Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/A-Point-Systems-ltd/ms-sql-mcp/llms.txt

Use this file to discover all available pages before exploring further.

MSSQL MCP Server is a Model Context Protocol (MCP) server that gives LLM agents structured, safe access to Microsoft SQL Server and Azure SQL Database. Built on .NET 9 with the official MCP C# SDK (ModelContextProtocol 0.1.0-preview.10), it runs as a stdio process that any MCP-compatible client — Cursor, VS Code Copilot, Claude Desktop, and others — can launch and query without writing a single line of database code.

Project origins

MSSQL MCP Server is forked from Azure-Samples/SQL-AI-samples and substantially extended with:
  • Unified object introspection — a single ListObjects tool replaces the legacy per-type helpers (ListTables, GetStoredProc, etc.), covering tables, views, stored procedures, functions, triggers, and system objects through one consistent interface.
  • Strict read/write SQL routingSqlStatementClassifier enforces a hard split so SELECT queries can only travel through ReadData and mutating statements can only travel through ExecuteSQL (or the dedicated write tools). This keeps destructive operations behind explicitly flagged tools.
  • AI Insights layer — an optional caching layer that stores LLM-authored (or server-generated baseline) summaries of database objects in the target database itself, reducing repeated schema work and token consumption across long investigations.

Requirements

ComponentVersion
.NET SDK / Runtime.NET 9.0
SQL Server2008 R2 (10.50) or later
Azure SQL DatabaseSupported
Tested target versions include SQL Server 2008 R2 through 2022 and Azure SQL Database. The server validates CONNECTION_STRING and opens a test SQL connection before starting the MCP transport. If either check fails, the process exits with code 1 and writes diagnostics to the log file — so a broken connection string is caught immediately, not mid-conversation.

Capabilities

Schema Inspection

Explore tables, views, stored procedures, functions, triggers, and system objects. Retrieve full column metadata, indexes, constraints, foreign keys, and T-SQL definitions.

Data Reads

Run any read-only SELECT or WITH … SELECT query against user tables, sys.*, INFORMATION_SCHEMA, and DMVs through the ReadData tool.

Write & DDL

Insert, update, delete, create, alter, drop, truncate, and execute stored procedures. Destructive tools are flagged in MCP metadata so agents can confirm intent before acting.

AI Insights Cache

Cache LLM-authored or auto-generated summaries of database objects. Freshness tracking, DDL-change detection, and enrichment directives keep insights current without manual upkeep.

Project layout

MS-SQL/
├── MssqlMcp/                    # MCP server (.NET 9 exe)
│   ├── Program.cs               # Startup, logging, DI, stdio transport
│   ├── SqlConnectionFactory.cs  # CONNECTION_STRING → SqlConnection
│   ├── SqlStatementClassifier.cs
│   ├── TriggerQualifiedName.cs
│   ├── DbOperationResult.cs
│   ├── InsightsLayer/           # AI Insights service + embedded SQL scripts
│   │   ├── InsightsLayerService.cs
│   │   ├── InsightDdlProcessingQueue.cs
│   │   └── SqlScripts/
│   └── Tools/                   # MCP tools (partial class Tools)
├── MssqlMcp.Tests/              # xUnit test suite
├── sample_mcp.json              # Example MCP client config
├── publish-release.ps1          # Single-file Release publish script
└── .cursor/skills/mssql-insights-ops/SKILL.md   # Agent playbook for insights
The MssqlMcp/ directory contains the entire server. InsightsLayer/ holds the AI Insights service, background DDL processing queue, and the embedded SQL scripts that are installed into the target database on demand. Tools/ contains a single partial Tools class split across files — one for each logical group of tools. MssqlMcp.Tests/ is an xUnit project covering SQL routing, name parsing, environment opt-out semantics, and integration smoke tests.

Next steps

Quickstart

Build from source, set your connection string, and connect your first MCP client in under five minutes.

Configuration

All environment variables: connection string, Insights layer toggles, log file path, and Azure SQL Entra ID auth.

Clients

Step-by-step setup for Cursor, VS Code Copilot, and Claude Desktop.

Tools overview

Full reference for all 19 MCP tools — read, write, DDL, and AI Insights.

Build docs developers (and LLMs) love