Skip to main content
Glama

MSSQL MCP Server

by c0h1b4

MSSQL MCP 服务器

用于连接 Microsoft SQL Server 数据库的模型上下文协议 (MCP) 服务器。此服务器提供用于执行 SQL 查询和管理数据库连接的工具。

**版本公告:**本项目已升级至使用 Model Context Protocol SDK 1.9.0。详情请参阅UPGRADE.md

安装

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 MSSQL MCP 服务器:

npx -y @smithery/cli install @c0h1b4/mssql-mcp-server --client claude

手动安装

npm install mssql-mcp-server

用法

将服务器添加到您的 MCP 设置配置文件:

{ "mcpServers": { "mssql": { "command": "mssql-mcp-server", "env": { "MSSQL_CONNECTION_STRING": "Server=localhost;Database=master;User Id=sa;Password=yourpassword;", // Or individual connection parameters: "MSSQL_HOST": "localhost", "MSSQL_PORT": "1433", "MSSQL_DATABASE": "master", "MSSQL_USER": "sa", "MSSQL_PASSWORD": "yourpassword", "MSSQL_ENCRYPT": "false", "MSSQL_TRUST_SERVER_CERTIFICATE": "true" } } } }

工具

询问

在 MSSQL 数据库上执行 SQL 查询。

参数
  • connectionString (字符串,可选):完整的连接字符串(可替代单独的参数)
  • host (字符串,可选):数据库服务器主机名
  • port (数字,可选):数据库服务器端口(默认值:1433)
  • database (字符串,可选):数据库名称(默认值:master)
  • username (字符串,可选):数据库用户名
  • password (字符串,可选):数据库密码
  • query (字符串,必需):要执行的 SQL 查询
  • encrypt (布尔值,可选):启用加密(默认值:false)
  • trustServerCertificate (布尔值,可选):信任服务器证书(默认值:true)

必须提供connectionString或( host + username + password )。

例子
const result = await use_mcp_tool({ server_name: 'mssql', tool_name: 'query', arguments: { host: 'localhost', username: 'sa', password: 'yourpassword', query: 'SELECT * FROM Users', }, });

运行服务器

本地开发

# Install dependencies npm install # Run in development mode npm run dev # Build npm run build # Run the built server npm start

使用 Docker

# Build and start services (SQL Server + MCP server) docker-compose up # Or just build the Docker image docker build -t mssql-mcp-server .

测试

# Run tests npm test # Run tests with coverage npm run test:coverage

安全

该服务器包括针对危险 SQL 操作的安全措施:

  • 阻止潜在的有害命令,如 DROP、TRUNCATE、ALTER、CREATE、EXEC 等。
  • 验证所有输入参数和数据库名称
  • 设置查询长度和超时的合理限制
  • 使用连接池来获得更好的性能和安全性

执照

麻省理工学院

-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

通过模型上下文协议实现 SQL 查询的执行以及 Microsoft SQL Server 数据库连接的管理。

  1. 安装
    1. 通过 Smithery 安装
    2. 手动安装
  2. 用法
    1. 工具
      1. 询问
    2. 运行服务器
      1. 本地开发
      2. 使用 Docker
    3. 测试
      1. 安全
        1. 执照

          Related MCP Servers

          • -
            security
            A
            license
            -
            quality
            A 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.
            Last updated -
            20
            Python
            MIT License
            • Linux
            • Apple
          • -
            security
            F
            license
            -
            quality
            A Model Context Protocol server that enables SQL query execution, database management, and business intelligence capabilities through MySQL connections.
            Last updated -
            JavaScript
          • A
            security
            A
            license
            A
            quality
            A Model Context Protocol server that enables secure interaction with Microsoft SQL Server databases, allowing AI assistants to list tables, read data, and execute SQL queries through a controlled interface.
            Last updated -
            1
            108
            Python
            MIT License
            • Linux
            • Apple
          • -
            security
            A
            license
            -
            quality
            A Model Context Protocol server that enables executing SQL queries and managing connections with Microsoft SQL Server databases.
            Last updated -
            3
            TypeScript
            MIT License

          View all related MCP servers

          MCP directory API

          We provide all the information about MCP servers via our MCP API.

          curl -X GET 'https://glama.ai/api/mcp/v1/servers/c0h1b4/mssql-mcp-server'

          If you have feedback or need assistance with the MCP directory API, please join our Discord server