MSSQL MCP

MSSQL MCP

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

Category
Visit Server

README

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

    安裝後,可以在命令提示字元執行以下指令確認:

    odbcad32
    

    在「驅動程式」標籤中應該可以看到「ODBC Driver 17 for SQL Server」或「ODBC Driver 18 for SQL Server」。

  2. 安裝依賴 在當前目錄下執行:

    npm install
    
  3. 設定環境變數 複製 .env.example.env,並填入您的資料庫連線資訊:

    cp .env.example .env
    

    編輯 .env 檔案:

    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 的資料庫工具

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured