mcp-mssql
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-mssql show me the last 5 orders from the orders table"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-mssql — Claude için MSSQL MCP Sunucusu
MSSQL’e Model Context Protocol (MCP) üzerinden güvenli bağlanan, STDIO modunda çalışan bir sunucudur.
Claude Desktop (ve MCP uyumlu diğer istemciler) tarafından harici bir tool olarak başlatılır.
NL→SQL: doğal dilde sor — Claude şemayı (discover_schema) kullanarak SQL üretir ve
run_sql_safeile çalıştırır.
✨ Özellikler
connect_db — Ortam değişkenleriyle MSSQL bağlantısını dener (sağlık kontrolü).
discover_schema —
INFORMATION_SCHEMAtabanlı tablo/kolon keşfi; basit heuristiklerledate_cols,measures,dimsetiketleri üretir.run_sql_safe — Tek
SELECTifadesini çalıştırır. DDL/DML ve çoklu ifadeler engellenir. OtomatikTOP 5000enjekte edilir (sorguda varsa dokunmaz).
🛡️ Guardrails:
DROP/UPDATE/INSERT/MERGE/EXECvb. yasak;;,--,/* */gibi çoklu ifade/yorum kalıpları reddedilir; 15 sn timeout.
Related MCP server: Azure SQL MCP Server
🧰 Gereksinimler
Node.js 18+ (öneri: 20+)
MSSQL (lokal / Docker / uzak / Azure SQL)
🔧 Kurulum
git clone https://github.com/ismailcankaratas/mcp-mssql.git
cd mcp-mssql
npm install.env oluştur (repo kökünde):
MSSQL_HOST=localhost
MSSQL_PORT=1433
MSSQL_DB=YourDatabase
MSSQL_USER=readonly_login
MSSQL_PWD=ReadOnly!123Geliştirmede
encrypt=truevetrustServerCertificate=truevarsayılan. Üretimde geçerli sertifika ileencrypt=truekullanın.
▶️ Çalıştırma
Geliştirme (TSX ile)
npm run devBuild & Start
npm run build
npm start🧪 Hızlı Bağlantı Testi
npx tsx src/test_local.tsBeklenen:
OK: [ { current_db: "...", version: "Microsoft SQL Server 2022 ..." } ]🖥️ Claude Desktop Entegrasyonu
Config dosyası (claude_desktop_config.json) örneği:
{
"mcpServers": {
"mssql": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/dist/server.js"],
"env": {
"MSSQL_HOST": "localhost",
"MSSQL_PORT": "1433",
"MSSQL_DB": "YourDatabase",
"MSSQL_USER": "readonly_login",
"MSSQL_PWD": "ReadOnly!123"
}
}
}
}Geliştirmede TS kaynakla koşmak istersen
Command: "tsx",Args: ["src/server.ts"]kullanabilirsin.
🧭 Claude içinde kullanım örnekleri
Bağlantı testi
tool: connect_db {}Şemayı keşfet
tool: discover_schema {}Güvenli sorgu çalıştır
tool: run_sql_safe {"sql":"SELECT TOP 5 name FROM sys.databases ORDER BY name"}
NL→SQL: doğal dilde sor — Claude şemayı (discover_schema) kullanarak SQL üretir ve
run_sql_safeile çalıştırır.
🔒 Güvenlik Notları
Üretimde salt-okuma kullanıcı (
db_datareader) kullanın.run_sql_safeyalnızca tek bir SELECT’e izin verir; DDL/DML ve çoklu ifadeler reddedilir.Maksimum satır sayısı için
TOPotomatik enjekte edilir (varsayılan: 5000).Sorgu süresi varsayılan 15s timeout ile sınırlıdır.
.envve gizli bilgileri asla versiyona eklemeyin.
🩺 Sorun Giderme
ENOTFOUND / ECONNREFUSED / ETIMEDOUT → Host/port doğru mu? Docker portu açık mı?
ELOGIN → Kullanıcı/parola doğru mu? DB’de
db_datareaderyetkisi var mı?TLS uyarısı (SNI) → IP yerine
MSSQL_HOST=localhostkullanın veya sertifika tanımlayın.discover_schema boş → DB’de tablo yok ya da kullanıcı
INFORMATION_SCHEMA’ya erişemiyor.
📂 Proje Yapısı
src/
db.ts # MSSQL bağlantısı ve query helper
schema.ts # INFORMATION_SCHEMA keşfi + heuristik etiketler
server.ts # MCP server (connect_db, discover_schema, run_sql_safe)
test_local.ts # MSSQL bağlantı smoke testi📄 Lisans
MIT
Available Tools
3 toolsconnect_dbConnect MSSQLA
Env üzerinden MSSQL bağlantısını test eder.
Inputs: no named parameters.
discover_schemaDiscover schemaA
Tablo/kolon keşfi ve heuristik etiketler (date_cols, measures, dims).
Inputs: no named parameters.
run_sql_safeRun SQL (safe)A
Yalnızca tek SELECT ifadesi çalıştırır; DDL/DML yasak; TOP limiti otomatik enjekte edilir.
Inputs: sql (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: connect_db tests the connection, discover_schema retrieves metadata, and run_sql_safe executes read-only queries. No overlap or confusion between them.
All tool names follow a consistent verb_noun pattern with snake_case, making the set predictable and easy to navigate. 'run_sql_safe' adds a modifier but still fits the convention.
Three tools is an ideal count for a focused read-only MSSQL exploration server. Each tool covers a necessary step in the workflow without redundancy or bloat.
The server provides a complete workflow for safe database exploration: verify connection, understand schema, and run SELECT queries. For its intended read-only purpose, there are no meaningful gaps.
Maintenance
Related MCP Connectors
Query your warehouse or a CSV with Claude/ChatGPT over MCP, governed by table-level ACL + audit.
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides secure SQL Server database access, allowing users to list tables and execute SQL queries through natural language in Claude Desktop.MIT
- FlicenseAqualityDmaintenanceEnables querying, exploring, and interacting with Azure SQL databases through MCP-compatible clients like Claude Desktop.5-
- AlicenseNot gradedqualityDmaintenanceEnables LLMs to query and manage MSSQL databases using natural language, supporting CRUD operations and schema management.2,112 npmMIT
- FlicenseNot gradedqualityDmaintenanceEnables secure interaction with Microsoft SQL Server databases, allowing schema exploration, metadata retrieval, and read-only query execution through natural language.1-