mcp-sqlserver
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., "@mcp-sqlserver show the schema for the Users table"
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.
mcp-sqlserver
MCP server for Microsoft SQL Server with explicit port support. Works from Claude Code, Cursor, and CLI; default port is 9123 (override with MSSQL_PORT).
Why this exists
Generic mssql-mcp-server packages can fail when run from Claude Code with a custom port: connection works from the CLI but not when the client spawns the process. This server reads config from environment variables and passes port as a number into the driver so behavior is consistent everywhere.
Related MCP server: mcp-sqlserver-readonly
Requirements
Node.js 18+
SQL Server reachable via TCP (default port 9123, or set
MSSQL_PORT)For Windows Integrated Auth (current user, no password):
npm install msnodesqlv8(Windows native driver)
Setup
cd mcp-sqlserver
npm install
npm run buildConfiguration
Option A: Connections map file (per environment / client)
Use a JSON file so each MCP server block only sets environment and client (and optionally the file path). One server (e.g. 192.168.100.65) can host multiple databases; each is a client with its own database name and credentials. You run one MCP server block per database (same server, different MSSQL_CLIENT).
File structure (e.g. connections.json): environment -> { server, port, encrypt?, trustServerCertificate?, windowsIntegrated?, clients: { clientName -> { database, user?, password?, domain?, windowsIntegrated? } } }. Server settings are shared; each client has database and either SQL credentials (user/password), NTLM (domain + user/password), or Windows Integrated (windowsIntegrated: true, no user/password).
Variable | Required | Description |
| When using file | Environment key (e.g. |
| When using file | Client key under |
| No | Path to the JSON file (default |
If both MSSQL_ENVIRONMENT and MSSQL_CLIENT are set, the server loads the file, uses the environment’s server/port/encrypt/trustServerCertificate, and the client’s database and auth. Any of MSSQL_SERVER, MSSQL_PORT, MSSQL_DATABASE, MSSQL_USER, MSSQL_PASSWORD, MSSQL_DOMAIN, MSSQL_ENCRYPT, MSSQL_TRUST_CERT, MSSQL_WINDOWS_INTEGRATED in env override the file values.
Windows authentication
NTLM (domain user)
In the client entry setdomainwithuserandpassword(e.g.domain: "MYDOMAIN"forMYDOMAIN\myuser). Uses the default driver (tedious). Env override:MSSQL_DOMAIN.Windows Integrated (current OS user)
In the client entry setwindowsIntegrated: true; omituserandpassword. Uses the msnodesqlv8 driver (Windows native). Install it withnpm install msnodesqlv8. You can setwindowsIntegrated: trueat the environment level to apply to all clients, or per client. Env override:MSSQL_WINDOWS_INTEGRATED=true.
Example connections.example.json (copy to connections.json and fill in real values):
{
"staging": {
"server": "192.168.100.65",
"port": 9123,
"encrypt": true,
"trustServerCertificate": true,
"clients": {
"QASandbox8": {
"database": "QASandbox8",
"user": "usrQASandbox8",
"password": "your-password"
},
"OtherDatabase": {
"database": "OtherDatabase",
"user": "usrOtherDb",
"password": "your-password"
},
"NTLM_Database": {
"database": "MyDb",
"domain": "MYDOMAIN",
"user": "myuser",
"password": "my-password"
},
"WindowsIntegratedDb": {
"database": "TrustedDb",
"windowsIntegrated": true
}
}
}
}Example MCP blocks: one per database on the same server (same staging server, different MSSQL_CLIENT):
"mssql-staging-qa": {
"command": "node",
"args": ["C:\\Code\\AI-Examples\\mcp\\mcp-sqlserver\\dist\\index.js"],
"env": {
"MSSQL_ENVIRONMENT": "staging",
"MSSQL_CLIENT": "QASandbox8",
"MSSQL_CONFIG_PATH": "C:\\Code\\AI-Examples\\mcp\\mcp-sqlserver\\connections.json"
}
},
"mssql-staging-other": {
"command": "node",
"args": ["C:\\Code\\AI-Examples\\mcp\\mcp-sqlserver\\dist\\index.js"],
"env": {
"MSSQL_ENVIRONMENT": "staging",
"MSSQL_CLIENT": "OtherDatabase",
"MSSQL_CONFIG_PATH": "C:\\Code\\AI-Examples\\mcp\\mcp-sqlserver\\connections.json"
}
}Option B: Environment variables only
Variable | Required | Description |
| Yes | Server host (e.g. |
| No | Port (default |
| No | Database name (default |
| Yes* | Login user (omit for Windows Integrated) |
| Yes* | Login password (omit for Windows Integrated) |
| No | NTLM domain (e.g. |
| No | Set to |
| No |
|
| No | Set to |
* Omit when using Windows Integrated auth (MSSQL_WINDOWS_INTEGRATED=true).
Claude Code / Cursor
Add your MCP server block under mcpServers in Claude Code or Cursor (e.g. Settings → MCP). Use one of these:
With a connections file (Option A) – Put
connections.jsonnext to the project (or setMSSQL_CONFIG_PATH). In the MCP config you only set environment, client, and path:
"mssql-staging-qa": {
"command": "node",
"args": ["C:\\Code\\AI-Examples\\mcp\\mcp-sqlserver\\dist\\index.js"],
"env": {
"MSSQL_ENVIRONMENT": "staging",
"MSSQL_CLIENT": "QASandbox8",
"MSSQL_CONFIG_PATH": "C:\\Code\\AI-Examples\\mcp\\mcp-sqlserver\\connections.json"
}
}Without a file (Option B) – Pass everything via env (server, port, database, user, password, etc.):
"mssql": {
"command": "node",
"args": ["C:\\Code\\AI-Examples\\mcp\\mcp-sqlserver\\dist\\index.js"],
"env": {
"MSSQL_SERVER": "192.168.100.65",
"MSSQL_PORT": "9123",
"MSSQL_DATABASE": "QASandbox8",
"MSSQL_USER": "usrQASandbox8",
"MSSQL_PASSWORD": "your-password",
"MSSQL_ENCRYPT": "true",
"MSSQL_TRUST_CERT": "true"
}
}Replace args[0] with the absolute path to dist/index.js on your machine.
Tools
query – Run a read-only SQL query (e.g.
SELECT ...). Returns results as a text table.list_tables – List tables in the current database. Optional
schemaargument (e.g.dbo).describe_table – Column names and types for a table. Arguments:
table, optionalschema(defaultdbo).
Run locally (stdio)
# Set env vars, then:
npm run start
# or without building:
npm run devThe server speaks MCP over stdio; a client (Claude Code, Cursor, or another MCP client) must start it and connect to stdin/stdout.
License
MIT
Available Tools
3 toolsdescribe_tableB
Return column names and types for a table.
Inputs: table (required), schema.
list_tablesA
List tables in the current database, optionally filtered by schema.
Inputs: schema.
queryA
Execute a read-only SQL query (SELECT) against the configured SQL Server database.
Inputs: sql (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: describe_table provides metadata for a specific table, list_tables enumerates available tables, and query executes arbitrary SELECT queries. There is no overlap in functionality, and an agent can easily differentiate between them based on their descriptions.
All tool names follow a consistent verb_noun pattern (describe_table, list_tables, query). While 'query' is a single word, it functions as a verb in this context and maintains readability without deviating from the clear, descriptive naming style used throughout.
With only 3 tools, the set feels thin for a SQL Server interface, which typically involves more operations like data manipulation (INSERT, UPDATE, DELETE) or schema modifications. However, the tools are well-scoped for read-only database interactions, making it borderline but not severely inadequate.
The tool surface is significantly incomplete for a SQL Server domain, as it only supports read operations (SELECT, metadata queries) without any write capabilities (INSERT, UPDATE, DELETE) or schema management tools. This creates notable gaps that could lead to agent failures when full database interactions are required.
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.
Cloud-hosted MCP server for secure AI access to enterprise data sources via CData Connect AI.
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables interaction with Microsoft SQL Server instances using Windows or SQL Server authentication via native ODBC drivers. It allows users to execute SQL queries, list tables, and inspect schemas across multiple configured database environments through natural language.1,129 npmMIT
- AlicenseNot gradedqualityDmaintenanceRead-only SQL Server MCP server enabling safe database queries, table listing, and schema inspection with built-in security protections.MIT
- AlicenseNot gradedqualityDmaintenanceA read-only MCP server for exploring on-premises, multi-instance Microsoft SQL Server estates from AI clients, with read-only enforcement and Windows authentication support.Apache 2.0
- AlicenseAqualityDmaintenanceA read-only MCP server for browsing and querying SQL Server databases, providing tools to list schemas, tables, describe columns, and execute safe SELECT queries with validated parameters.15ISC