Mssql

Databases

A Model Context Protocol (MCP) server for Microsoft SQL Server that enables secure database interactions through a controlled interface. Allows AI assistants to safely list tables, read data, and execute SQL queries while maintaining security and structure.

Your AI app calls the Mssql MCP server, which does the databases work and sends the result back to the chat.

About Mssql

Mssql is a community MCP server from RichardHan, filed in our directory under databases. A Model Context Protocol (MCP) server for Microsoft SQL Server that enables secure database interactions through a controlled interface. Allows AI assistants to safely list tables, read data, and execute SQL queries while maintaining security and structure.

At a glance

Publisher
RichardHan (community)
Runs
See the README for setup
Written in
Python
License
MIT
GitHub stars
406

How to set up Mssql

  1. Follow the install steps in the Mssql README; it is written in Python, so have that toolchain ready.
  2. Check the Mssql README for keys or settings; the registry lists none that Mssql requires.
  3. Add Mssql to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the Mssql tools to confirm the connection.
  5. Run one read-only task with Mssql first, and keep your app asking before each tool call until the results look right.

Mssql compared with similar servers

  • Mac Messages by carterlasalle has fewer GitHub stars than Mssql (345 against 406); both are community servers, and both run locally.
  • Bagel by Extelligence-ai has more GitHub stars than Mssql (408 against 406); both are community servers, and both run locally.
  • Affine by DAWNCR0W has fewer GitHub stars than Mssql (339 against 406); both are community servers, and both run locally.

Before you connect Mssql

  • Give Mssql its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each Mssql tool call until you trust what it does with them.
  • Treat text that Mssql fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for Mssql on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for Mssql

How marketing and sales teams put Mssql to work, by company size. Pick the size closest to yours and start Mssql on one use case.

Small business

  • A small business with its own app can ask Mssql plain questions about customers and orders, without writing SQL.
  • Owners can use Mssql to pull a list of customers who haven't bought in 90 days and plan a win-back email.
  • Mssql runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Marketing analysts can connect Mssql to answer campaign questions from the warehouse directly, instead of waiting on the data team's queue.
  • Lifecycle teams can use Mssql to build audience lists from product data and check counts before a send.
  • Start Mssql on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprises should point Mssql at a read replica with a read-only role, so agents query freely without risk to production data.
  • Data teams can expose curated views through Mssql, so marketing gets self-serve answers without access to raw customer tables.
  • Mssql is a community server, so have security review the code and pin a version before Mssql touches company data.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

Mssql README

From RichardHan/mssql_mcp_server on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

Microsoft SQL Server MCP Server

A Model Context Protocol (MCP) server for secure SQL Server database access through Claude Desktop.

Features

  • 🔍 List database tables
  • 📊 Execute SQL queries (read-only by default; optional write mode)
  • 🔐 Multiple authentication methods (SQL, Windows, Azure AD)
  • 🏢 LocalDB and Azure SQL support
  • 🔌 Custom port configuration

Quick Start

Install with Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "mssql": {
      "command": "uvx",
      "args": ["--from", "microsoft-sql-server-mcp", "mssql_mcp_server"],
      "env": {
        "MSSQL_SERVER": "localhost",
        "MSSQL_DATABASE": "your_database",
        "MSSQL_USER": "your_username",
        "MSSQL_PASSWORD": "your_password"
      }
    }
  }
}

Configuration

