Provides an MCP endpoint to query MSSQL databases with secure connections and built-in safeguards.
Configuration
View docs{
"mcpServers": {
"mssql": {
"command": "mssql-mcp-server",
"args": [],
"env": {
"MSSQL_CONNECTION_STRING": "Server=localhost;Database=master;User Id=sa;Password=yourpassword;",
"MSSQL_HOST": "localhost",
"MSSQL_PORT": "1433",
"MSSQL_DATABASE": "master",
"MSSQL_USER": "sa",
"MSSQL_PASSWORD": "yourpassword",
"MSSQL_ENCRYPT": "false",
"MSSQL_TRUST_SERVER_CERTIFICATE": "true"
}
}
}
}You can connect to Microsoft SQL Server databases through an MCP server that exposes a dedicated query tool and managed connections. This enables you to run SQL queries, control connections securely, and integrate SQL data access into your MCP workflow.
Use this MSSQL MCP Server with your MCP client to run SQL queries against a Microsoft SQL Server. You will configure a server entry in your MCP settings, then call the query tool to execute statements like selecting rows or modifying data. The server handles connection pooling, input validation, and safeguards against dangerous SQL operations.
Prerequisites: you need Node.js and npm installed on your machine. You may also use Docker if you prefer containerized execution.
Option A: Install via Smithery for automated client integration with Claude Desktop.
npx -y @smithery/cli install @c0h1b4/mssql-mcp-server --client claudeOption B: Manual installation of the MCP server package.
npm install mssql-mcp-serverAdd the server to your MCP settings configuration file. You provide either a full connection string or individual connection parameters. The server is started and then you can call the query tool to run SQL against your MSSQL database.
{
"mcpServers": {
"mssql": {
"command": "mssql-mcp-server",
"env": {
"MSSQL_CONNECTION_STRING": "Server=localhost;Database=master;User Id=sa;Password=yourpassword;",
// Or individual connection parameters:
"MSSQL_HOST": "localhost",
"MSSQL_PORT": "1433",
"MSSQL_DATABASE": "master",
"MSSQL_USER": "sa",
"MSSQL_PASSWORD": "yourpassword",
"MSSQL_ENCRYPT": "false",
"MSSQL_TRUST_SERVER_CERTIFICATE": "true"
}
}
}
}The server includes safeguards against dangerous SQL operations, validates input parameters and database names, sets reasonable limits on query length and timeout, and uses connection pooling to improve performance and security.
The MSSQL MCP Server exposes a tool named query to execute SQL statements on a MSSQL database.
Typical usage is to invoke the query tool with the appropriate connection details and a SQL statement, for example selecting data from a table.
Local development and testing follow a standard Node.js workflow: install dependencies, run in development mode, build, and then start the built server. If you prefer containerized operation, you can use Docker to build and run services that include SQL Server and the MCP server.
Execute a SQL query on a MSSQL database. Parameters include connection details or a full connection string, and the required query string. Optional options control encryption and certificate trust.