SQL Server MCP (Windows)

io.github.TharanaBope由 GitHub 帳號 TharanaBope 發布v1.0.4更新於 Oct 27, 2026

SQL Server MCP with RAG capabilities for Windows (native ODBC support)

已驗證STDIO僅桌面資料庫資料與分析

概覽

AI 產生的概覽

本機 MCP 伺服器,讓 AI 助理在 Windows 上探索與查詢 Microsoft SQL Server 資料庫,支援結構搜尋與唯讀 SELECT 查詢。

可以做什麼
  • 列出並描述資料庫、資料表、檢視表、預存程序及資料庫統計資訊
  • 整理外鍵關聯,找出與某張資料表直接相連的資料表
  • 在資料表、欄位、檢視表與預存程序中搜尋結構,並找出某個欄位的使用位置
  • 執行具逾時與資料列上限的唯讀 SELECT 查詢
  • 快取結構中繼資料以加快重複查詢
適用情境
當你使用 SQL Server 執行個體,希望助理不必手寫 SQL 就能回答其結構、資料表關聯與資料內容的問題時適用。較適合探索與唯讀報表,而非變更結構。
執行需求
在 Windows 上透過 npx 以本機程序執行,需要原生 ODBC 驅動程式與 msnodesqlv8 驅動程式。需要可連線的 SQL Server 執行個體,並以環境變數提供連線設定:SQL_SERVER、SQL_DATABASE、SQL_PORT、SQL_USE_WINDOWS_AUTH,使用 SQL 驗證時另需 SQL_USERNAME 與 SQL_PASSWORD。選用設定包括 QUERY_TIMEOUT、MAX_RESULT_ROWS、ENABLE_SCHEMA_CACHE 與 CACHE_TTL_MINUTES。
安裝前請注意
SQL_PASSWORD 以明文寫在助理的設定檔中,請妥善保護該檔案。伺服器預設為唯讀,但 README 指出可明確開啟寫入操作,屆時助理將能修改資料。查詢結果與結構資訊會傳送給你所使用的 AI 模型供應商。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 SQL Server MCP (Windows),將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

SQL Server MCP - Cross-Platform Database Integration for AI

[License: MIT] [TypeScript] [MCP] [npm version] [npm downloads]

A Model Context Protocol (MCP) server implementation for SQL Server that enables AI assistants to explore and query SQL Server databases through natural language. Built as a RAG (Retrieval-Augmented Generation) system optimized for database knowledge exploration.

🌟 Features

  • 🔍 Schema Exploration - List databases, tables, views, stored procedures
  • 🔗 Relationship Mapping - Discover foreign key relationships and table dependencies
  • 🔎 Search & Discovery - Global schema search across tables, columns, procedures
  • ⚡ Safe Query Execution - Read-only SELECT queries with automatic timeouts and row limits
  • 🗄️ Schema Caching - Fast retrieval with configurable TTL (default: 60 minutes)
  • 🔐 Security First - Read-only by default, SQL injection prevention, query validation
  • 🖥️ Cross-Platform - Native Windows Authentication & macOS Docker support

🎥 Demo

See SQL Server MCP in action with AI assistant integration:

[SQL Server MCP Demo]

Note: Watch how natural language queries instantly explore database schemas, find relationships, and retrieve data - all without leaving your AI assistant!

🚀 Quick Start

This repository contains two platform-specific implementations:

Windows Version → sql-server-mcp/

  • ✅ Windows Authentication (ODBC Driver 17)
  • ✅ SQL Server Authentication
  • ✅ Native msnodesqlv8 driver for optimal performance
  • 📖 Windows Setup Guide

macOS Version → sql-server-mcp-mac/

  • ✅ SQL Server Authentication (Docker required)
  • ✅ Pure JavaScript mssql driver (no native dependencies)
  • 📖 macOS Setup Guide

📦 Installation

🎉 Now Available on MCP Registry!

This server is officially published in the Model Context Protocol Registry:

  • Windows: io.github.TharanaBope/sql-server-mcp
  • macOS: io.github.TharanaBope/sql-server-mcp-macos

🚀 Quick Start (Recommended)

No installation needed! Just add to your AI assistant's configuration:

Claude Desktop (Windows)

Config Location: %APPDATA%\Claude\claude_desktop_config.json

json
{  "mcpServers": {    "sql-server": {      "command": "npx",      "args": ["-y", "@tharanabopearachchi/sql-server-mcp@latest"],      "env": {        "SQL_SERVER": "localhost",        "SQL_DATABASE": "master",        "SQL_USE_WINDOWS_AUTH": "true"      }    }  }}
Claude Desktop (macOS)

Config Location: ~/Library/Application Support/Claude/claude_desktop_config.json

json
{  "mcpServers": {    "sql-server": {      "command": "npx",      "args": ["-y", "@tharanabopearachchi/sql-server-mcp-macos@latest"],      "env": {        "SQL_SERVER": "localhost",        "SQL_DATABASE": "master",        "SQL_USE_WINDOWS_AUTH": "false",        "SQL_USERNAME": "sa",        "SQL_PASSWORD": "your_password"      }    }  }}
LM Studio Configuration

Config Location: Varies by platform

  • Windows: %USERPROFILE%\.lmstudio\config.json
  • macOS: ~/.lmstudio/config.json
json
{  "mcpServers": {    "sql-server": {      "command": "npx",      "args": ["-y", "@tharanabopearachchi/sql-server-mcp@latest"],      "env": {        "SQL_SERVER": "localhost",        "SQL_DATABASE": "master",        "SQL_USE_WINDOWS_AUTH": "true",        "SQL_USERNAME": "",        "SQL_PASSWORD": ""      }    }  }}
VS Code with Continue Extension

Config Location: ~/.continue/config.json

json
{  "experimental": {    "modelContextProtocolServers": [      {        "transport": {          "type": "stdio",          "command": "npx",          "args": ["-y", "@tharanabopearachchi/sql-server-mcp@latest"]        },        "env": {          "SQL_SERVER": "localhost",          "SQL_DATABASE": "master",          "SQL_USE_WINDOWS_AUTH": "true"        }      }    ]  }}
Cursor IDE

Config Location: Cursor Settings → Features → Model Context Protocol

json
{  "mcpServers": {    "sql-server": {      "command": "npx",      "args": ["-y", "@tharanabopearachchi/sql-server-mcp@latest"],      "env": {        "SQL_SERVER": "localhost",        "SQL_DATABASE": "master",        "SQL_USE_WINDOWS_AUTH": "true"      }    }  }}
Cline (VS Code Extension)

Config Location: VS Code Settings → Cline → MCP Settings

json
{  "mcpServers": {    "sql-server": {      "command": "npx",      "args": ["-y", "@tharanabopearachchi/sql-server-mcp@latest"],      "env": {        "SQL_SERVER": "localhost",        "SQL_DATABASE": "master",        "SQL_USE_WINDOWS_AUTH": "true"      }    }  }}

Restart your AI assistant and you're ready to go!

🛠️ Development Setup

For development or local modifications:

Windows
bash
cd sql-server-mcpnpm installnpm run build

👉 Complete Windows Setup Instructions

macOS
bash
cd sql-server-mcp-macnpm installnpm run build

👉 Complete macOS Setup Instructions

🛠️ Available MCP Tools

The server provides 12 powerful tools for database exploration:

Schema Exploration

  • list_databases - Discover all available databases
  • list_tables - View tables with row counts
  • describe_table - Get detailed schema (columns, types, constraints, indexes)
  • list_views - List all views
  • list_stored_procedures - List stored procedures with metadata
  • get_procedure_definition - Get full SQL definition
  • get_database_overview - High-level statistics

Relationship Mapping

  • get_table_relationships - Get foreign key relationships (incoming & outgoing)
  • get_related_tables - Find directly connected tables

Search & Discovery

  • search_schema - Search across tables, columns, views, procedures
  • find_column_usage - Find all tables containing a specific column

Query Execution

  • execute_query - Execute read-only SELECT queries safely

💬 Example Usage

Once configured, you can ask your AI assistant:

"What databases are available on this server?"
"Show me all tables in the Sales database"
"What's the schema of the Orders table?"
"Find all tables that reference the Customers table"
"Search for any columns related to 'email'"
"Execute: SELECT TOP 10 * FROM Products ORDER BY Price DESC"

⚙️ Configuration

Both versions use environment variables for configuration:

env
SQL_SERVER=localhostSQL_DATABASE=masterSQL_PORT=1433SQL_USE_WINDOWS_AUTH=true          # Windows onlySQL_USERNAME=                       # For SQL AuthSQL_PASSWORD=                       # For SQL AuthQUERY_TIMEOUT=30MAX_RESULT_ROWS=1000ENABLE_SCHEMA_CACHE=trueCACHE_TTL_MINUTES=60

See platform-specific READMEs for detailed configuration instructions.

🔐 Security Features

  • ✅ Read-only by default - Write operations disabled unless explicitly enabled
  • ✅ Query validation - Only SELECT statements allowed by default
  • ✅ Automatic timeouts - Prevents long-running queries
  • ✅ Row limits - Prevents memory exhaustion
  • ✅ SQL injection prevention - Query sanitization and validation
  • ✅ Database whitelisting - Optional restriction to specific databases

🏗️ Architecture

MCP/├── sql-server-mcp/              # Windows implementation│   ├── src/│   │   ├── index.ts             # MCP server entry point│   │   ├── database/            # Connection, caching, queries│   │   ├── tools/               # 12 MCP tools│   │   └── types/               # TypeScript interfaces│   ├── dist/                    # Compiled output│   ├── package.json│   └── README.md                # Windows documentation│├── sql-server-mcp-mac/          # macOS implementation│   ├── src/                     # Same structure as Windows│   └── README.md                # macOS documentation│├── LICENSE                      # MIT License└── README.md                    # This file

🎯 Use Cases

Database Exploration

  • "What tables exist in this database?"
  • "Show me the structure of the Users table"
  • "List all stored procedures"

Schema Research

  • "Find all tables with an 'email' column"
  • "Search for anything related to 'invoice'"
  • "What views are available?"

Relationship Analysis

  • "How are Orders and Customers related?"
  • "Show me all tables that reference Products"
  • "What are the foreign key relationships for this table?"

Data Queries

  • "Get the top 10 most expensive products"
  • "Show me recent orders"
  • "What's the total count of records in each table?"

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

📚 Resources

🌐 Platform-Specific Documentation

PlatformDirectoryKey Features
Windowssql-server-mcp/Windows Auth, ODBC Driver, Native performance
macOSsql-server-mcp-mac/Docker SQL Server, Pure JS, No native deps

Made with ❤️ for the MCP community

⭐ Star this repo if you find it useful! 🐛 Report bugs via Issues 💬 Questions? Check the Discussions

來源:README.md,提交 9d80105

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.0.4最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分