mssql-mcp
An MCP server that enables AI assistants to query and manage Microsoft SQL Server databases using natural language.
README
MSSQL MCP Server
⚠️ EXPERIMENTAL USE ONLY — This MCP Server is provided for educational and experimental purposes. It is NOT intended for production use. Use appropriate security measures and test thoroughly before any deployment.
What is this? 🤔
An MCP (Model Context Protocol) server that lets AI assistants like Claude, Cursor, and other LLM-powered tools query and manage your Microsoft SQL Server database using natural language.
Quick Example
You: "Show me all customers from New York"
AI: *queries your MSSQL database and returns the results in plain English*
Features 📊
- Natural language to SQL — Ask questions in plain English
- Row-level CRUD support — Read, insert, update, and delete rows with dedicated tools
- Schema discovery — Inspect tables, views, procedures, functions, and triggers
- Safer write workflows —
preview_updateandpreview_deleteplus confirmation gating for destructive tools - Rich text tool results — Concise summaries with JSON inlined in the primary text block when helpful, plus resource links for large artifacts
- Query analysis — Generate estimated execution plans with
explain_query - MCP resources and prompts — Expose schema snapshots, query artifacts, and prompt templates to capable clients
- Remote transport support — Run locally over
stdioor remotely over Streamable HTTP - Multi-database support — Connect to multiple databases on the same server
- Read-only mode — Restrict to inspection, search, read, and explain tools for safer environments
- Secure by default — WHERE clauses required for updates/deletes; SQL injection safeguards for reads; DDL tools off unless
ENABLE_DDL=true
Supported AI Clients
- Claude Desktop
- Cursor (VS Code with AI)
- VS Code Agent extension
- Any MCP-compatible client
Quick Start 🚀
One-Click Install (Cursor / VS Code)
Click Add to Cursor or Install in VS Code above to add the MCP server—no cloning required; it runs via npx.
Cursor opens a dedicated install page that lists env vars you can edit before saving (similar to a short form). The Add to Cursor preset includes every variable from the table below (connection, timeouts, ENABLE_DDL defaulting to false, write caps, MCP_TRANSPORT / HTTP settings, MCP_BASE_URL, etc.); set ENABLE_DDL to true there if you want schema tools.
VS Code only applies the JSON embedded in the vscode:mcp/install link: you get static placeholder values, not an interactive database wizard. To be prompted for host, database, and credentials when the server starts, add inputs to .vscode/mcp.json as in the Prompted inputs example under VS Code (mcp.json) below.
Prerequisites
- Node.js 18 or higher
- SQL Server (local, Azure SQL, or remote)
- An MCP-compatible AI client (Claude Desktop, Cursor, etc.)
Installation
From npm (recommended):
npx -y @eamonboyle/mssql-mcp
Or install globally: npm install -g @eamonboyle/mssql-mcp
From source (for development):
git clone https://github.com/eamonboyle/mssql-mcp.git
cd mssql-mcp
npm install
npm run build
Configuration
Environment Variables
| Variable | Required | Description |
|---|---|---|
SERVER_NAME |
Yes | SQL Server host (e.g., localhost, my-server.database.windows.net) |
DATABASE_NAME |
Yes** | Default database name. Optional when DATABASES is set. |
DB_USER |
Yes* | SQL Server username (for SQL authentication) |
DB_PASSWORD |
Yes* | SQL Server password (for SQL authentication) |
READONLY |
No | "true" for read-only mode, "false" for full access (default: "false") |
DATABASES |
No | Comma-separated allowlist for multi-database access (e.g., ProdDB,StagingDB) |
CONNECTION_TIMEOUT |
No | Timeout in seconds (default: 30) |
QUERY_TIMEOUT_MS |
No | Query timeout in milliseconds (default: 30000) |
MAX_ROWS |
No | Maximum rows returned by read tools (default: 10000) |
TRUST_SERVER_CERTIFICATE |
No | "true" for self-signed certs (e.g., local dev) (default: "false") |
MCP_TRANSPORT |
No | stdio (default) or http |
MCP_HTTP_HOST |
No | Bind host for Streamable HTTP mode (default: 127.0.0.1) |
MCP_HTTP_PORT |
No | Bind port for Streamable HTTP mode (default: 3333) |
MCP_BASE_URL |
No | Optional externally visible base URL for remote deployments |
ENABLE_DDL |
No | "true" enables create_table, create_index, and drop_table (default: false) |
MAX_WRITE_ROWS |
No | Maximum rows a single write tool may affect before it is blocked (default: 100) |
REQUIRE_WRITE_PREVIEW |
No | "true" (default): call preview_update / preview_delete, then pass the returned previewToken with confirmed=true on update_data / delete_data. Set "false" to skip the token (confirmation still applies). |
* Required for SQL authentication. For Windows/Integrated authentication, consult the mssql package documentation.
** Required for single-database setups. When DATABASES is provided, DATABASE_NAME becomes optional and is used as the default database if set.
Cursor (mcp.json)
Use global or project MCP config: e.g. ~/.cursor/mcp.json or .cursor/mcp.json in your repo.
{
"mcpServers": {
"mssql": {
"command": "npx",
"args": ["-y", "@eamonboyle/mssql-mcp"],
"env": {
"SERVER_NAME": "localhost",
"DATABASE_NAME": "AppDB",
"DATABASES": "AppDB,ReportingDB",
"DB_USER": "your_username",
"DB_PASSWORD": "your_password",
"READONLY": "false"
}
}
}
}
Restart Cursor after changes.
Cursor HTTP MCP
To expose the server remotely over Streamable HTTP:
{
"mcpServers": {
"mssql-http": {
"url": "http://127.0.0.1:3333"
}
}
}
Run the server with:
MCP_TRANSPORT=http MCP_HTTP_HOST=127.0.0.1 MCP_HTTP_PORT=3333 npx -y @eamonboyle/mssql-mcp
VS Code (mcp.json)
VS Code uses .vscode/mcp.json (or MCP: Open User Configuration) with a top-level servers object—not mcpServers.
Static env (same idea as the one-click link; edit values in the file):
{
"servers": {
"mssql": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@eamonboyle/mssql-mcp"],
"env": {
"SERVER_NAME": "localhost",
"DATABASE_NAME": "AppDB",
"DATABASES": "AppDB,ReportingDB",
"DB_USER": "your_username",
"DB_PASSWORD": "your_password",
"READONLY": "false",
"CONNECTION_TIMEOUT": "30",
"QUERY_TIMEOUT_MS": "30000",
"MAX_ROWS": "10000",
"TRUST_SERVER_CERTIFICATE": "false"
}
}
}
}
Prompted inputs (closest to Cursor’s hosted form: VS Code asks on first start, then stores values). Use ${input:…} in env and define matching entries under inputs:
{
"inputs": [
{
"type": "promptString",
"id": "mssql-server",
"description": "SQL Server host (e.g. localhost or my-server.database.windows.net)"
},
{
"type": "promptString",
"id": "mssql-database",
"description": "Default database name"
},
{
"type": "promptString",
"id": "mssql-databases",
"description": "Optional: comma-separated DB allowlist (e.g. AppDB,ReportingDB). Leave empty for a single database."
},
{
"type": "promptString",
"id": "mssql-user",
"description": "SQL Server login (SQL authentication)"
},
{
"type": "promptString",
"id": "mssql-password",
"description": "SQL Server password",
"password": true
}
],
"servers": {
"mssql": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@eamonboyle/mssql-mcp"],
"env": {
"SERVER_NAME": "${input:mssql-server}",
"DATABASE_NAME": "${input:mssql-database}",
"DATABASES": "${input:mssql-databases}",
"DB_USER": "${input:mssql-user}",
"DB_PASSWORD": "${input:mssql-password}",
"READONLY": "false",
"CONNECTION_TIMEOUT": "30",
"QUERY_TIMEOUT_MS": "30000",
"MAX_ROWS": "10000",
"TRUST_SERVER_CERTIFICATE": "false"
}
}
}
}
Claude Desktop Setup
- Open File → Settings → Developer → Edit Config
- Add the MCP server configuration:
{
"mcpServers": {
"mssql": {
"command": "npx",
"args": ["-y", "@eamonboyle/mssql-mcp"],
"env": {
"SERVER_NAME": "localhost",
"DATABASE_NAME": "AppDB",
"DATABASES": "AppDB,ReportingDB",
"DB_USER": "your_username",
"DB_PASSWORD": "your_password",
"READONLY": "false"
}
}
}
}
- Restart Claude Desktop.
Multi-Database Support
To allow queries across multiple databases:
"env": {
"SERVER_NAME": "your-server.database.windows.net",
"DATABASE_NAME": "ProdDB",
"DATABASES": "ProdDB,StagingDB,AnalyticsDB",
"DB_USER": "your_username",
"DB_PASSWORD": "your_password",
"READONLY": "false"
}
DATABASES defines which databases the MCP can access. All tools accept an optional databaseName parameter. When omitted, the server uses DATABASE_NAME if it is included in DATABASES; otherwise it falls back to the first entry in DATABASES.
Sample Configurations
See src/samples/ for example configs:
claude_desktop_config.json— Claude Desktopvscode_agent_config.json— VS Code Agent
Usage Examples
Once configured, you can ask things like:
- "Show me all users from New York"
- "List the configured databases this MCP can access"
- "Preview the rows that would be updated before changing status to archived"
- "Explain this query and open the execution plan viewer"
- "Show the foreign keys and relationships around dbo.Orders"
- "Search the customers table for email addresses containing acme.com"
- "Create a new table called products with columns for id, name, and price"
- "Update all pending orders to completed status"
- "Delete inactive sessions older than 30 days"
- "List all tables in the database"
- "Describe the schema of the customers table"
- "List all views and procedures in the reporting database"
- "Explain why this SELECT query is slow"
Available Tools
| Tool | Read-only | Description |
|---|---|---|
read_data |
✓ | Execute validated SELECT queries |
search_data |
✓ | Search one or more columns with parameterized LIKE |
explain_query |
✓ | Get an estimated execution plan for a SELECT query |
list_table |
✓ | List tables in a database |
describe_table |
✓ | Get table schema (optional schemaName) |
list_objects |
✓ | List tables, views, procedures, functions, and triggers |
describe_object |
✓ | Describe an object definition and metadata |
insert_data |
Insert rows | |
update_data |
Update rows (requires WHERE; optional schemaName) |
|
delete_data |
Delete rows (requires WHERE; optional schemaName) |
|
create_table |
Create tables | |
create_index |
Create indexes | |
drop_table |
Drop tables |
Resources And Prompts
Clients that support MCP resources and prompts can use additional discovery surfaces:
- Resources — Server config, prompt catalog, per-database table lists, per-database object lists, and dynamic table/object resources
- Prompts —
explore_schema,draft_safe_select, andreview_write_operation
Changelog
Release notes: CHANGELOG.md.
Security Notes
- Credentials — Never commit
DB_USER/DB_PASSWORDor config files with secrets. Use environment variables or a secrets manager. - Read-only mode — Set
READONLY: "true"when you only need queries. - WHERE clauses — Update and delete operations require explicit WHERE clauses to reduce accidental full-table changes.
- SQL injection — The server validates and restricts dangerous SQL patterns.
- DDL tools — Disabled by default (
ENABLE_DDLunset orfalse). SetENABLE_DDL=trueonly if the assistant should create/drop tables or indexes.
Contributing
Contributions are welcome! Please read CONTRIBUTING.md for guidelines. By participating, you agree to uphold our Code of Conduct.
License
MIT License — see LICENSE for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
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 模型以安全和受控的方式获取实时的网络信息。