Provides a Model Context Protocol server to query and manage SQL Server databases from MCP-enabled clients.
Configuration
View docs{
"mcpServers": {
"bymcs-mssql-mcp": {
"command": "npx",
"args": [
"-y",
"mssql-mcp@latest"
],
"env": {
"DB_PORT": "1433",
"DB_USER": "your-username",
"DB_SERVER": "your-server.com",
"DB_ENCRYPT": "true",
"DB_DATABASE": "your-database",
"DB_PASSWORD": "your-password",
"DB_REQUEST_TIMEOUT": "30000",
"DB_CONNECTION_TIMEOUT": "30000",
"DB_TRUST_SERVER_CERTIFICATE": "true"
}
}
}
}This MCP server lets you interact with Microsoft SQL Server using Model Context Protocol-enabled IDEs. You connect, run queries, inspect schemas, and manage data through a consistent, scriptable interface that integrates with editors like Claude Desktop, Cursor, Windsurf, and VS Code.
You connect to your SQL Server instance and start issuing operations through an MCP-enabled client. Use it to connect, execute parameterized queries, inspect database schemas, retrieve data with pagination, and run stored procedures. The server manages a pool of connections for efficient resource use and returns structured results that your editor can display or process.
# Prerequisites
- Node.js and npm installed on your machine
# Install the MCP server globally
npm install -g mssql-mcpConfigure your MCP client to point at this server. The server runs via a local command that invokes the MCP package with the latest release, and you supply your database credentials through environment variables. The following environment variables are supported.
{
"mcpServers": {
"mssql": {
"command": "npx",
"args": ["-y", "mssql-mcp@latest"],
"env": {
"DB_SERVER": "your-server.com",
"DB_DATABASE": "your-database",
"DB_USER": "your-username",
"DB_PASSWORD": "your-password",
"DB_ENCRYPT": "true",
"DB_TRUST_SERVER_CERTIFICATE": "true"
}
}
}
}The server accepts these environment variables. Required ones are indicated where applicable.
DB_SERVER
DB_DATABASE
DB_USER
DB_PASSWORD
DB_PORT
DB_ENCRYPT
DB_TRUST_SERVER_CERTIFICATE
DB_CONNECTION_TIMEOUT
DB_REQUEST_TIMEOUTFor Azure SQL Database, encryption is enabled by default and you should set the certificate trust to false.
{ "DB_ENCRYPT": "true", "DB_TRUST_SERVER_CERTIFICATE": "false" }Use parameterized queries to prevent SQL injection. Store credentials securely (e.g., in your editor's secret store or a managed vault) and limit the permissions of the database user to the minimum required for your tasks.
Connect to database using environment variables
Close current database connection
Check connection state with pool info
Execute any SQL query with parameters
List database objects such as tables, views, and procedures
Get detailed structure of a specific table
Retrieve data with pagination
Execute stored procedures
List all databases