mcp-mssql
Enables natural language to SQL queries on MSSQL databases via Claude, with safe SELECT-only execution and schema discovery.
README
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.
🧰 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!123
Geliştirmede
encrypt=truevetrustServerCertificate=truevarsayılan. Üretimde geçerli sertifika ileencrypt=truekullanın.
▶️ Çalıştırma
Geliştirme (TSX ile)
npm run dev
Build & Start
npm run build
npm start
🧪 Hızlı Bağlantı Testi
npx tsx src/test_local.ts
Beklenen:
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
Recommended Servers
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.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.