MS SQL Server MCP Server
This server provides MCP tools to connect to and interact with Microsoft SQL Server databases, supporting both read-only queries and data modifications, with strong emphasis on security and safe parameterization.
Connection Management: Connect using environment variables, disconnect, and check connection status including server/database info and connection pool metrics.
Execute Arbitrary SQL: Run any SQL statement (SELECT, INSERT, UPDATE, DELETE, DDL) with optional named parameters. Warnings note it can modify data.
List Schema Objects: List tables, views, stored procedures, or functions with optional schema filtering and pagination.
Describe Table Columns: Get column definitions such as name, data type, length, nullability, and defaults for a specified table.
Read Table Rows: Fetch rows from a table with column projection, parameterized WHERE clause, ORDER BY, and pagination. Read-only.
Execute Stored Procedures: Call a stored procedure with input parameters; may modify data.
List Databases: List all databases on the server with pagination and state/recovery information.
Response Formatting: Most tools support
response_format(jsonormarkdown).Security Features: Credentials are sourced only from environment variables, identifiers are validated, and user input uses parameterized queries to prevent SQL injection.
Pagination and Truncation: List/read operations support limit and offset, with metadata indicating total counts and whether more results exist.
Deprecated Aliases: Older tool names remain available for backward compatibility.
Transport Modes: Supports both
stdio(local IDE) andhttp(remote/hosted) transports.
Click on "Install 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., "@MS SQL Server MCP Servershow me the top 10 customers by total orders"
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.
MS SQL Server MCP Server v2.3.6
๐ Model Context Protocol (MCP) server for Microsoft SQL Server - compatible with Claude Desktop, Cursor, Windsurf and VS Code.
Standards Alignment
Protocol target: MCP draft/latest spec
Transport spec: Transports
Security: Security best practices
SDK:
@modelcontextprotocol/sdkpinned to1.28.0
Related MCP server: MSSQL MCP Server
๐ Quick Start
1. Install
npm install -g mssql-mcp2. Configure IDE
Claude Desktop (claude_desktop_config.json):
{
"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"
}
}
}
}Cursor/Windsurf/VS Code (.vscode/mcp.json):
{
"servers": {
"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"
}
}
}
}HTTP transport (remote/hosted scenarios):
{
"servers": {
"mssql": {
"type": "http",
"url": "http://127.0.0.1:3001",
"env": {}
}
}
}Replace with your actual database credentials. Credentials are read from the server environment only โ never passed as tool parameters.
๏ฟฝ๏ฟฝ๏ธ Tool Catalog
Primary tools (use these)
Tool | Read-only | Description |
| No | Connect using env variables. Idempotent. |
| No | Close connection. Idempotent. |
| โ | Connection state and pool metrics |
| โ ๏ธ No | Execute arbitrary SQL. May mutate data. |
| โ | List tables/views/procedures/functions with pagination |
| โ | Column definitions for a table |
| โ | Paginated rows with projection and safe WHERE |
| โ ๏ธ No | Execute a stored procedure |
| โ | List all databases on the instance |
All data tools accept a response_format parameter ("json" | "markdown", default "json"). Use "markdown" to get human-readable table output.
Deprecated aliases (still work for backward compatibility)
Old name | Use instead |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
๐ Transport Modes
Mode | Use when |
| Local IDE integration (Claude Desktop, Cursor, VS Code) |
| Remote/hosted deployment, testing with MCP Inspector |
# stdio (default)
node dist/src/index.js
# HTTP on 127.0.0.1:3001
MCP_TRANSPORT=http node dist/src/index.js
# Custom HTTP host/port
MCP_TRANSPORT=http MCP_HOST=0.0.0.0 MCP_PORT=8080 node dist/src/index.js๐ง Environment Variables
Database connection
Variable | Required | Default | Description |
| โ | โ | SQL Server hostname or IP |
| โ | โ | Database name |
| โ | โ | Login username |
| โ | โ | Login password |
| โ | 1433 | TCP port |
| โ | true | Enable TLS (required for Azure SQL) |
| โ | false | Trust self-signed certs |
| โ | 30000 | Connection timeout ms |
| โ | 30000 | Query timeout ms |
Transport
Variable | Default | Description |
|
|
|
|
| HTTP bind address |
|
| HTTP port |
๐ Security Model
No credential parameters: All connection settings come from environment variables only. Tool inputs cannot override connection config.
Identifier validation: Schema, table, and procedure names are validated against a safe identifier pattern before interpolation into SQL.
Parameterized queries: All user-supplied values (WHERE clause values, column values) must be passed as named parameters via
@paramNameโ never embedded in query strings.Origin validation: HTTP transport validates
Originheader and only allows localhost by default.SQL risk labeling:
run_sql_queryandexecute_stored_procedureare explicitly labeled as non-read-only and open-world.
โ ๏ธ SQL Risk Notes
run_sql_query accepts arbitrary SQL including DDL and DML. To minimize risk:
Use a least-privilege SQL login (SELECT-only where possible)
Never run the server with a
sysadminorsaaccountConsider network firewall rules to limit what the server can reach
๐ Pagination
All list tools return a pagination object:
{
"count": 20,
"limit": 20,
"offset": 0,
"has_more": true,
"next_offset": 20,
"total_count": 150
}Default page size: 20 rows. Maximum: 200 rows.
Results are also truncated if the serialized payload exceeds 100KB, with a truncation_message explaining how many rows were dropped.
๐๏ธ Architecture
src/
index.ts โ bootstrap (env, transport selection)
server.ts โ createServer() factory
constants.ts โ limits, defaults, protocol strings
config.ts โ env parsing
types.ts โ shared TypeScript interfaces
db/
connection.ts โ connection pool singleton
validators.ts โ SQL identifier validation
query-builders.ts โ safe parameterized query construction
tools/ โ one file per tool group
resources/ โ MCP resource handlers
transports/ โ stdio and HTTP transports
utils/
errors.ts โ error normalization helpers
format.ts โ JSON formatting, payload truncation
markdown.ts โ markdown table/list rendering helpers
pagination.ts โ pagination metadata helpers๐งช Inspector Smoke Test
npx @modelcontextprotocol/inspectorExpected:
stdio server connects
Tool list renders with all tools
mssql_connection_statusreturns JSON without a connectionmssql_connect_databaseworks when env variables are set
๐จ Development
npm install
npm run typecheck # type check only
npm run build # compile TypeScript
npm test # run unit tests
npm run ci # typecheck + build + testLicense
MIT ยฉ BYMCS
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables AI assistants to interact with Microsoft SQL Server databases through query execution, schema discovery, CRUD operations, stored procedures, and data export with built-in safety controls.18Apache 2.0
- Alicense-qualityDmaintenanceEnables AI assistants to interact with Microsoft SQL Server databases through a standardized interface. Supports executing SQL queries, browsing database schemas, and viewing table data with flexible authentication options for both local and Azure SQL databases.5MIT
- Flicense-qualityDmaintenanceProvides direct SQL query access to Microsoft SQL Server databases with full CRUD operations, enabling AI assistants to execute queries, modify data, and manage database objects through a simplified interface.
- Alicense-qualityDmaintenanceEnables LLMs to query and manage MSSQL databases using natural language, supporting CRUD operations and schema management.3,282MIT
Related MCP Connectors
GibsonAI MCP server: manage your databases with natural language
Query PostgreSQL databases in plain English โ LLM-generated, safety-validated SQL.
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/bymcs/mssql-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server