SQL Server MCP Server
The SQL Server MCP Server connects AI agents to SQL Server databases for schema inspection, query execution, data diagnostics, and connection management.
Connection Management: List, switch, add, and remove named database connection profiles dynamically (connections can be configured via JSON file, environment variables, or during a session).
Query Execution: Run
SELECTqueries immediately (with an optional row limit, default 500). Execute write operations—INSERT,UPDATE,DELETE, DDL (CREATE,ALTER,DROP TABLE,TRUNCATE), and stored procedures—only after a preview step that requires explicit confirmation.Schema Inspection: List tables with row counts (optionally include views), inspect full table details (columns, data types, keys, indexes), list stored procedures with name filtering, and retrieve their source definitions.
Data Diagnostics: Search for a value across all columns in a table; check foreign key violations (orphaned records) for one or all tables; count rows and sample data with optional filtering; identify rows with
NULLvalues in specified columns; compare row counts between parent and child tables to find data gaps; generate a comprehensive table diagnostic report covering counts, nulls, FK violations, and recent rows.Performance Analysis: Retrieve the estimated execution plan for any
SELECTquery.Safety & Permissions:
SELECTqueries run without confirmation; any write operation requires a dry-run preview and an explicitconfirm: trueflag; dangerous operations likeDROP DATABASE,xp_cmdshell, andBULK INSERTare permanently blocked.
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., "@SQL Server MCP ServerList all tables in the database"
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.
SQL Server MCP Server
A Model Context Protocol (MCP) server for SQL Server — built for development debugging and multi-database data repair. Connects to Antigravity (the AI agent) so you can inspect schemas, run queries, and diagnose data problems across multiple databases directly from your IDE chat.
🚀 Setup & Configuration
You can configure single or multiple SQL Server databases directly using any of these 3 clean methods:
Method 1: Using a connections.json File (Easiest & Cleanest!) 🌟
Create a connections.json file in your workspace directory (or set CONNECTIONS_FILE in env pointing to your JSON file path). Write your database connections in clean JSON array format without any escaping:
[
{
"name": "sweet-shop",
"label": "PradeepSweetShop Dev",
"server": "localhost\\SQLEXPRESS",
"database": "PradeepSweetShopDb",
"user": "sa",
"password": "your_password"
},
{
"name": "ecommerce",
"label": "ECommerce Dev",
"server": "localhost\\SQLEXPRESS",
"database": "ECommerceDB",
"user": "sa",
"password": "your_password"
}
]And configure mcp_config.json:
{
"mcpServers": {
"sql-server-mcp": {
"command": "npx",
"args": ["-y", "@dkcodingcenter/sql-server-mcp"],
"env": {
"CONNECTIONS_FILE": "C:/path/to/connections.json"
}
}
}
}Method 2: Environment Variable (DB_CONNECTIONS JSON Array)
Pass a JSON array string directly in DB_CONNECTIONS:
{
"mcpServers": {
"sql-server-mcp": {
"command": "npx",
"args": ["-y", "@dkcodingcenter/sql-server-mcp"],
"env": {
"DB_CONNECTIONS": "[{\"name\":\"sweet-shop\",\"label\":\"PradeepSweetShop Dev\",\"server\":\"localhost\\\\SQLEXPRESS\",\"database\":\"PradeepSweetShopDb\",\"user\":\"sa\",\"password\":\"your_password\"},{\"name\":\"ecommerce\",\"label\":\"ECommerce Dev\",\"server\":\"localhost\\\\SQLEXPRESS\",\"database\":\"ECommerceDB\",\"user\":\"sa\",\"password\":\"your_password\"}]"
}
}
}
}Method 3: Single Database Configuration
{
"mcpServers": {
"sql-server-mcp": {
"command": "npx",
"args": ["-y", "@dkcodingcenter/sql-server-mcp"],
"env": {
"DB_SERVER": "localhost",
"DB_NAME": "PradeepSweetShopDb",
"DB_USER": "sa",
"DB_PASSWORD": "your_password"
}
}
}
}Related MCP server: MSSQL MCP Server
🛠️ Available Tools (17 total)
Connection Management
Tool | Description |
| List all loaded SQL Server connection profiles and see which one is active |
| Switch default active connection to another loaded profile by name |
| Dynamically add or update a named connection profile during chat session |
| Remove a connection profile |
Query Execution
Tool | Description |
| Run a SELECT query (accepts optional |
| Run INSERT/UPDATE/DELETE/DDL — shows preview first, requires confirm=true to execute |
Schema Inspection
Tool | Description |
| List all tables with row counts |
| Full table details: columns, PKs, FKs, indexes |
| List all stored procedures |
| Get stored procedure source code |
Data Diagnostics
Tool | Description |
| Search for a value across all columns in a table |
| Find orphaned records / FK violations |
| Row count + sample rows from a table |
| Find NULL values in specified columns |
| Compare parent/child table counts to find gaps |
| Full diagnostic report on a table |
| Get execution plan for a query |
🔐 Permission Model
Query Type | Behaviour |
| Runs immediately, no confirmation needed |
| Shows preview first. Must call again with |
| Shows preview first. Must call again with |
| Always blocked, cannot be executed |
💡 Example Questions to Ask the Agent
"List all configured SQL connections"
"Switch SQL connection to ecommerce"
"Run a query
SELECT TOP 5 * FROM Paymentson connection ecommerce""Compare row counts between Products and Categories in sweet-shop"
"Run a full diagnostic on the Orders table"
📦 Publishing to npm
To publish updates to npm:
npm login
npm publish --access publicMaintenance
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
- Alicense-qualityDmaintenanceEnables 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.3734MIT
- Flicense-qualityCmaintenanceEnables AI assistants to interact with SQL Server databases through tools for connectivity, schema exploration, SQL queries, and OEE metrics analysis.
Related MCP Connectors
Explore, query, and inspect SQLite databases with ease. List tables, preview results, and view det…
Debug, build, and manage Power Automate cloud flows with AI agents
Provide real-time data querying and visualization by integrating Tako with your agents. Generate o…
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/dkp5897/sql-server-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server