Skip to content
Back to search

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.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/richardhan--mssql-mcp-server/badge.svg)](/listings/richardhan--mssql-mcp-server)

HTML

<a href="/listings/richardhan--mssql-mcp-server"><img src="/api/listings/richardhan--mssql-mcp-server/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Install with Claude Desktop

Add to your `claude_desktop_config.json`:

{
  "mcpServers": {
    "mssql": {
      "command": "uvx",
      "args": ["microsoft_sql_server_mcp"],
      "env": {
        "MSSQL_SERVER": "localhost",
        "MSSQL_DATABASE": "your_database",
        "MSSQL_USER": "your_username",
        "MSSQL_PASSWORD": "your_password"
      }
    }
  }
}

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 140 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. # Microsoft SQL Server MCP Server
  2. [![PyPI](https://img.shields.io/pypi/v/microsoft_sql_server_mcp)](https://pypi.org/project/microsoft_sql_server_mcp/)
  3. [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
  4. <a href="https://glama.ai/mcp/servers/29cpe19k30">
  5. <img width="380" height="200" src="https://glama.ai/mcp/servers/29cpe19k30/badge" alt="Microsoft SQL Server MCP server" />
  6. </a>
  7. A Model Context Protocol (MCP) server for secure SQL Server database access through Claude Desktop.
  8. ## Features
  9. - 🔍 List database tables
  10. - 📊 Execute SQL queries (read-only by default; optional write mode)
  11. - 🔐 Multiple authentication methods (SQL, Windows, Azure AD)
  12. - 🏢 LocalDB and Azure SQL support
  13. - 🔌 Custom port configuration
  14. ## Quick Start
  15. ### Install with Claude Desktop
  16. Add to your `claude_desktop_config.json`:
  17. ```json
  18. {
  19. "mcpServers": {
  20. "mssql": {
  21. "command": "uvx",
  22. "args": ["--from", "microsoft-sql-server-mcp", "mssql_mcp_server"],
  23. "env": {
  24. "MSSQL_SERVER": "localhost",
  25. "MSSQL_DATABASE": "your_database",
  26. "MSSQL_USER": "your_username",
  27. "MSSQL_PASSWORD": "your_password"
  28. }
  29. }
  30. }
  31. }
  32. ```
  33. ## Configuration
  34. ### Basic SQL Authentication
  35. ```bash
  36. MSSQL_SERVER=localhost # Required
  37. MSSQL_DATABASE=your_database # Required
  38. MSSQL_USER=your_username # Required for SQL auth
  39. MSSQL_PASSWORD=your_password # Required for SQL auth
  40. ```
  41. ### Windows Authentication
  42. ```bash
  43. MSSQL_SERVER=localhost
  44. MSSQL_DATABASE=your_database
  45. MSSQL_WINDOWS_AUTH=true # Use Windows credentials
  46. ```
  47. ### Azure SQL Database
  48. ```bash
  49. MSSQL_SERVER=your-server.database.windows.net
  50. MSSQL_DATABASE=your_database
  51. MSSQL_USER=your_username
  52. MSSQL_PASSWORD=your_password
  53. # Encryption is automatic for Azure
  54. ```
  55. ### Optional Settings
  56. ```bash
  57. MSSQL_PORT=1433 # Custom port (default: 1433)
  58. MSSQL_ENCRYPT=true # Force encryption (uses pymssql `encryption=require`)
  59. MSSQL_TRUST_SERVER_CERTIFICATE=true # Trust SQL Server TLS cert (default: true for non-Azure encrypt, false for Azure)
  60. MSSQL_QUERY_TIMEOUT=300 # Query timeout in seconds (default: 300). Queries exceeding this limit are automatically terminated.
  61. MSSQL_ALLOW_WRITES=1 # Allow INSERT/UPDATE/DELETE; tool name becomes execute_sql (default: read-only `query` tool)
  62. MSSQL_COMMAND=query # Optional override for the MCP tool name
  63. ```
  64. ### Read-only vs write mode
  65. 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.
  66. 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.
  67. ## Alternative Installation Methods
  68. ### Using pip
  69. ```bash
  70. pip install microsoft_sql_server_mcp
  71. ```
  72. Then in `claude_desktop_config.json`:
  73. ```json
  74. {
  75. "mcpServers": {
  76. "mssql": {
  77. "command": "python",
  78. "args": ["-m", "mssql_mcp_server"],
  79. "env": { ... }
  80. }
  81. }
  82. }
  83. ```
  84. ### Development
  85. ```bash
  86. git clone https://github.com/RichardHan/mssql_mcp_server.git
  87. cd mssql_mcp_server
  88. pip install -e .
  89. ```
  90. ## Dependency notes
  91. The `mcp` SDK is pinned to `>=1.0.0,<2.0.0` in both `pyproject.toml` and `requirements.txt`.
  92. `mcp` 2.0.0 removed the legacy `Server` decorator API (`@app.list_resources()`,
  93. `@app.list_tools()`, ...) that `src/mssql_mcp_server/server.py` is built on, so an
  94. unconstrained install crashes at import time with:
  95. ```
  96. AttributeError: 'Server' object has no attribute 'list_resources'
  97. ```
  98. This matters most for `uvx --from git+...` launches, which resolve dependencies fresh on
  99. every cold start and ignore `uv.lock`. Do not drop the upper bound until the server is
  100. migrated to the 2.x API.
  101. ## Security
  102. - Create a dedicated SQL user with minimal permissions (e.g. `db_datareader` for read-only deployments)
  103. - Never use admin/sa accounts for the MCP connection
  104. - Use Windows Authentication when possible
  105. - Enable encryption for sensitive data
  106. - Treat `MSSQL_ALLOW_WRITES` as an explicit opt-in; keep it off unless the user deliberately wants writes
  107. - Read-only mode parses T-SQL and fail-closes on unsupported/stacked statements — still pair it with least-privilege DB grants
  108. ## License
  109. MIT

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.