Token导航 LogoToken导航TokenDH.com
Mssql Server MCP logo
数据服务未说明官方级别未说明来源级核验

Mssql Server MCP

MCP Server

一个全面的SQL Server数据库操作工具集,提供30多种工具用于数据库管理、查询、分析和维护。

工具数

27

提示词数

0

GitHub Stars

0

资源数

0
数据分析JavaScriptClaude性能监控Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

mohammadrehan1992

提供方

mohammadrehan1992

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

SQL Server MCP🗄️

全面 模型上下文协议(MCP) 用于SQL server数据库操作的服务器。该服务器通过Claude Desktop或任何兼容MCP的客户端提供30多种数据库管理、查询、分析和管理工具。

](https://github.com/mohammadrehan1992/mssql-server-mcp/stargazers) ](https://github.com/mohammadrehan1992/mssql-server-mcp/network) ![License: MIT](https://opensource.org/licenses/MIT) ](https://nodejs.org/)

🚀 特性

🔍 数据库发现和模式分析

  • 列出数据库、表、视图、存储过程和函数
  • 详细的表结构分析,包括列、数据类型、约束
  • 索引和外键关系映射
  • 完整的模式探索工具

📊 数据操作和查询

  • 执行任何具有参数绑定的SQL查询
  • 具有过滤、排序和分页功能的表数据检索
  • 带条件WHERE子句的行计数
  • 使用参数执行存储过程

性能与监控

  • 查询执行计划分析
  • 数据库性能统计
  • 表大小分析和存储度量
  • 主动连接监控
  • 查询性能见解

🔧 数据库管理

  • 数据库备份创建(完整、差异、日志)
  • 数据库完整性检查(DBCC CHECKDB)
  • 数据库文件信息(.mdf、.ldf)
  • 一般数据库信息和元数据

👥 安全和用户管理

  • 列出数据库用户和角色
  • 用户权限分析
  • 安全主体信息

🔄 SQL Server代理和作业

  • SQL Server代理作业列表
  • 作业执行历史和状态
  • 自动化任务监控

📦 安装

方法1:从GitHub安装(推荐)

# Install globally from GitHub
npm install -g https://github.com/mohammadrehan1992/mssql-server-mcp.git

方法2:克隆并在本地安装

# Clone the repository
git clone https://github.com/mohammadrehan1992/mssql-server-mcp.git

# Navigate to the directory
cd mssql-server-mcp

# Install dependencies
npm install

# Install globally
npm install -g .

方法3:下载并安装

  1. 从下载ZIP文件
  2. 提取文件
  3. 在提取的文件夹中打开终端
  4. 运行安装命令:
npm install
npm install -g .

验证安装

安装后,验证其是否正常工作:

# Check if the command is available
sql-server-mcp --help

# Or check the installation path
which sql-server-mcp  # On macOS/Linux
where sql-server-mcp  # On Windows

🔧 配置

Claude桌面设置

添加到您的Claude Desktop配置文件中:

窗户: %APPDATA%\Claude\claude_desktop_config.json\ macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "sqlserver": {
      "command": "sql-server-mcp",
      "env": {
        "SQL_CONNECTION_STRING": "Server=localhost;Database=YourDatabase;Integrated Security=true;TrustServerCertificate=true;"
      }
    }
  }
}
注: 如果您是在本地而不是全局安装的,请使用服务器文件的完整路径: ``json { "mcpServers": { "sqlserver": { "command": "node", "args": ["/full/path/to/mssql-server-mcp/server.js"], "env": { "SQL_CONNECTION_STRING": "your-connection-string-here" } } } } ``

连接字符串示例

Windows身份验证(推荐)

Server=localhost;Database=YourDatabase;Integrated Security=true;TrustServerCertificate=true;

SQL Server Express

Server=.\\SQLEXPRESS;Database=YourDatabase;Integrated Security=true;TrustServerCertificate=true;

本地数据库

Server=(localdb)\\MSSQLLocalDB;Database=YourDatabase;Integrated Security=true;TrustServerCertificate=true;

使用用户名和密码

Server=localhost;Database=YourDatabase;User Id=username;Password=password;TrustServerCertificate=true;

Azure SQL数据库

Server=your-server.database.windows.net;Database=YourDatabase;User Id=username;Password=password;Encrypt=true;

带端口的命名实例

Server=localhost\\INSTANCE_NAME,1433;Database=YourDatabase;Integrated Security=true;TrustServerCertificate=true;

🛠️ 可用工具

📋 Basic Operations (2 tools)

  • execute_query -使用可选参数执行任何SQL查询
  • execute_stored_procedure -使用参数执行存储过程

🗂️ Schema Discovery (6 tools)

  • list_databases -列出SQL Server实例上的所有数据库
  • list_tables -列出具有可选架构筛选的表
  • list_views -列出具有可选架构筛选的数据库视图
  • list_stored_procedures -列出具有可选架构筛选的存储过程
  • list_functions -列出具有可选模式筛选的用户定义函数
  • list_schemas -列出当前数据库中的所有架构

🔍 Table Structure Analysis (4 tools)

  • describe_table -获取详细的表结构(列、数据类型、约束)
  • get_table_indexes -获取特定表的所有索引
  • get_table_constraints -获取所有约束(PK、FK、CHECK等)
  • get_foreign_keys -获取外键关系

📊 Data Operations (2 tools)

  • get_table_data -通过过滤、排序和分页检索表数据
  • get_table_count -使用可选的WHERE条件获取行数

