mssql-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
🗄️ mssql-mcp
เชื่อม AI ของคุณเข้ากับ Microsoft SQL Server ผ่าน Model Context Protocol
ถามข้อมูลด้วยภาษาคน · ดู schema ได้ทันที · อ่านอย่างเดียวเป็นค่าเริ่มต้น
✨ จุดเด่น
🔒 Read-only โดยค่าเริ่มต้น อนุญาตเฉพาะ
SELECTปลอดภัยต่อข้อมูล⚡ ติดตั้งบรรทัดเดียว ผ่าน
npxไม่ต้อง clone เอง🌐 รองรับหลาย environment ตั้ง dev / uat / prod ในเซิร์ฟเวอร์เดียว และกำหนด read-only แยกรายตัวได้
🧰 5 เครื่องมือพร้อมใช้ ดูรายการ connection ฐานข้อมูล ตาราง โครงสร้างคอลัมน์ และรัน query
🛡️ จำกัดจำนวนแถว ป้องกันผลลัพธ์ใหญ่เกินไป (ค่าเริ่มต้น 500 แถว)
🔌 ใช้ได้กับ Claude Desktop, Claude Code และ MCP client อื่น ๆ
Related MCP server: mcp-server-mssql
🧰 เครื่องมือ (Tools)
Tool | หน้าที่ |
| แสดงรายการ connection/environment ที่ตั้งไว้ (ไม่แสดงรหัสผ่าน) |
| แสดงรายชื่อฐานข้อมูลบนเซิร์ฟเวอร์ |
| แสดงตารางและ view (กรองตาม schema ได้) |
| แสดงคอลัมน์ ชนิดข้อมูล nullable และ primary key |
| รัน T-SQL (อ่านอย่างเดียวหากไม่ปิดโหมด read-only) |
📦 ติดตั้ง
สิ่งที่ต้องมี: Node.js 18+ และ SQL Server ที่เชื่อมต่อได้ด้วย SQL Authentication
⚠️ ยังไม่รองรับ Windows Authentication (Integrated Security)
วิธีที่ 1: ใช้ผ่าน npx จาก GitHub (แนะนำ)
ไม่ต้องติดตั้งล่วงหน้า แค่ใส่ config ใน MCP client (ดูหัวข้อถัดไป)
ตัวอย่างนี้ใช้ repo ของ
koravut-Dev
วิธีที่ 2: clone แล้ว build เอง
git clone https://github.com/koravut-Dev/mssql-mcp.git
cd mssql-mcp
npm install # build อัตโนมัติผ่าน prepare scriptทุก tool (ยกเว้น
list_connections) รับพารามิเตอร์connectionเพิ่มเติม เช่น "ดูตารางใน uat" ถ้าไม่ระบุจะใช้ connection ค่าเริ่มต้น
🔧 ตั้งค่า MCP Client
Claude Desktop
แก้ไฟล์ claude_desktop_config.json
(Windows: %APPDATA%\Claude\ · macOS: ~/Library/Application Support/Claude/)
{
"mcpServers": {
"mssql": {
"command": "npx",
"args": ["-y", "github:koravut-Dev/mssql-mcp"],
"env": {
"MSSQL_SERVER": "localhost",
"MSSQL_PORT": "1433",
"MSSQL_DATABASE": "MyDatabase",
"MSSQL_USER": "readonly_user",
"MSSQL_PASSWORD": "your_password",
"MSSQL_TRUST_SERVER_CERTIFICATE": "true"
}
}
}
}จากนั้นรีสตาร์ท Claude Desktop
Claude Code
claude mcp add mssql \
-e MSSQL_SERVER=localhost \
-e MSSQL_DATABASE=MyDatabase \
-e MSSQL_USER=readonly_user \
-e MSSQL_PASSWORD=your_password \
-e MSSQL_TRUST_SERVER_CERTIFICATE=true \
-- npx -y github:koravut-Dev/mssql-mcpถ้า clone มาเอง
ใช้ "command": "node" และ "args": ["C:/path/to/mssql-mcp/dist/index.js"] แทน npx
🌐 หลาย Environment (dev / uat / prod)
สร้างไฟล์ config แล้วชี้ด้วย MSSQL_CONFIG (คัดลอกจาก mssql-mcp.config.example.json)
{
"default": "dev",
"connections": {
"dev": { "server": "dev-sql.example.com", "database": "MyApp", "user": "dev_user",
"password": "${MSSQL_DEV_PASSWORD}", "readonly": false },
"prod": { "server": "prod-sql.example.com", "database": "MyApp", "user": "prod_reader",
"password": "${MSSQL_PROD_PASSWORD}", "readonly": true, "maxRows": 200 }
}
}ตั้งค่าใน MCP client:
{
"mcpServers": {
"mssql": {
"command": "npx",
"args": ["-y", "github:koravut-Dev/mssql-mcp"],
"env": {
"MSSQL_CONFIG": "C:/secrets/mssql-mcp.config.json",
"MSSQL_DEV_PASSWORD": "...",
"MSSQL_PROD_PASSWORD": "..."
}
}
}
}🔑 ใช้
${ENV_VAR}ในค่าใดก็ได้ เพื่อเก็บรหัสผ่านไว้นอกไฟล์ config🔒
readonlyตั้งแยกได้ทีละ connection (ค่าเริ่มต้นtrue) แนะนำให้ prod เป็น read-only เสมอfield ที่ใช้ได้ในแต่ละ connection:
server,port,instance,database,user,password,encrypt,trustServerCertificate,readonly,maxRows,requestTimeout,descriptionไฟล์
mssql-mcp.config.jsonอยู่ใน.gitignoreแล้ว อย่า commit ขึ้น Gitถ้าไม่ตั้ง
MSSQL_CONFIGจะใช้โหมด connection เดียวจากตัวแปรด้านล่าง (ชื่อdefault)
⚙️ ตัวแปรสภาพแวดล้อม (โหมด connection เดียว)
ตัวแปร | ค่าเริ่มต้น | คำอธิบาย |
|
| ชื่อหรือ IP ของเซิร์ฟเวอร์ |
|
| พอร์ต |
| – | ชื่อ named instance (ถ้ามี) |
| – | ฐานข้อมูลเริ่มต้น |
| – | ผู้ใช้ SQL |
| – | รหัสผ่าน |
|
| เข้ารหัสการเชื่อมต่อ (Azure SQL ต้องเป็น |
|
| ตั้งเป็น |
|
|
|
|
| จำนวนแถวสูงสุดที่ส่งกลับ |
|
| timeout ของ query (มิลลิวินาที) |
🛡️ ความปลอดภัย
โหมด read-only ใน mssql-mcp เป็น ด่านตรวจเสริม ที่ตรวจว่า query ขึ้นต้นด้วย SELECT/WITH และไม่มีคำสั่งแก้ไขข้อมูล แต่ไม่ใช่การป้องกันที่สมบูรณ์
แนวทางที่ปลอดภัยจริง: สร้างผู้ใช้ที่มีสิทธิ์อ่านอย่างเดียวใน SQL Server
CREATE LOGIN mcp_reader WITH PASSWORD = 'ใส่รหัสผ่านที่แข็งแรง';
USE MyDatabase;
CREATE USER mcp_reader FOR LOGIN mcp_reader;
ALTER ROLE db_datareader ADD MEMBER mcp_reader;และอย่า commit ไฟล์ .env หรือรหัสผ่านขึ้น Git
💬 ตัวอย่างการใช้งาน
เมื่อเชื่อมต่อแล้ว ลองถาม AI ว่า:
"มี environment อะไรให้เชื่อมต่อบ้าง"
"มีตารางอะไรในฐานข้อมูล uat บ้าง"
"ตาราง Orders มีคอลัมน์อะไรบ้าง"
"ยอดขายรวมแต่ละเดือนของปีนี้เป็นเท่าไร"
"ลูกค้า 10 อันดับแรกที่สั่งซื้อมากที่สุดคือใคร"
🧑💻 สำหรับนักพัฒนา
npm install
npm run build # คอมไพล์ TypeScript -> dist/
npm run dev # watch modeทดสอบด้วย MCP Inspector:
npx @modelcontextprotocol/inspector node dist/index.js🔍 แก้ปัญหาเบื้องต้น
ตั้ง MSSQL_TRUST_SERVER_CERTIFICATE=true สำหรับเซิร์ฟเวอร์ที่ใช้ certificate แบบ self-signed
ตรวจว่า SQL Server เปิดโหมด SQL Server and Windows Authentication และผู้ใช้มีสิทธิ์เข้าถึงฐานข้อมูลนั้น
เปิด TCP/IP ใน SQL Server Configuration Manager, เปิดพอร์ต 1433 บน firewall, หรือใช้ MSSQL_INSTANCE กรณี named instance
📄 License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Related MCP Connectors
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
Draxlr's remote MCP server connects AI assistants to your SQL databases and dashboards. Explore schemas, run read-only queries, manage saved queries and dashboards, and export results, all with row-level security so each user sees only their own data.
Related MCP Servers
- AlicenseAqualityNot gradedmaintenanceEnables AI assistants to interact with both local SQL Server and Azure SQL Database through natural language, supporting queries, data manipulation, and schema operations with built-in security features.82,101 npm1-
- AlicenseBqualityDmaintenanceEnables AI agents to interact with Microsoft SQL Server databases via MCP, supporting table listing, schema retrieval, and CRUD operations.31MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to connect to Microsoft SQL Server via the MCP protocol, supporting database schema queries, data reading, and arbitrary SQL execution.ISC
- AlicenseNot gradedqualityNot gradedmaintenanceEnables AI agents to safely read SQL Server databases via MCP with structured queries, default-deny table permissions, OAuth authentication, and full audit logging.MIT