Microsoft SQL Server MCP Server
Microsoft SQL Server MCP 服务器
模型上下文协议 (MCP) 服务器,支持与 Microsoft SQL Server 数据库进行安全交互。该服务器允许 AI 助手通过受控界面列出表格、读取数据并执行 SQL 查询,从而使数据库探索和分析更加安全、更加结构化。
特征
将可用的 SQL Server 表列为资源
读取表内容
执行 SQL 查询并进行适当的错误处理
通过环境变量保护数据库访问
综合日志记录
自动系统依赖项安装
Related MCP server: SQL Server MCP
安装
通过 MCP 安装时,该软件包将自动安装所需的系统依赖项(如 FreeTDS):
pip install mssql-mcp-server配置
设置以下环境变量:
MSSQL_SERVER=localhost
MSSQL_USER=your_username
MSSQL_PASSWORD=your_password
MSSQL_DATABASE=your_database用法
使用 Claude Desktop
将其添加到您的claude_desktop_config.json中:
{
"mcpServers": {
"mssql": {
"command": "uv",
"args": [
"--directory",
"path/to/mssql_mcp_server",
"run",
"mssql_mcp_server"
],
"env": {
"MSSQL_SERVER": "localhost",
"MSSQL_USER": "your_username",
"MSSQL_PASSWORD": "your_password",
"MSSQL_DATABASE": "your_database"
}
}
}
}作为独立服务器
# Install dependencies
pip install -r requirements.txt
# Run the server
python -m mssql_mcp_server发展
# Clone the repository
git clone https://github.com/RichardHan/mssql_mcp_server.git
cd mssql_mcp_server
# Create virtual environment
python -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
# Install development dependencies
pip install -r requirements-dev.txt
# Run tests
pytest安全注意事项
切勿提交环境变量或凭据
使用具有最低所需权限的数据库用户
考虑实施查询白名单以供生产使用
监控并记录所有数据库操作
安全最佳实践
此 MCP 服务器需要数据库访问权限才能运行。出于安全考虑:
创建具有最小权限的专用 SQL Server 登录名
切勿使用 sa 凭据或管理帐户
将数据库访问限制为仅进行必要的操作
启用日志记录以用于审计目的
定期对数据库访问进行安全审查
有关以下方面的详细说明,请参阅SQL Server 安全配置指南:
创建受限的 SQL Server 登录名
设置适当的权限
监控数据库访问
安全最佳实践
⚠️重要提示:配置数据库访问时始终遵循最小特权原则。
执照
MIT 许可证 - 详情请参阅 LICENSE 文件。
贡献
分叉存储库
创建你的功能分支(
git checkout -b feature/amazing-feature)提交您的更改(
git commit -m 'Add some amazing feature')推送到分支(
git push origin feature/amazing-feature)打开拉取请求
Available Tools
1 toolexecute_sqlC
Execute an SQL query on the SQL Server
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The SQL query to execute |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, and the description fails to disclose whether queries are read-only or can modify data, potential risks like SQL injection, or result formats. This is a significant gap for a tool that can execute arbitrary SQL.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is very concise at one sentence, but it lacks structure and does not front-load key information beyond the basic action. It could include more detail without becoming verbose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the lack of output schema and annotations, the description is incomplete. It does not explain what the tool returns (e.g., result sets, affected rows), error behavior, or any constraints. Critical context for safe usage is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has high coverage (100%) and describes the 'query' parameter sufficiently. The description adds no extra meaning beyond what the schema already provides, so a baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'execute' and the resource 'SQL query on the SQL Server', making the purpose straightforward. However, it restates the tool name without adding depth beyond stating it runs queries.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this tool or when to avoid it. No mention of prerequisites, security considerations, or alternatives. The description provides no contextual usage direction.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
1 tool update
v1.0.0- First observed
execute_sql
TDQS
Scored across 1 tool
Only one tool exists, so there is no risk of confusion or overlap.
With a single tool, naming is trivially consistent to itself.
A single SQL execution tool is insufficient for the typical scope of SQL Server operations, which usually requires multiple tools for schema exploration, query execution, and data manipulation.
The tool set is severely incomplete; it lacks fundamental operations such as listing tables, describing schemas, or managing databases, limiting useful agent workflows.
Maintenance
Related MCP Connectors
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.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
The BigQuery remote MCP server is a fully managed service that uses the Model Context Protocol to connect AI applications and LLMs to BigQuery data sources. It provides secure, standardized tools for AI agents to list datasets and tables, retrieve schemas, generate and execute SQL queries through natural language, and analyze data—enabling direct access to enterprise analytics data without requiring manual SQL coding.
The HubSpot MCP Server acts as a bridge that enables AI assistants and Large Language Models to securely interact with HubSpot CRM data through natural conversation, without requiring users to understand complex API structures. It provides read-only access to standard CRM objects (contacts, companies, deals, tickets, products, invoices, and more) and their associations, secured via OAuth 2.0, allowing AI agents to perform tasks like summarizing deals, fetching company updates, and looking up record changes.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceA Model Context Protocol server that enables secure and structured interaction with Microsoft SQL Server databases, allowing AI assistants to list tables, read data, and execute SQL queries with controlled access.59MIT
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI assistants (Cursor, Windsurf, Claude Code) to interact with Microsoft SQL Server databases by providing connectivity through environment-configurable connections.8585 npm8MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that provides AI assistants with comprehensive access to SQL databases, enabling schema inspection, query execution, and database operations with enterprise-grade security.25 npm9MIT
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that provides comprehensive access to Microsoft SQL Server databases, enabling Language Models to inspect schemas, execute queries, manage database objects, and perform advanced database operations.8-