📈 Performance & Statistics (6 tools)

  • get_database_info -一般数据库信息和元数据
  • get_table_sizes -表大小分析和存储度量
  • get_active_connections -有关活动数据库连接的信息
  • get_database_files -数据库文件信息(.mdf、.ldf)
  • analyze_query_plan -获取查询的执行计划
  • get_query_statistics -最近查询的性能统计

🔧 Backup & Maintenance (2 tools)

  • backup_database -创建数据库备份(完整、差异、日志)
  • check_database_integrity -运行DBCC CHECKDB进行完整性验证

👥 Security & Users (3 tools)

  • list_users -列出所有数据库用户
  • list_roles -列出所有数据库角色
  • get_user_permissions -获取特定用户的权限

🔄 SQL Agent & Jobs (2 tools)

  • list_sql_agent_jobs -列出SQL Server代理作业
  • get_job_history -获取作业执行历史记录

🧪 测试您的连接

创建一个测试脚本来验证您的连接是否正常:

// test-connection.js
const sql = require('mssql');

async function testConnection() {
  const connectionString = 'Your-Connection-String-Here';
  
  try {
    const pool = await sql.connect(connectionString);
    const result = await pool.request().query('SELECT @@VERSION as Version');
    console.log('✅ Connection successful!');
    console.log('SQL Server Version:', result.recordset[0].Version);
    await pool.close();
  } catch (error) {
    console.error('❌ Connection failed:', error.message);
  }
}

testConnection();

运行方式:

node test-connection.js

🚨 故障排除

常见连接问题

  1. “无法连接到本地主机:1433”

- SQL Server服务可能未运行 - TCP/IP协议可能已禁用 - 尝试 .\SQLEXPRESS 而不是 localhost

  1. “用户登录失败”

- 检查SQL身份验证的用户名/密码 - 验证是否启用了Windows身份验证 - 确保用户具有数据库访问权限

  1. “找不到服务器”

- 验证服务器名称和实例 - 检查SQL Server Browser服务是否正在运行 - 尝试使用显式端口: localhost,1433

启用TCP/IP协议

  1. 打开 配置管理器
  2. 首选 SQL Server网络配置MSSQLSERVER协议
  3. 启用 传输控制协议/网际协议
  4. 重新启动SQL Server服务

查找SQL Server实例

# List SQL Server services
sc query | findstr SQL

# List network instances
sqlcmd -L

💡 使用示例

基本查询执行

Ask Claude: "Execute this query: SELECT TOP 10 * FROM Users WHERE Active = 1"

模式探索

Ask Claude: "Show me all tables in the database and describe the Users table structure"

性能分析

Ask Claude: "What are the largest tables in the database and show me recent query performance statistics"

数据分析

Ask Claude: "Get the first 100 rows from the Orders table where OrderDate is from last month"

数据库管理

Ask Claude: "Check database integrity and show me information about database files"

🔒 安全考虑

  • 使用 身份验证 尽可能提高安全性
  • 将数据库用户权限限制为所需的最小访问权限
  • 使用 信任服务器证书=true 仅用于当地发展
  • 对于生产,配置正确的SSL证书
  • 定期审查用户权限和访问日志

🤝 贡献

我们欢迎捐款!以下是您可以提供帮助的方式:

  1. 分叉存储库 在GitHub上
  2. 克隆你的叉子 本地:
   git clone https://github.com/your-username/mssql-server-mcp.git
  1. 创建要素分支:
   git checkout -b feature/amazing-feature
  1. 进行更改 并对其进行测试
  2. 提交您的更改:
   git commit -m 'Add amazing feature'
  1. 推你的叉子:
   git push origin feature/amazing-feature
  1. 打开拉取请求 在GitHub上

开发设置

# Clone the repo
git clone https://github.com/mohammadrehan1992/mssql-server-mcp.git
cd mssql-server-mcp

# Install dependencies
npm install

# Test your changes
node server.js

报告问题

发现错误或有功能请求?请 打开一个问题 与:

  • 问题/特征的清晰描述
  • 复制步骤(针对bug)
  • 您的环境详细信息(操作系统、Node.js版本、SQL Server版本)
  • 预期行为与实际行为

📋 需求

  • Node.js 16.0.0或更高版本
  • SQL Server 2012年或更高版本(包括Express、LocalDB、Azure SQL)
  • 视窗 (用于Windows身份验证)或SQL Server身份验证

📄 许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。

🙋‍♂️ 支持与社区

  • 🐛 报告问题:
  • 💬 讨论:
  • 📚 文档:
  • ⭐ 给我们一颗星: 如果这个项目对你有帮助,请考虑 主演它!

获取帮助

  1. 检查 问题 -你的问题可能已经得到了回答
  2. 阅读 故障排除 下节
  3. 打开新问题 提供有关您问题的详细信息
  4. 加入讨论 在GitHub上讨论一般问题

🌟 表示支持

如果这个项目对你有帮助,请考虑:

  • 对存储库进行标记
  • 🍴 叉它 贡献
  • 📢 分享它 与其他可能觉得有用的人一起
  • 🐛 报告错误 以帮助改善它

📊 项目统计

Last commit

______________________________________________________________________

由以下材料制成❤️ SQL Server社区

*由开发 穆罕默德·雷恩*

目录标签

目录标签

数据分析JavaScriptClaude性能监控数据库管理本地部署SQLServer工具数据库查询数据库维护

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

27

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP