Read-only MCP for Microsoft SQL Server: metadata discovery, parameterized SELECT, plans.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
One-click editor setup isnβt available for this listing yet β we donβt have a confirmed install command, and weβd rather show nothing than point your editor at the wrong package or host. Follow the projectβs own setup instructions, linked above.
Inspect callable tools, capabilities, and parameters exposed to AI agents by Microsoft SQL Server.
list_profilesList configured connection profiles. Call first when picking a non-default profile. Returns `name`, `description` and `allow_write` per profile.
get_objectGet metadata for one relation (columns, indexes, constraints, relationships) or routine (definition). `name` accepts `Users`, `dbo.Users` or `[dbo].[Users]`. `includes` omitted β `columns`. Relations also carry an approximate `row_count`.
run_queryExecute read-only T-SQL SELECT; only SELECT allowed (no DML/DDL). Returns results as CSV in the `data` field (inline) or a snapshot resource URI when `snapshot=true`. Inline limit: 500 rows (hard ceiling 1000). Snapshot limit: 10 000 rows (hard ceiling 50 000). Prefer `analyze_query` for plan tuninβ¦
analyze_queryAnalyze execution plan for a read-only SELECT. Returns compact JSON summary (cost, operators, cardinality, warnings, `missing_indexes`, waits, stats); no result rows, full XML at `plan_uri`.
run_commandExecute write T-SQL (DDL/DML). Advertised only when some profile sets `AllowWrite=true` (off by default); still rejected at call time when the target `profile` is locked. Caller manages transactions. Returns `rows_affected` (β1 for DDL) and server `messages`. Marked destructive; intended for human-β¦
A read-only-by-default Model Context Protocol (MCP) server for Microsoft SQL Server that provides schema discovery, select-only queries, execution-plan analysis, opt-in writes, and profile-based access to multiple servers from a single toolset deployment.
Requirements: .NET 8.0 or later runtime (the tool targets net8.0 and net10.0), SQL Server, and a connection string.
Set MCPMSSQL_CONNECTION_STRING and run the server in one of these ways:
A profile is one SQL Server connection: a connection string, the row and timeout caps that apply to it, and whether writes are allowed. A profile named default always exists; every tool takes an optional profile to reach another, and list_profiles reports what is configured.
Settings come from three sources, merged field by field, later winning:
appsettings.json β any number of profiles;McpMssql__Profiles__<NAME>__<FIELD> environment variables β any number of profiles;MCPMSSQL_<FIELD> environment variables β the default profile only.Because the merge is per field rather than per profile, an appsettings.json can carry the full set while a flat MCPMSSQL_CONNECTION_STRING repoints the default profile at a local server, leaving its other fields intact. There is no fallback connection string: a profile without one β including a default that nothing configured β fails startup.
Each setting has one field name, spelled three ways β the JSON path under McpMssql:Profiles:<NAME>, that same path with : replaced by __ as an environment variable, or the flat form:
| Field | Flat variable | Default | Hard ceiling |
|---|---|---|---|
ConnectionString | MCPMSSQL_CONNECTION_STRING | required | β |
Description | MCPMSSQL_DESCRIPTION | none | β |
AllowWrite | MCPMSSQL_ALLOW_WRITE | false | β |
Query:MaxRows | MCPMSSQL_QUERY_MAX_ROWS | 500 | 1 000 |
Query:CommandTimeoutSeconds | MCPMSSQL_QUERY_COMMAND_TIMEOUT_SECONDS | 30 | 300 |
Query:SnapshotMaxRows | MCPMSSQL_QUERY_SNAPSHOT_MAX_ROWS | 10 000 | 50 000 |
Query:SnapshotCommandTimeoutSeconds | MCPMSSQL_QUERY_SNAPSHOT_COMMAND_TIMEOUT_SECONDS | 120 | 300 |
Analyze:CommandTimeoutSeconds | MCPMSSQL_ANALYZE_COMMAND_TIMEOUT_SECONDS | 300 | 600 |
Write:CommandTimeoutSeconds | MCPMSSQL_WRITE_COMMAND_TIMEOUT_SECONDS | 60 | 600 |
Caps are per profile. A value above its ceiling β or below 1 β is clamped at startup and the adjustment is logged as a warning on stderr; a flat value that is not an integer, or not a boolean for AllowWrite, is ignored, leaving whatever the other sources set.
Single connection: flat environment variables are the shortest path.
Multiple connections: use the user-scoped appsettings.json, which keeps credentials out of the host's process environment.
~/.config/mcp-mssql/appsettings.json%USERPROFILE%\.config\mcp-mssql\appsettings.jsonProfile names are case-insensitive, and the structured environment form splits on __, so McpMssql__Profiles__WAREHOUSE__ConnectionString is profile warehouse, field ConnectionString. A missing appsettings.json is fine β the server starts on whatever sources remain β but one that is not valid JSON fails startup.
Local development: store the connection string in user-secrets, then run with DOTNET_ENVIRONMENT=Development so secrets and a working-directory appsettings.json load as extra sources.
Connection string syntax: the usual Server=host,port;Database=db;User ID=...;Password=...;Encrypt=True; keywords of Microsoft.Data.SqlClient, which also supports Microsoft Entra (Azure AD) authentication: set Authentication to a supported mode (e.g. Active Directory Default, Active Directory Managed Identity, or Active Directory Interactive) when connecting to Azure SQL. See Connect to Azure SQL with Microsoft Entra authentication and SqlClient for all modes and details.
All tools accept an optional profile; when omitted, the default profile is used.
Tools
| Tool | Description | Key params |
|---|---|---|
list_profiles | List configured connection profiles. Call first when picking a non-default profile. Returns name, description and allow_write per profile. | β |
get_object | Get metadata for one relation (columns, indexes, constraints, relationships) or routine (definition). name accepts Users, dbo.Users or [dbo].[Users]. includes omitted β columns. Relations also carry an approximate row_count. | kind, name, profile, catalog, schema, includes |
run_query | Execute read-only T-SQL SELECT; only SELECT allowed (no DML/DDL). Returns results as CSV in the data field (inline) or a snapshot resource URI when snapshot=true. Inline limit: 500 rows (hard ceiling 1000). Snapshot limit: 10 000 rows (hard ceiling 50 000). Prefer analyze_query for plan tuning. | sql, profile, catalog, parameters, snapshot |
analyze_query | Analyze execution plan for a read-only SELECT. Returns compact JSON summary (cost, operators, cardinality, warnings, missing_indexes, waits, stats); no result rows, full XML at plan_uri. | sql, profile, catalog, parameters, estimated |
run_command | Execute write T-SQL (DDL/DML). Advertised only when some profile sets AllowWrite=true (off by default); still rejected at call time when the target profile is locked. Caller manages transactions. Returns rows_affected (β1 for DDL) and server messages. Marked destructive; intended for human-supervised use. | sql, profile, catalog, parameters |
kind β relation or routine.includes β Array of detail sections: columns, indexes, constraints, relationships (relations only), definition (routines only). relationships returns foreign keys in both directions.Catalog browsing is left to run_query over sys.objects, sys.schemas and sys.databases. get_object accepts analyze_query's missing_indexes[].table as-is.
Resources
Factual signals from GitHub, npm, and our automated checks β not a rating.
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/microsoft-sql-server)<a href="https://allmcps.com/mcp/microsoft-sql-server"><img src="https://allmcps.com/api/badge/microsoft-sql-server?style=directory" alt="Microsoft SQL Server on AllMCPs" /></a>