mssql
A Model Context Protocol server for Microsoft SQL Server
claude mcp add --transport stdio combiz-mssql-mcp-server python -m mssql_mcp_server.server \ --env MSSQL_PORT="1433" \ --env MSSQL_USER="your-username" \ --env MSSQL_DRIVER="ODBC Driver 17 for SQL Server" \ --env MSSQL_SERVER="your-server-hostname" \ --env MSSQL_ENCRYPT="yes" \ --env MSSQL_DATABASE="your-database" \ --env MSSQL_PASSWORD="your-password" \ --env MSSQL_CONNECTION_TIMEOUT="30" \ --env MSSQL_TRUSTED_CONNECTION="no" \ --env MSSQL_MULTI_SUBNET_FAILOVER="no" \ --env MSSQL_TRUST_SERVER_CERTIFICATE="yes"
How to use
This MSSQL MCP server lets AI assistants like Claude interact with your Microsoft SQL Server databases through a unified Model Context Protocol interface. It exposes capabilities to execute arbitrary SQL queries, browse and inspect the database schema, and retrieve sample data from tables. The server supports multi-line queries, SQL comments, and GO batch separators, and can authenticate using either SQL authentication or Windows trusted connections. To use it, run the server (via Python) and configure your MCP client to point to the mssql server entry, providing the necessary environment variables for database connectivity. The available tool, execute_sql, accepts a query string and returns results or error details, while the server exposes resources for schema and data access so clients can discover table structures and sample data.
How to install
Prerequisites:
- Python 3.8+
- An ODBC driver for SQL Server installed on the host (e.g., ODBC Driver 17 or 18)
- Network access to the target SQL Server
From PyPI:
pip install mssql-mcp-server-enhanced
From Source:
git clone https://github.com/combiz/mssql-mcp-server.git
cd mssql-mcp-server
pip install -e .
Configure environment variables for your database connection (examples shown in the README):
export MSSQL_SERVER=your-server.database.windows.net
export MSSQL_DATABASE=your-database
export MSSQL_USER=your-username
export MSSQL_PASSWORD=your-password
export MSSQL_ENCRYPT=yes
export MSSQL_TRUST_SERVER_CERTIFICATE=no
Run the server:
python -m mssql_mcp_server.server
Alternatively, configure via MCP config as shown in the mcp_config section and integrate with Claude Desktop, Claude Code, Cursor, or other MCP-compatible clients.
Additional notes
Tips and considerations:
- Ensure the MSSQL_DRIVER matches the installed ODBC driver on your host. If you encounter driver-not-found errors, update MSSQL_DRIVER to the exact driver name installed.
- For Windows authentication, set MSSQL_TRUSTED_CONNECTION=yes and omit MSSQL_USER and MSSQL_PASSWORD.
- Enable encryption in production by setting MSSQL_ENCRYPT=yes and consider MSSQL_TRUST_SERVER_CERTIFICATE=no to enforce certificate validation.
- The server executes queries as-is; enforce proper permissions at the database level and apply input controls on the client side to avoid misuse.
- If you use Claude Desktop and host the MCP server in a virtual environment, you can point the command to your virtual environment's Python executable as shown in the README example for a virtualenv.
- For multi-subnet environments, consider enabling MSSQL_MULTI_SUBNET_FAILOVER and adjust MSSQL_CONNECTION_TIMEOUT as needed.
Related MCP Servers
mcp-pinecone
Model Context Protocol server to allow for reading and writing from Pinecone. Rudimentary RAG
lc2mcp
Convert LangChain tools to FastMCP tools
freecad
FreeCAD MCP - Open-source Model Context Protocol server for FreeCAD automation
taskflow
A task management Model Context Protocol (MCP) server that helps AI assistants break down user requests into manageable tasks with subtasks, dependencies, and notes. Enforces a structured workflow with user approval steps.
cursor-feedback-extension
Save your Cursor monthly quota! Unlimited AI interactions in one conversation via MCP feedback loop.
Convert-Markdown-PDF
Markdown To PDF Conversion MCP