Microsoft SQL MCP Server
Official Microsoft MCP server for SQL Server, Azure SQL, and Microsoft Fabric. Exposes schema discovery, table management, and CRUD operations via natural language.
The MSSQL MCP Server is Microsoft's official Model Context Protocol implementation for interacting with SQL Server family databases. It is listed in the microsoft/mcp catalog and lives under the Azure-Samples organization at Azure-Samples/SQL-AI-samples/MssqlMcp (alias: aka.ms/MssqlMcp). The server lets an AI agent connect to any SQL endpoint, on-premises SQL Server, Azure SQL Database, or a Microsoft Fabric SQL endpoint, using a standard connection string, then issue schema and data operations from a chat-style interface.
The repo ships two interchangeable implementations: a Node.js server and a .NET 8 server. The .NET implementation exposes seven concrete tools: ListTables, DescribeTable, CreateTable, DropTable, InsertData, ReadData, and UpdateData. The Node implementation provides equivalent query, CRUD, and schema management capabilities, with an additional READONLY toggle and built-in safeguards such as requiring WHERE clauses on read and update operations.
The project is officially labeled experimental and is not intended for production use without additional hardening. It is most useful for prototyping agentic data workflows, building internal analytics copilots, and demoing natural-language SQL on Azure SQL or Fabric.
Tools
| Tool | Description |
|---|---|
ListTables |
Enumerate all tables in the connected database. |
DescribeTable |
Return schema details (columns, types, keys) for a given table. |
CreateTable |
Create a new table from a CREATE TABLE statement or schema definition. |
DropTable |
Drop an existing table. |
InsertData |
Insert rows into a table. |
ReadData |
Run a SELECT query against the database. WHERE clause is enforced to avoid full table scans. |
UpdateData |
Update existing rows. Requires an explicit WHERE clause. |
Prerequisites
- A SQL Server, Azure SQL Database, or Microsoft Fabric SQL endpoint
- For the .NET implementation: .NET 8 SDK
- For the Node implementation: Node.js 14+
- An MCP client (Claude Desktop, VS Code with the Agent extension, etc.)
Clone and build
git clone https://github.com/Azure-Samples/SQL-AI-samples.git
cd SQL-AI-samples/MssqlMcp
.NET 8 build
cd dotnet/MssqlMcp
dotnet build
The executable lands at MssqlMcp/bin/Debug/net8.0/MssqlMcp.exe.
Node build
cd Node
npm install
npm run build
The entry point lands at Node/dist/index.js.
Claude Desktop config (.NET)
{
"mcpServers": {
"MSSQL MCP": {
"command": "C:\\src\\SQL-AI-samples\\MssqlMcp\\dotnet\\MssqlMcp\\bin\\Debug\\net8.0\\MssqlMcp.exe",
"env": {
"CONNECTION_STRING": "Server=.;Database=test;Trusted_Connection=True;TrustServerCertificate=True"
}
}
}
}
For Azure SQL, use a connection string like Server=tcp:your-server.database.windows.net,1433;Database=your-db;Authentication=Active Directory Interactive;Encrypt=True;Connection Timeout=30;.
Claude Desktop config (Node)
{
"mcpServers": {
"mssql": {
"command": "node",
"args": ["C:/path/to/SQL-AI-samples/MssqlMcp/Node/dist/index.js"],
"env": {
"SERVER_NAME": "your-server-name.database.windows.net",
"DATABASE_NAME": "your-database-name",
"READONLY": "false"
}
}
}
}
VS Code config (.NET)
"mcp": {
"servers": {
"MSSQL MCP": {
"type": "stdio",
"command": "C:\\src\\SQL-AI-samples\\MssqlMcp\\dotnet\\MssqlMcp\\bin\\Debug\\net8.0\\MssqlMcp.exe",
"env": {
"CONNECTION_STRING": "Server=.;Database=test;Trusted_Connection=True;TrustServerCertificate=True"
}
}
}
}
Environment variables
.NET
CONNECTION_STRING: full ADO.NET connection string
Node
SERVER_NAME: SQL server hostnameDATABASE_NAME: target databaseREADONLY:"true"to disable writes,"false"for full CRUDCONNECTION_TIMEOUT: optional, seconds (default 30)TRUST_SERVER_CERTIFICATE: optional, for self-signed certs
- Let an AI agent answer ad-hoc business questions by running SELECT queries against Azure SQL or a Fabric SQL endpoint.
- Prototype an internal analytics copilot that can explore unknown schemas via ListTables and DescribeTable before querying.
- Bootstrap a new database during development: have the agent generate and run CreateTable, InsertData, and seed scripts.
- Run controlled data updates from chat, with WHERE clause enforcement to prevent accidental mass writes.
- Demo natural-language SQL against on-premises SQL Server using Trusted Connection (Windows auth) without standing up a separate API.
- "List all tables in the sales database and describe the Orders table."
- "Show me the top 20 customers by total order value in the last 90 days."
- "Create a table called Leads with columns id, email, source, created_at."
- "Insert a new row into Contacts for jane@acme.com with source = 'webinar'."
- "Update the status to 'closed' for all Tickets where resolved_at is not null."
- Officially maintained by Microsoft and referenced from the
microsoft/mcpcatalog viaaka.ms/MssqlMcp. - Works across on-premises SQL Server, Azure SQL Database, and Microsoft Fabric using a single connection string.
- Two implementations (Node and .NET 8) so teams can pick the runtime that matches their stack.
- Built-in safeguards: WHERE clause enforcement for reads and updates, plus a
READONLYmode in the Node build.
- Explicitly marked experimental and not intended for production use without additional hardening.
- Tool surface is intentionally narrow (seven core tools); no stored procedure, view DDL, or index management primitives.
- Requires a local build (no published npm package or container image) and absolute paths in the MCP config.
- Data API builder SQL MCP Server: Microsoft's production-oriented MCP surface, configured via DAB JSON and shipped in DAB 1.7+.
- RichardHan/mssql_mcp_server: community Python MCP server for SQL Server focused on safe read and query execution.
- aadversteeg/mssqlclient-mcp-server: community .NET MSSQL client implementing the MCP protocol.