Skip to main content
Glama
ismailcankaratas

mcp-mssql

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_safe ile çalıştırır.


✨ Özellikler

  • connect_db — Ortam değişkenleriyle MSSQL bağlantısını dener (sağlık kontrolü).

  • discover_schemaINFORMATION_SCHEMA tabanlı tablo/kolon keşfi; basit heuristiklerle date_cols, measures, dims etiketleri üretir.

  • run_sql_safeTek SELECT ifadesini çalıştırır. DDL/DML ve çoklu ifadeler engellenir. Otomatik TOP 5000 enjekte edilir (sorguda varsa dokunmaz).

🛡️ Guardrails: DROP/UPDATE/INSERT/MERGE/EXEC vb. 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!123

Geliştirmede encrypt=true ve trustServerCertificate=true varsayılan. Üretimde geçerli sertifika ile encrypt=true kullanı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_safe ile çalıştırır.


🔒 Güvenlik Notları

  • Üretimde salt-okuma kullanıcı (db_datareader) kullanın.

  • run_sql_safe yalnızca tek bir SELECT’e izin verir; DDL/DML ve çoklu ifadeler reddedilir.

  • Maksimum satır sayısı için TOP otomatik enjekte edilir (varsayılan: 5000).

  • Sorgu süresi varsayılan 15s timeout ile sınırlıdır.

  • .env ve 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_datareader yetkisi var mı?

  • TLS uyarısı (SNI) → IP yerine MSSQL_HOST=localhost kullanı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 tools
connect_dbConnect MSSQLA

Env üzerinden MSSQL bağlantısını test eder.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool 'tests' the connection, implying a non-destructive diagnostic action, but it does not disclose what happens on success/failure, whether authentication is required, or whether any side effects occur. The description offers minimal insight beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence that directly conveys the tool's purpose. It contains zero waste and is appropriately sized for a tool with no parameters and a simple function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (no parameters, no output schema) and the presence of sibling tools, the description is minimally viable but lacks context about what 'test' entails (e.g., output, failure behavior, dependency on environment settings). It is complete enough for a basic understanding but does not fully cover the operational context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema is empty with zero parameters, so there are no parameter semantics to explain. Per the rubric, 0 parameters warrants a baseline score of 4. The description does not introduce any parameter-related confusion.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states a specific verb ('test eder' - tests) and resource ('MSSQL bağlantısı' - MSSQL connection), effectively distinguishing it from sibling tools like discover_schema and run_sql_safe. It conveys the tool's sole purpose without ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus the sibling tools (discover_schema, run_sql_safe). It does not mention alternatives, prerequisites, or exclusions. The usage context is only implied by the name, not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

discover_schemaDiscover schemaA

Tablo/kolon keşfi ve heuristik etiketler (date_cols, measures, dims).

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It discloses that the tool produces heuristic labels, which is a behavioral trait, and 'keşfi' (discovery) suggests a read-only operation. However, it does not explicitly state safety (no side effects), whether an active connection is required, or any limitations. Some useful context is provided, but significant gaps remain.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single concise sentence in Turkish that conveys the main purpose and output labels. No redundant information, perfectly scoped for a zero-parameter tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple with zero parameters and no output schema, but the description only partially explains the return value (tables/columns and heuristic labels). It lacks details about the exact result structure, any expected database state, and how this tool fits into a workflow with siblings. However, it covers the essentials for a schema discovery tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, so the schema already covers everything. The description adds no parameter semantics because there are none; per the rubric, 0 parameters yields a baseline of 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool performs table/column discovery and outputs heuristic labels (date_cols, measures, dims). It is distinct from sibling tools connect_db and run_sql_safe, which handle connection and query execution, respectively.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies a use case for exploring database schema but does not explicitly state when to use it versus alternatives, nor does it mention prerequisites or exclusions. The sibling names provide some context, but the description itself offers no explicit usage guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

run_sql_safeRun SQL (safe)A

Yalnızca tek SELECT ifadesi çalıştırır; DDL/DML yasak; TOP limiti otomatik enjekte edilir.

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYes

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It reveals important traits: it only permits a single SELECT, rejects DDL/DML, and automatically injects a TOP limit. These details go beyond a generic 'runs SQL' and give the agent a clear safety and modification profile.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in Turkish that delivers all need-to-know information without extraneous words. Its structure is ideal for quick agent parsing.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with one simple parameter, no output schema, and no annotations, the description covers the essential constraints and behavior. It lacks examples or output format details, but these are not critical for an agent to correctly invoke a straightforward SELECT execution tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds substantial meaning to the 'sql' parameter, which has zero schema coverage. It specifies the parameter must be a single SELECT statement, forbids DDL/DML, and notes the automatic TOP injection. This fully compensates for the lack of schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's function with a specific verb and resource: 'Yalnızca tek SELECT ifadesi çalıştırır' (executes only a single SELECT statement). It distinguishes itself from siblings by explicitly limiting scope to SELECT and forbidding DDL/DML, making its purpose unmistakable.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives clear context about when to use the tool (for read-only SELECT queries) and explicitly excludes DDL/DML. However, it does not explicitly name alternative tools like connect_db or discover_schema, so it falls short of a 5 but provides better guidance than an implicit usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 3 tool updatesv1.0.0
    • First observedconnect_db
    • First observeddiscover_schema
    • First observedrun_sql_safe

TDQS

A4.2/5.0
Disambiguation5/5

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.

Naming Consistency5/5

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.

Tool Count5/5

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.

Completeness5/5

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

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables LLMs to query and manage MSSQL databases using natural language, supporting CRUD operations and schema management.
    3,338
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables secure interaction with Microsoft SQL Server databases, allowing schema exploration, metadata retrieval, and read-only query execution through natural language.
    1
    -

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ismailcankaratas/mcp-mssql'

If you have feedback or need assistance with the MCP directory API, please join our Discord server