SQL Server MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@SQL Server MCP Server show me the schema of the users table"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
SQL Server MCP Server
一个基于模型上下文协议(MCP)的 SQL Server 数据库操作服务器,让 AI 助手能够通过标准化接口与 SQL Server 数据库交互。
功能特性
查询执行:执行带参数化的 SELECT 查询
数据修改:执行 INSERT、UPDATE、DELETE 操作
结构查询:列出数据库表、查看表结构
性能分析:使用执行计划分析查询性能
连接管理:支持环境变量自动连接,安全可靠
Related MCP server: mcp-server-mssql
安装
npm install sqlserver-mcp-ddz或直接使用 npx:
npx sqlserver-mcp-ddz配置
方式一:环境变量自动连接(推荐)
在 MCP 客户端配置中添加环境变量,服务器启动时会自动连接数据库:
{
"mcpServers": {
"sqlserver-mcp-ddz": {
"command": "npx",
"args": ["-y", "sqlserver-mcp-ddz"],
"env": {
"SQLSERVER_HOST": "127.0.0.1",
"SQLSERVER_PORT": "1433",
"SQLSERVER_USER": "sa",
"SQLSERVER_PASSWORD": "your_password",
"SQLSERVER_DATABASE": "your_database",
"SQLSERVER_ENCRYPT": "true",
"SQLSERVER_TRUST_CERTIFICATE": "false"
}
}
}
}支持的环境变量:
变量名 | 说明 | 必填 | 默认值 |
| 数据库主机地址 | 是 | - |
| 数据库端口 | 否 |
|
| 数据库用户名 | 是 | - |
| 数据库密码 | 是 | - |
| 数据库名称 | 是 | - |
| 是否加密连接 | 否 |
|
| 是否信任服务器证书 | 否 |
|
方式二:手动连接
不在配置中添加环境变量时,需要通过 connect_db 工具手动连接:
{
"mcpServers": {
"sqlserver": {
"command": "npx",
"args": ["-y", "sqlserver-mcp-ddz"]
}
}
}可用工具
connect_db
连接到 SQL Server 数据库(环境变量配置后可省略此步骤)。
参数:
host(字符串,必填):数据库主机地址port(数字,可选):数据库端口,默认 1433user(字符串,必填):数据库用户名password(字符串,必填):数据库密码database(字符串,必填):数据库名称encrypt(布尔,可选):是否加密连接,默认 truetrustServerCertificate(布尔,可选):是否信任服务器证书,默认 false
示例:
{
"host": "localhost",
"port": 1433,
"user": "sa",
"password": "your_password",
"database": "mydb",
"encrypt": true,
"trustServerCertificate": false
}query
执行 SELECT 查询并返回结果。
参数:
sql(字符串,必填):SQL SELECT 查询语句params(数组,可选):查询参数
示例:
{
"sql": "SELECT * FROM users WHERE age > @param0",
"params": [18]
}execute
执行 INSERT、UPDATE 或 DELETE 查询。
参数:
sql(字符串,必填):SQL 语句params(数组,可选):查询参数
示例:
{
"sql": "INSERT INTO users (name, email) VALUES (@param0, @param1)",
"params": ["张三", "zhangsan@example.com"]
}list_tables
列出当前数据库中的所有表。
describe_table
获取指定表的结构信息,包括列、主键和外键。
参数:
table(字符串,必填):表名
示例:
{
"table": "users"
}explain
使用执行计划分析 SQL 查询性能。
参数:
sql(字符串,必填):要分析的 SQL 查询
示例:
{
"sql": "SELECT * FROM users WHERE email = 'test@example.com'"
}show_statement
执行系统存储过程或 SHOW 类语句。
参数:
sql(字符串,必填):SQL 语句
示例:
{
"sql": "EXEC sp_who"
}安全说明
query工具仅允许 SELECT、SHOW、WITH 和 EXEC 查询数据修改操作请使用
execute工具所有查询支持参数化输入,防止 SQL 注入
数据库凭据仅在运行时传递,不会被持久化存储
Available Tools
7 toolsconnect_dbC
Connect to a SQL Server database
Inputs: host (required), user (required), database (required), password (required), +3 more.
describe_tableC
Get the structure of a specific table
Inputs: table (required).
executeC
Execute an INSERT, UPDATE, or DELETE query
Inputs: sql (required), params.
explainB
Analyze SQL query performance using execution plan
Inputs: sql (required).
list_tablesB
List all tables in the database
Inputs: no named parameters.
queryC
Execute a SELECT query and return results
Inputs: sql (required), params.
show_statementC
Execute system stored procedures or SHOW-like statements
Inputs: sql (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
The core split between read (query), write (execute), and metadata (list_tables, describe_table) is clear, and explain is distinctly performance-focused. The only fuzzy boundary is execute vs. show_statement, since both run arbitrary SQL against the server and only the description distinguishes DML from stored procedures/SHOW statements.
Four tools follow a verb_noun pattern (describe_table, show_statement, connect_db, list_tables) while three are bare verbs (execute, explain, query), producing a mixed but still readable convention. 'query' is especially weak as a name since it is both a verb and a noun and doesn't pair with the others.
Seven tools is well-scoped for a database access server: one connection tool, two metadata tools, three execution tools, and one diagnostics tool. Each tool covers a distinct slice of the workflow and none feels redundant or padded.
The read/execute/metadata/explain loop is covered, but there is no DDL support (CREATE/ALTER/DROP TABLE) since execute is limited to INSERT/UPDATE/DELETE, no transaction control, no disconnect or list_databases to pair with connect_db. Agents can handle typical data workflows but will hit dead ends on schema changes and connection management.
Maintenance
Related MCP Connectors
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Draxlr's remote MCP server connects AI assistants to your SQL databases and dashboards. Explore schemas, run read-only queries, manage saved queries and dashboards, and export results, all with row-level security so each user sees only their own data.
Related MCP Servers
- AlicenseAqualityNot gradedmaintenanceEnables AI assistants to interact with both local SQL Server and Azure SQL Database through natural language, supporting queries, data manipulation, and schema operations with built-in security features.82,621 npm1-
- AlicenseBqualityDmaintenanceEnables AI agents to interact with Microsoft SQL Server databases via MCP, supporting table listing, schema retrieval, and CRUD operations.31MIT
- AlicenseNot gradedqualityDmaintenanceA comprehensive MCP server for SQL Server database operations, enabling CRUD operations, schema exploration, and stored procedure execution through natural language.4 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to connect to Microsoft SQL Server via the MCP protocol, supporting database schema queries, data reading, and arbitrary SQL execution.ISC