Microsoft SQL Server MCP Server
This server exposes an execute_sql tool for running SQL against a configured Microsoft SQL Server database.
Execute SQL queries against the connected database.
Run read or write operations; the exposed
execute_sqltool indicates write mode is enabled, subject to database permissions.Query tables/data and, if permitted, inspect schema metadata such as table lists via SQL.
Use configured authentication methods: SQL auth, Windows auth, or Azure SQL/Azure AD-related setups.
Connect to local, LocalDB, custom-port, or Azure SQL Server instances.
Apply configured query timeouts and encryption/TLS trust settings.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Microsoft SQL Server MCP Server show me the top 10 customers by total purchases"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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
Related MCP server: MCP SQL Server
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 authWindows Authentication
MSSQL_SERVER=localhost
MSSQL_DATABASE=your_database
MSSQL_WINDOWS_AUTH=true # Use Windows credentialsAzure 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 AzureOptional 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 nameRead-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_mcpThen 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_datareaderfor 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_WRITESas an explicit opt-in; keep it off unless the user deliberately wants writesRead-only mode parses T-SQL and fail-closes on unsupported/stacked statements — still pair it with least-privilege DB grants
License
MIT
Available Tools
1 toolexecute_sqlC
Execute an SQL query on the SQL Server
Inputs: query (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 1 tool
Only one tool exists, so there is no risk of confusion or overlap.
With a single tool, naming is trivially consistent to itself.
A single SQL execution tool is insufficient for the typical scope of SQL Server operations, which usually requires multiple tools for schema exploration, query execution, and data manipulation.
The tool set is severely incomplete; it lacks fundamental operations such as listing tables, describing schemas, or managing databases, limiting useful agent workflows.
Maintenance
Related MCP Connectors
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Draxlr's remote MCP server connects AI assistants to your SQL databases and dashboards. Explore schemas, run read-only queries, manage saved queries and dashboards, and export results, all with row-level security so each user sees only their own data.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
The BigQuery remote MCP server is a fully managed service that uses the Model Context Protocol to connect AI applications and LLMs to BigQuery data sources. It provides secure, standardized tools for AI agents to list datasets and tables, retrieve schemas, generate and execute SQL queries through natural language, and analyze data—enabling direct access to enterprise analytics data without requiring manual SQL coding.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceA Model Context Protocol server that enables secure and structured interaction with Microsoft SQL Server databases, allowing AI assistants to list tables, read data, and execute SQL queries with controlled access.60MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that provides AI assistants with comprehensive access to SQL databases, enabling schema inspection, query execution, and database operations with enterprise-grade security.55 npm9MIT
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that provides comprehensive access to Microsoft SQL Server databases, enabling Language Models to inspect schemas, execute queries, manage database objects, and perform advanced database operations.8-
- AlicenseNot gradedqualityDmaintenanceA 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 opera1,560 npm47MIT