claude-database-tools
A SQL Server CLI and MCP server for Claude Code that supports standard SQL Server authentication for database interaction and management. It enables users to perform schema exploration, execute queries, and manage data records with built-in SQL injection prevention.
README
claude-database-tools
SQL Server CLI and MCP server for Claude Code.
Why This Tool?
This project is an alternative to Microsoft's official mssql MCP server with some key advantages:
-
SQL Server Authentication: Supports SQL Server authentication (username/password), not just Windows/Entra authentication. Ideal for development environments, Docker containers, or scenarios where integrated auth isn't available.
-
CLI-First Design: The CLI tools can be used directly from a Claude Code skill, giving you database access without requiring MCP server setup. This is useful when you want simpler configuration or need to work in environments where MCP servers are problematic.
-
MCP Server Included: Also provides an MCP server if you prefer that integration approach.
Features
- CLI Tool: Command-line interface for SQL Server operations
- MCP Server: Model Context Protocol server for Claude integration (experimental)
- Security: Built-in SQL injection prevention and query validation
- Operations: List tables, describe schemas, query data, insert/update/delete records, DDL generation
Installation
git clone https://github.com/cyronius/claude-database-tools.git
cd claude-database-tools
npm install
npm run build
Configuration
Copy .env.example to .env and configure your database connection:
cp .env.example .env
Edit .env with your SQL Server credentials:
SQL_SERVER=localhost
SQL_DATABASE=your_database
SQL_USER=your_username
SQL_PASSWORD=your_password
SQL_PORT=1433
SQL_ENCRYPT=false
SQL_TRUST_SERVER_CERTIFICATE=true
CLI Usage
After building, run commands with:
node dist/cli/index.js <command> [options]
Or install globally:
npm install -g .
sql-cli <command> [options]
Commands
| Command | Description |
|---|---|
list-tables [schemas...] |
List tables, optionally filtered by schema |
describe-table <tableName> |
Get table schema (columns, indexes, foreign keys) |
read-data <query> |
Execute a SELECT query |
insert-data <tableName> <jsonData> |
Insert records |
update-data <tableName> <updates> <whereClause> |
Update records |
delete-data <tableName> <whereClause> --confirm |
Delete records |
exec-proc <procedureName> [params] |
Execute stored procedure |
create-table <tableName> <columns> |
Create a new table |
drop-table <tableName> |
Drop a table |
create-index <tableName> <indexName> <columns> |
Create an index |
get-ddl <tableName> |
Generate CREATE TABLE DDL |
get-alter-ddl <tableName> |
Generate ALTER TABLE DDL |
Examples
# List all tables
sql-cli list-tables
# List tables in specific schemas
sql-cli list-tables dbo sales
# Describe a table
sql-cli describe-table dbo.Users
# Query data
sql-cli read-data "SELECT TOP 10 * FROM dbo.Users"
# Insert data
sql-cli insert-data dbo.Users '{"name": "John", "email": "john@example.com"}'
# Update data
sql-cli update-data dbo.Users '{"name": "Jane"}' "id = 1"
# Delete data (requires --confirm flag)
sql-cli delete-data dbo.Users "id = 1" --confirm
# Get table DDL
sql-cli get-ddl dbo.Users
MCP Server (Experimental)
Note: The MCP server integration has not been fully tested. Use at your own risk.
The MCP server allows Claude Code to interact with your SQL Server database directly.
Setup
Add to your ~/.claude/mcp.json:
{
"mcpServers": {
"mssql": {
"command": "node",
"args": ["/path/to/claude-database-tools/dist/index.js"],
"env": {
"SQL_SERVER": "your-server",
"SQL_DATABASE": "your-database",
"SQL_USER": "your-username",
"SQL_PASSWORD": "your-password",
"SQL_ENCRYPT": "true",
"READONLY": "true"
}
}
}
}
Restart Claude Code to load the MCP server.
Available MCP Tools
Read-Only (available when READONLY=true):
list_tables- List tablesdescribe_table- Get table schemaread_data- Execute SELECT queriesget_table_ddl- Generate CREATE TABLE DDLget_table_alter_ddl- Generate ALTER TABLE DDL
Write (requires READONLY=false):
insert_data- Insert recordsupdate_data- Update recordsdelete_data- Delete recordscreate_table- Create tablescreate_index- Create indexesdrop_table- Drop tablesexecute_stored_proc- Execute stored procedures
Security
- SQL Injection Prevention: SELECT queries are validated against dangerous keywords and patterns
- Parameterized Queries: All INSERT/UPDATE/DELETE operations use parameterized queries
- WHERE Clause Required: UPDATE and DELETE operations require WHERE clauses
- Query Limits: Maximum query length of 10,000 characters, result sets limited to 10,000 records
- Read-Only Mode: Set
READONLY=trueto disable write operations
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。