SqlServerMcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
SqlServerMcp
A Model Context Protocol (MCP) server for SQL Server. Exposes schema inspection, safe read-only queries, and query plan analysis as MCP tools.
How it works: This server does not accept natural-language questions. Instead, the connected AI tool (the MCP client) decides and generates the SQL query based on the user's intent and the schema it inspects via the tools below. The server only executes the SQL the AI produces, under the safety rules described in Safety.
Install
dotnet tool install -g SqlServerMcpRelated MCP server: MSSQL MCP Server
Configure
Configuration is done entirely through environment variables in your MCP client config. No need to edit any files — just add your connection strings and query settings directly in the env block.
Add the following to your MCP client configuration (e.g. Claude Desktop claude_desktop_config.json):
{
"mcpServers": {
"sqlserver": {
"command": "sqlservermcp",
"env": {
"ConnectionStrings__MyDb": "Server=localhost;Database=MyDatabase;Trusted_Connection=True;TrustServerCertificate=True;",
"Query__DefaultTop": "1000",
"Query__MaxTop": "500000"
}
}
}
}Environment Variable Format
Variable | Description |
| SQL Server connection string. Add multiple with different names. |
| Default row limit for queries (default: |
| Maximum allowed row limit (default: |
Note: Use double underscores (
__) as the separator — this is the .NET configuration convention for environment variables.
Multiple Databases
You can configure multiple databases by adding multiple connection string variables:
{
"env": {
"ConnectionStrings__Production": "Server=prod-server;Database=ProdDb;...",
"ConnectionStrings__Staging": "Server=staging-server;Database=StagingDb;..."
}
}Then use the ListDatabases tool to see available names, and pass the database name to any query tool.
Available Tools
Tool | Description |
| List available database names configured in this server |
| List all user tables in a database |
| Describe columns of a specific table (schema.table format) |
| Return full database schema: tables, columns, PKs, FKs |
| Search tables and columns by keyword |
| Execute a safe read-only SELECT query with auto row-limiting |
| Explain a SELECT query using estimated execution plan |
Example
Prompt:
"Using the
MyDbdatabase, show me the top 5 customers by total order amount in 2025."
The AI generates and executes the query by calling SearchSchema / DescribeTable to discover the tables, then passing this SQL to RunQuery:
SELECT TOP 5 c.CustomerId, c.Name, SUM(o.TotalAmount) AS TotalSpent
FROM dbo.Customers c
JOIN dbo.Orders o ON o.CustomerId = c.CustomerId
WHERE YEAR(o.OrderDate) = 2025
GROUP BY c.CustomerId, c.Name
ORDER BY TotalSpent DESC;Expected output:
CustomerId | Name | TotalSpent |
1042 | Acme Corp | 184500.00 |
778 | Globex Ltd | 162300.50 |
2310 | Initech | 149875.25 |
915 | Soylent Inc | 138420.00 |
604 | Umbrella Co | 121990.75 |
Disclaimer: The accuracy of the generated SQL and the final output depends on the AI model you select in your MCP client. More capable models produce more reliable queries; weaker models may misinterpret the schema or the intent of the prompt.
Safety
Only
SELECTqueries are allowed — all write operations are blockedQueries are automatically row-limited to prevent runaway results
Connection strings are configured server-side, never exposed to the AI client
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
SQL validation, formatting, parsing, metadata extraction, linting, and security analysis.
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Query Postgres, MySQL, SQL Server, Oracle, BigQuery, ClickHouse and Redshift from your AI client.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to connect and query Microsoft SQL Server databases using natural language, executing read-only SQL queries for safe data inspection and analysis.MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI assistants to interact with Microsoft SQL Server databases via introspection and query tools. Supports single or multiple databases with read-only mode by default and an optional write capability.299 npm5MIT
- FlicenseCqualityDmaintenanceEnables AI assistants to analyze and query SQL Server databases, including schema discovery, health checks, and data retrieval.10-
- FlicenseNot gradedqualityDmaintenanceEnables secure interaction with Microsoft SQL Server databases, allowing schema exploration, metadata retrieval, and read-only query execution through natural language.1-