mssql-mcp
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., "@mssql-mcprun a read-only query to show the top 10 rows from the Customers 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.
mssql-mcp
Local MCP server (stdio) for running ad hoc T-SQL queries against SQL Server databases, read-only by default.
Context: the official Microsoft sample Azure-Samples/SQL-AI-samples/MssqlMcp was removed in June 2026 ("unsafe MCP sample"), and its official replacement (Data API builder SQL MCP Server) does not allow free-form SQL. This small server (official MCP SDK + the mssql driver) fills the gap.
Security model
Use a SQL login restricted to db_datareader. That is the only read-only guarantee that actually holds. This server assumes it is driven by an LLM that reads untrusted database content, so a prompt injection can make it emit any query it is allowed to emit.
On top of that, three defences apply in read-only mode (the default):
Queries are parsed with a tokeniser that understands string literals, quoted and bracketed identifiers, and nested block comments. Only a single
SELECT/WITHstatement is accepted, and write, DDL, execution and pass-through keywords are rejected anywhere in the statement — including after a CTE, whereWITH … DELETEis otherwise valid T-SQL.Every query runs inside a transaction that is always rolled back, so a statement that slips past the parser still cannot persist a change.
Rows are streamed and the query is cancelled once
maxRowsis reached, so an unboundedSELECTcannot exhaust memory.
Set MSSQL_MCP_READONLY=false to lift 1 and 2.
Related MCP server: sql-explorer-mcp
Configuration
Credentials are read from a .env file resolved next to index.js (see .env.example), or from the environment. Copy the example and fill it in:
cp .env.example .envVariable | Default | Purpose |
| — | Server hostname (required) |
|
| Server port |
| — | Default database |
| — | Credentials (required) |
|
| Encrypt the connection |
|
| Skip certificate validation — see below |
Server options:
Variable | Default | Purpose |
|
| Alternate .env location |
|
|
|
|
| Query timeout |
| unset | Comma-separated allowlist; also filters |
|
| Connection pools kept open; the least recently used one is closed to make room |
DB_CONFIG_TRUST_SERVER_CERTIFICATE=true encrypts the connection without authenticating the server, which leaves it open to interception. Prefer installing the server's CA certificate. The server prints a warning at startup when this is enabled.
Without MSSQL_MCP_ALLOWED_DATABASES, every database the login can reach is queryable via the database parameter. Roaming across more databases than MSSQL_MCP_MAX_POOLS is fine — pools are recycled, not refused.
Exposed tools
read_data— ad hoc T-SQL query,maxRowsdefaults to 100, capped at 1000, optionaldatabaseparamlist_objects— tables/views/procs/functions, LIKE filter (e.g.%ORDER%)describe_object— columns + parameters (e.g.dbo.GetOrderTotals)get_definition— T-SQL source of a view/proc/function viaOBJECT_DEFINITIONlist_databases— databases available on the server
Registering with Claude Code
claude mcp add --scope user mssql -- node /path/to/mssql-mcp/index.jsFor a read-write server (on demand, one-off session):
claude mcp add --scope local mssql-rw --env MSSQL_MCP_READONLY=false -- node /path/to/mssql-mcp/index.jsTests
pnpm test # offline: read-only guard regression suite
pnpm smoke # end-to-end, needs a reachable databaseBonus: dump all module definitions
node dump-definitions.mjs [out-dir] # default: ./sql-definitionsDumps the T-SQL source of every proc/view/function/trigger of the configured database, one file per object. Requires GRANT VIEW DEFINITION for the login. Object names are sanitised before being used as filenames, since SQL Server allows path separators inside bracketed identifiers; objects whose sanitised names collide are skipped and reported rather than silently overwritten.
This server cannot be installed
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
- AlicenseAqualityCmaintenanceSQL Server MCP server with AST-based query validation, read-only safety, schema exploration, ER diagram generation, and DBA toolkit integration (First Responder Kit, DarlingData, sp_WhoIsActive).125MIT
- Alicense-qualityFmaintenanceRead-only MCP server for SQL databases (SQL Server, Postgres, SQLite) with multi-server support and three-layer safety using AST validation and linting.MIT
- Alicense-qualityCmaintenanceRead-only SQL Server MCP server enabling safe database queries, table listing, and schema inspection with built-in security protections.MIT
- FlicenseAqualityDmaintenanceMCP server for connecting to SQL Server in readonly mode. Allows any MCP client to explore the schema and run SELECT queries against a SQL Server database.6
Related MCP Connectors
Read-only MCP server for ClassQuill, a tutoring-business-management platform.
Read-only MCP server for wafergraph.com's semiconductor & AI supply-chain data: 30 tools, no auth.
Official Microsoft MCP Server to query Microsoft Entra data using natural language
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/MCopin/mssql-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server