Featured

Deploy OpenClaw in 60 seconds — 20% off logoDeploy OpenClaw in 60 seconds — 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free
6,000+ web scrapers for your AI agent, start free logo6,000+ web scrapers for your AI agent, start free

Apify gives your agent live web data: 6,000+ prebuilt scrapers and actors, MCP-ready. Sign up free with $5 in usage credits.

Try Apify free
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data — no proxies, no parsers, no maintenance.

Start building free
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it — secured from day one.

Get it set up for you
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free
Reach 48,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

Enables AI assistants to connect to Microsoft SQL Server via the MCP protocol, supporting database schema queries, data reading, and arbitrary SQL execution.

README.md

MSSQL MCP Server

這是一個自定義的 Model Context Protocol (MCP) 伺服器,用於連接 Microsoft SQL Server。它可以讓您的 AI 助手(如 Claude Desktop 或 Cursor)直接查詢資料庫結構、讀取資料或執行 SQL 指令。

安裝與設定

  1. 安裝 ODBC Driver for SQL Server

此 MCP 伺服器需要 Microsoft ODBC Driver 17 或 18 for SQL Server 來支援 Always Encrypted 功能。

下載連結:https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server

安裝後,可以在命令提示字元執行以下指令確認: ``bash odbcad32 `` 在「驅動程式」標籤中應該可以看到「ODBC Driver 17 for SQL Server」或「ODBC Driver 18 for SQL Server」。

  1. 安裝依賴

在當前目錄下執行: ``bash npm install ``

  1. 設定環境變數

複製 .env.example.env,並填入您的資料庫連線資訊: ``bash cp .env.example .env ` 編輯 .env 檔案: `ini DB_USER=sa DB_PASSWORD=您的密碼 DB_SERVER=localhost DB_DATABASE=您的資料庫名稱 DB_PORT=1433 DB_ENCRYPT=true DB_TRUST_SERVER_CERTIFICATE=true ``

在 Claude Desktop 中使用

編輯您的 Claude Desktop 設定檔 (通常位於 %APPDATA%\Claude\claude_desktop_config.json),新增以下內容:

{
  "mcpServers": {
    "mssql": {
      "command": "node",
      "args": ["D:/MCP/MSSQL_MCP/index.js"]
    }
  }
}

功能

此 MCP 伺服器提供以下功能:

Resources (資源)

  • mssql://{schema}/{table}: 讀取指定資料表的前 100 筆資料。
  • 例如: mssql://dbo/Users

Tools (工具)

  • list_tables: 列出資料庫中所有的資料表。
  • 參數 (可選): schema (篩選架構), limit (限制筆數)
  • get_table_schema: 查詢指定資料表的欄位結構。
  • 參數: tableName (例如 "dbo.Users")
  • execute_query: 執行任意 T-SQL 指令 (SELECT, INSERT, UPDATE, DELETE)。
  • 參數: query (例如 "SELECT * FROM Users WHERE ID = 1")

安全性注意事項

  • 此伺服器允許執行任意 SQL 指令,請確保不要在生產環境中隨意執行破壞性指令 (DROP, DELETE 等)。
  • 請勿將包含密碼的 .env 檔案提交到版本控制系統。

Always Encrypted 支援限制

此 MCP 伺服器使用 Node.js 的 mssql 套件(基於 Tedious 驅動),目前無法解密 SQL Server Always Encrypted 欄位

查詢包含 Always Encrypted 欄位的資料表時,加密欄位會顯示為 [ENCRYPTED - Always Encrypted column cannot be decrypted by Node.js mssql driver]

如需查詢加密欄位的實際內容,請使用:

  • SQL Server Management Studio (SSMS)
  • Azure Data Studio
  • 支援 Always Encrypted 的 .NET 應用程式
  • 其他支援 Always Encrypted 的資料庫工具

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Databases servers.