Skip to main content
Glama
deepesh112

mssql-mcp-server

by deepesh112

mssql-mcp-server

Production-ready, cross-platform Microsoft SQL Server MCP server — lets AI assistants (Claude Desktop, Cursor, VS Code, Windsurf, Continue, ...) work with SQL Server through the Model Context Protocol.

Security-first: read-only by default, AST-based SQL policy enforcement, dangerous statements blocked, parameterized queries only, secrets never logged.

Features

  • 51 tools across 7 groups (registered according to your security policy):

    • Query: parameterized SELECT with pagination, DML, stored procedures, scalar/table functions, explicit transactions with idle auto-rollback, bulk insert

    • Metadata: databases, schemas, tables, views, procedures, functions, triggers, columns, indexes, foreign keys, constraints, sizes, schema search, object definitions

    • Admin (read-only, opt-in): active/blocking sessions, running queries, deadlocks, backup history, agent jobs, server info, index fragmentation, missing indexes, database health

    • AI helpers (deterministic): schema context for NL→SQL, validate/optimize/ fix SQL, execution plans, cost estimates, FK-path join generation

    • Export: CSV / Excel / JSON / Parquet (path-jailed, formula-injection safe)

    • Import: CSV with preview + type inference, bulk file load

    • Connections: multiple named connections, health checks, database switching

  • 7 resources (mssql://...) and 8 prompts (query writing, tuning, schema walkthroughs, data-quality audits...)

  • Connectivity: SQL auth, Windows auth, Azure AD (password / service principal / managed identity), named instances, custom ports, TLS, connection pooling

  • Cross-platform: Windows (ODBC Driver 18), Ubuntu/Debian/RHEL/Rocky/Alma, macOS (Homebrew), Docker (stdio or streamable-HTTP)

Related MCP server: SQL Server MCP

Quick start

# Linux / macOS (installs the ODBC driver + the server)
./scripts/install.sh

# Windows (PowerShell, installs ODBC Driver 18 + the server)
./scripts/install.ps1

# or, with the driver already installed:
pipx install "mssql-mcp-server[dataio]"

If SQL Server is already installed

You do not need to start the bundled Docker database. The computer running the MCP server still needs:

  • Python 3.12 or newer

  • Microsoft ODBC Driver 18 for SQL Server

  • Network access and valid credentials for the existing SQL Server

Verify the ODBC driver on Linux or macOS:

odbcinst -q -d

The output should include [ODBC Driver 18 for SQL Server]. On Windows, check from PowerShell with:

Get-OdbcDriver | Where-Object Name -eq "ODBC Driver 18 for SQL Server"

Install only the MCP server:

pipx install "mssql-mcp-server[dataio]"

Create a .env file in the directory where the MCP server will run and point it at the existing database:

MSSQL_SERVER=localhost
MSSQL_PORT=1433
MSSQL_DATABASE=your_database
MSSQL_AUTH=sql
MSSQL_USERNAME=your_username
MSSQL_PASSWORD=your_password
MSSQL_ENCRYPT=true
READ_ONLY=true

Then start the server:

mssql-mcp

Replace localhost with the SQL Server hostname or IP address when it is remote. For a local development server with a self-signed certificate, set MSSQL_TRUST_CERTIFICATE=true; do not use that setting for production. The default transport is stdio, so the command normally waits for an MCP client to communicate with it. See Configuration for Windows and Azure AD authentication, named instances, and additional connections.

Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "mssql": {
      "command": "mssql-mcp",
      "env": {
        "MSSQL_SERVER": "localhost",
        "MSSQL_DATABASE": "SampleShop",
        "MSSQL_USERNAME": "app_reader",
        "MSSQL_PASSWORD": "***",
        "READ_ONLY": "true"
      }
    }
  }
}

Claude Code users can install it as a plugin instead:

/plugin marketplace add deepesh112/mcp_tool_sql
/plugin install mssql-mcp@deepesh112-mssql

(uses uvx; connection comes from your MSSQL_* environment variables — see docs/client-configs.md).

Try the bundled dev stack (SQL Server 2022 + sample database + the server over HTTP):

docker compose -f docker/docker-compose.yml up --build

Security model

Mode (SECURITY_MODE)

Allows

read_only (default)

SELECT, metadata, resources, allowlisted procs

standard

+ parameterized DML, procedures, transactions, imports

elevated

+ DDL (CREATE/ALTER/DROP of schema objects)

Dangerous operations (DROP DATABASE, xp_cmdshell, SHUTDOWN, KILL, TRUNCATE, login changes, OPENROWSET, BACKUP/RESTORE, GRANT/DENY/REVOKE, dynamic EXEC(...)) are blocked in every mode unless you set ALLOW_DANGEROUS_OPERATIONS=true and list the category in ALLOWED_DANGEROUS_OPS. Every statement is parsed (sqlglot AST) and scanned by a normalizing regex layer; unparseable statements are rejected (fail closed). Tools your policy forbids are never registered, so clients can't even see them. Details: docs/security.md.

Documentation

Development

uv venv && uv pip install -e ".[dev]"
pytest                          # unit + security (no DB needed)
pytest -m integration           # needs a live SQL Server (see docker/)
ruff check src tests && black --check src tests && mypy

License

MIT — see LICENSE.

A
license - permissive license
-
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

Related MCP Servers

  • F
    license
    -
    quality
    C
    maintenance
    A Model Context Protocol server that allows Large Language Models like Claude to execute SQL queries, explore database schemas, and maintain persistent connections to SQL Server databases.
  • A
    license
    B
    quality
    C
    maintenance
    A Model Context Protocol server that enables AI assistants (Cursor, Windsurf, Claude Code) to interact with Microsoft SQL Server databases by providing connectivity through environment-configurable connections.
    8
    398
    8
    MIT
  • A
    license
    -
    quality
    D
    maintenance
    A Model Context Protocol (MCP) server that enables AI agents to interact with Microsoft SQL Server databases through secure, intelligent database operations. This server provides comprehensive CRUD capabilities, schema introspection, stored procedure execution, transaction management, and bulk opera
    316
    37
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    A Model Context Protocol server that enables LLMs like Claude to interact with Microsoft SQL Server databases through natural language, supporting queries, data manipulation, and table management.
    8
    3,043
    MIT

View all related MCP servers

Related MCP Connectors

  • A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…

  • MCP (Model Context Protocol) server for Appwrite

  • MCP server for AI dialogue using various LLM models via AceDataCloud

View all MCP Connectors

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/deepesh112/mcp_tool_sql'

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