Skip to main content
Glama
SQL Server MCP

SQL Server MCP

by cwilby

mcp-node-mssql

用法

光标

请参阅官方 Cursor 文档以了解更多信息。

  1. 打开(或创建) mcp.json文件(它应该位于~/.cursor/mcp.json或<project-root>/.cursor/mcp.json中,但有关更多详细信息,请参阅 Cursor 文档)。

  2. 添加以下详细信息并保存文件:

{
  "mcpServers": {
    "mssql": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-node-mssql"
      ],
      "env": {
        "DB_HOST": "localhost",
        "DB_PORT": "1433",
        "DB_USERNAME": "<username>",
        "DB_PASSWORD": "<password>",
        "DB_DATABASE": "<database>"
      }
    }
  }
}

风帆冲浪

请参阅官方 Windsurf 文档以了解更多信息。

  1. 打开Windsurf MCP Configuration Panel

  2. 单击Add custom server 。

  3. 添加以下详细信息并保存文件:

{
  "mcpServers": {
    "mssql": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-node-mssql"
      ],
      "env": {
        "DB_HOST": "localhost",
        "DB_PORT": "1433",
        "DB_USERNAME": "<username>",
        "DB_PASSWORD": "<password>",
        "DB_DATABASE": "<database>"
      }
    }
  }
}

克劳德·科德

请参阅官方 Claude Code 文档以了解更多信息。

您可以从 Claude Code CLI 添加新的 MCP 服务器。但直接修改 json 文件更简单!

  1. 打开 Claude Code 配置文件(它应该在~/.claude.json中)。

  2. 找到projects > mcpServers部分并添加以下详细信息并保存文件:

{
  "projects": {
    "mcpServers": {
      "mssql": {
        "command": "npx",
        "args": [
          "-y",
          "mcp-node-mssql"
        ],
        "env": {
          "DB_HOST": "localhost",
          "DB_PORT": "1433",
          "DB_USERNAME": "<username>",
          "DB_PASSWORD": "<password>",
          "DB_DATABASE": "<database>"
        }
      }
    }
  }
}

Related MCP server: Microsoft SQL Server MCP Server

问题和故障排除

在执行任何其他操作之前,请确保您正在运行最新版本!

如果您在使用此 MCP 服务器时遇到问题,请在GitHub上打开一个问题!

发展

安装

npm install

建造

npm run build

本地运行开发服务器

要测试 MCP 服务器的本地开发版本(而不是使用已发布的包),请按照以下步骤操作:

  1. 构建项目:

npm run build
  1. 创建或修改您的mcp.json文件以引用您的本地构建:

{
  "mcpServers": {
    "mssql": {
      "command": "node",
      "args": [
        "/path/to/your/local/mcp-node-mssql/dist/index.js"
      ],
      "env": {
        "DB_HOST": "localhost",
        "DB_PORT": "1433",
        "DB_USERNAME": "<username>",
        "DB_PASSWORD": "<password>",
        "DB_DATABASE": "<database>"
      }
    }
  }
}
  1. 将此mcp.json文件放置在以下位置之一:

    • 对于 Cursor:在您的主目录( ~/.cursor/mcp.json )或项目目录( .cursor/mcp.json )中

    • 对于 Windsurf:使用 MCP 配置面板添加自定义服务器

  2. 重新启动您的 AI 助手(Cursor 或 Windsurf)以加载新配置。

这使您可以立即测试 MCP 服务器的更改,而无需发布新版本。

Available Tools

8 tools
commit-transactionC

Commit a transaction

Inputs: transactionId (required).

get-stored-procedureC

Get a specific stored procedure by name

Inputs: procedureName (required).

get-stored-proceduresB

Get a list of all stored procedures in the database

get-tableC

Get a specific table by name

Inputs: tableName (required).

get-tablesB

Get a list of all tables in the database

queryC

Query the database with a SQL statement

Inputs: query (required).

rollback-transactionC

Rollback a transaction

Inputs: transactionId (required).

start-transactionC

Start a new transaction

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 8 tools

    Disambiguation5/5

    Every tool has a clearly distinct purpose with no ambiguity. Tools are clearly separated by resource type (tables vs stored procedures) and action type (get specific vs get list vs transaction operations vs query). The query tool stands alone as a general-purpose operation.

    Naming Consistency5/5

    All tools follow a consistent verb-noun pattern with hyphens. Transaction tools use verb-transaction pattern (start-transaction, commit-transaction, rollback-transaction), get operations use get-noun pattern (get-table, get-tables), and query stands alone as a clear single verb. The naming is perfectly predictable throughout.

    Tool Count5/5

    8 tools is well-scoped for a database server. Each tool earns its place with clear responsibilities: 4 for data/metadata retrieval, 3 for transaction management, and 1 for general querying. This provides comprehensive coverage without bloat.

    Completeness4/5

    The toolset covers core database operations well with querying, transaction management, and metadata retrieval. Minor gaps exist in write operations beyond transactions (no explicit insert/update/delete tools) and schema modification (no create/alter/drop tools), but the query tool provides a workaround for most of these operations.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      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.
      63
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      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.
      1
      406
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      A Model Context Protocol server that allows Large Language Models like Claude to execute SQL queries, explore database schemas, and maintain persistent connections to SQL Server databases.
      -
    • F
      license
      A
      quality
      C
      maintenance
      A Model Context Protocol server that enables LLMs like Claude to interact with Microsoft SQL Server databases through natural language, supporting queries, data manipulation, and table management.
      8
      -