@warnyin/mssql-mcp
v0.1.1
Published
MCP server for managing Microsoft SQL Server — list/describe schemas, run queries, execute T-SQL.
Readme
@warnyin/mssql-mcp
A Model Context Protocol (MCP) server for managing Microsoft SQL Server. Exposes
read-only and administrative tools over stdio, so it can be launched directly
by any MCP-compatible client (Claude Desktop, Claude Code, MCP Inspector, etc.)
via npx.
Features
- List & describe — databases, schemas, tables, views, stored procedures, functions, indexes, foreign keys.
- Get definitions — source T-SQL for views, procedures, and functions.
- Query — safe
SELECT/WITHexecution with row caps and pagination guidance. - Execute — full T-SQL (
INSERT,UPDATE,DELETE, DDL) when needed; opt-in disabled viaMSSQL_READONLY=true. - Server info — version, edition, current login, collation.
Quickstart
Run via npx
MSSQL_SERVER=localhost \
MSSQL_USER=sa \
MSSQL_PASSWORD='Your_Strong_Password' \
MSSQL_DATABASE=master \
npx -y @warnyin/mssql-mcpRun from source
npm install
npm run build
MSSQL_SERVER=localhost MSSQL_USER=sa MSSQL_PASSWORD='Your_Strong_Password' node dist/index.jsTest with MCP Inspector
npx -y @modelcontextprotocol/inspector \
--env MSSQL_SERVER=localhost \
--env MSSQL_USER=sa \
--env MSSQL_PASSWORD='Your_Strong_Password' \
node dist/index.jsConfiguration
All configuration is via environment variables.
| Variable | Required | Default | Description |
| --- | --- | --- | --- |
| MSSQL_SERVER | ✅ | — | Server hostname or IP. |
| MSSQL_USER | ✅ | — | SQL login. |
| MSSQL_PASSWORD | ✅ | — | SQL login password. |
| MSSQL_DATABASE | | (login default) | Default database for queries. |
| MSSQL_PORT | | 1433 | TCP port. |
| MSSQL_INSTANCE | | — | Named instance (e.g. SQLEXPRESS). |
| MSSQL_ENCRYPT | | true | Enable TLS. |
| MSSQL_TRUST_SERVER_CERTIFICATE | | false | Accept self-signed certs (dev only). |
| MSSQL_CONNECTION_TIMEOUT_MS | | 15000 | Connect timeout. |
| MSSQL_REQUEST_TIMEOUT_MS | | 30000 | Per-request timeout. |
| MSSQL_READONLY | | false | When true, disables mssql_execute. |
Claude Desktop / Claude Code config
Add this entry to your MCP servers config (claude_desktop_config.json or
your Claude Code MCP config):
{
"mcpServers": {
"mssql": {
"command": "npx",
"args": ["-y", "@warnyin/mssql-mcp"],
"env": {
"MSSQL_SERVER": "localhost",
"MSSQL_USER": "sa",
"MSSQL_PASSWORD": "Your_Strong_Password",
"MSSQL_DATABASE": "master"
}
}
}
}Tools
| Tool | Read-only | Description |
| --- | --- | --- |
| mssql_list_databases | ✅ | List databases on the instance. |
| mssql_list_schemas | ✅ | List user schemas in a database. |
| mssql_list_tables | ✅ | List tables, optionally filtered by schema, with row counts. |
| mssql_describe_table | ✅ | Columns, PK, FKs, and indexes for a table or view. |
| mssql_list_views | ✅ | List views. |
| mssql_list_procedures | ✅ | List stored procedures and user-defined functions. |
| mssql_get_object_definition | ✅ | T-SQL source of a view / procedure / function. |
| mssql_query | ✅ | Run a SELECT / WITH query. Capped at 100 rows by default (max 10000). |
| mssql_execute | ❌ | Run any T-SQL — disabled when MSSQL_READONLY=true. |
| mssql_server_info | ✅ | Version, edition, hostname, current login, collation. |
Every tool supports response_format: 'markdown' | 'json' (defaults to
markdown).
Safety notes
mssql_queryrejects statements that don't begin withSELECTorWITH(after leading comments/whitespace).mssql_executeis markeddestructiveHint: trueand is fully disabled whenMSSQL_READONLY=true.- Responses are capped at 25 000 characters; results beyond that are truncated
and
truncated: trueis reported in the structured response. - The server logs to
stderronly (per stdio MCP convention).
License
MIT