Basic SQL Authentication
MSSQL_SERVER=localhost          # Required
MSSQL_DATABASE=your_database    # Required
MSSQL_USER=your_username        # Required for SQL auth
MSSQL_PASSWORD=your_password    # Required for SQL auth
Windows Authentication
MSSQL_SERVER=localhost
MSSQL_DATABASE=your_database
MSSQL_WINDOWS_AUTH=true         # Use Windows credentials
Azure SQL Database
MSSQL_SERVER=your-server.database.windows.net
MSSQL_DATABASE=your_database
MSSQL_USER=your_username
MSSQL_PASSWORD=your_password
# Encryption is automatic for Azure
Optional Settings
MSSQL_PORT=1433                 # Custom port (default: 1433)
MSSQL_ENCRYPT=true              # Force encryption (uses pymssql `encryption=require`)
MSSQL_TRUST_SERVER_CERTIFICATE=true  # Trust SQL Server TLS cert (default: true for non-Azure encrypt, false for Azure)
MSSQL_QUERY_TIMEOUT=300         # Query timeout in seconds (default: 300). Queries exceeding this limit are automatically terminated.
MSSQL_ALLOW_WRITES=1            # Allow INSERT/UPDATE/DELETE; tool name becomes execute_sql (default: read-only `query` tool)
MSSQL_COMMAND=query             # Optional override for the MCP tool name
Read-only vs write mode

By default the server exposes a query tool that only accepts a single read-only SELECT / WITH / set-operation statement (parsed as T-SQL) and sets readOnlyHint (so Cursor Ask mode can use it). Stacked batches (SELECT …; INSERT …), SELECT INTO, EXEC, and other non-SELECT statements are rejected before they reach the database driver.

Set MSSQL_ALLOW_WRITES=1 to expose execute_sql and allow writes. Prefer a least-privilege read-only SQL login for the default mode, the parser is fail-closed defense in depth, not a substitute for database permissions, and does not claim to prove arbitrary T-SQL is free of side effects.

Alternative Installation Methods

Using pip
pip install microsoft_sql_server_mcp

Then in claude_desktop_config.json:

{
  "mcpServers": {
    "mssql": {
      "command": "python",
      "args": ["-m", "mssql_mcp_server"],
      "env": { ... }
    }
  }
}
Development
git clone https://github.com/RichardHan/mssql_mcp_server.git
cd mssql_mcp_server
pip install -e .

Dependency notes

The mcp SDK is pinned to >=1.0.0,<2.0.0 in both pyproject.toml and requirements.txt.

mcp 2.0.0 removed the legacy Server decorator API (@app.list_resources(), @app.list_tools(), ...) that src/mssql_mcp_server/server.py is built on, so an unconstrained install crashes at import time with:

AttributeError: 'Server' object has no attribute 'list_resources'

This matters most for uvx --from git+... launches, which resolve dependencies fresh on every cold start and ignore uv.lock. Do not drop the upper bound until the server is migrated to the 2.x API.

Security

  • Create a dedicated SQL user with minimal permissions (e.g. db_datareader for read-only deployments)
  • Never use admin/sa accounts for the MCP connection
  • Use Windows Authentication when possible
  • Enable encryption for sensitive data
  • Treat MSSQL_ALLOW_WRITES as an explicit opt-in; keep it off unless the user deliberately wants writes
  • Read-only mode parses T-SQL and fail-closes on unsupported/stacked statements, still pair it with least-privilege DB grants

License

MIT

Questions about Mssql

What is the Mssql MCP server?

A Model Context Protocol (MCP) server for Microsoft SQL Server that enables secure database interactions through a controlled interface. Allows AI assistants to safely list tables, read data, and execute SQL queries while maintaining security and structure. Mssql is maintained by RichardHan on GitHub at RichardHan/mssql_mcp_server, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the Mssql MCP server?

Mssql doesn't publish a one-line install in the MCP registry, so follow the setup steps in its README on GitHub (RichardHan/mssql_mcp_server). Like most servers, Mssql ends with a command or URL you paste into your AI app's MCP config.

Does Mssql need an API key?

The registry lists no required keys for Mssql. Check the Mssql README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is Mssql an official MCP server?

No. Mssql is a community server maintained by RichardHan. Community servers can be excellent; read the code and the open issues before you give Mssql access to company data.

What license is Mssql under?

Mssql is released under the MIT license, according to its GitHub repository. The license covers the code of Mssql; the service it connects to has its own terms.