This guide walks you through cloning the repository, building the server, wiring up your connection string, and issuing your first natural-language query to SQL Server — all in under five minutes. By the end you will have a running MCP server that your AI coding assistant can use to inspect schemas, read data, and execute write operations.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.
Prerequisites
- .NET 9.0 SDK — download here. The SDK (not just the runtime) is required to build from source. If you use the self-contained single-file publish output, only the runtime is needed on the target machine.
- SQL Server or Azure SQL Database — SQL Server 2008 R2 (10.50) or later, including Azure SQL Database. The server is tested against SQL Server 2008 R2 through 2022.
- An MCP-compatible client — Cursor, VS Code with GitHub Copilot Agent, or Claude Desktop. See Clients for per-client configuration details.
Steps
Clone and build
Clone the repository and build the server project:After a successful build, the debug executable is at:You can also run the xUnit test suite (no live database required for most tests):For a production-ready self-contained single-file binary, use the included publish script:This produces
C:\Development\MCPs\MS-SQL-Release\MssqlMcp.exe by default (the output path is set in MssqlMcp/MssqlMcp.csproj).Set the connection string
The server reads The server validates the connection string and opens a live test connection before the MCP transport starts. A bad string causes an immediate exit (code
CONNECTION_STRING from its process environment. Do not set it as a system-wide environment variable — doing so would expose your credentials to every process on the machine. Instead, pass it only to the MCP server process via the env block of your MCP client config (see the next step).Connection string format is standard ADO.NET. A Windows authentication example:1) with diagnostics written to the log file.Configure your MCP client
Add the server to your MCP client’s config file. The example below uses Cursor’s Replace the
mcp.json format, which closely matches sample_mcp.json in the repository root:command path with the actual location of your built or published executable, and update CONNECTION_STRING to point at your database. See Clients / Cursor for full per-client instructions including VS Code and Claude Desktop formats.Restart the MCP server after changing any environment variable — the server reads env vars only at startup.
Verify the connection
When the MCP client launches the server, startup validation runs automatically:
The log contains the process ID, working directory, masked connection string, the SQL connection test result, and stack traces on failure.
- The server checks that
CONNECTION_STRINGis non-empty. - It opens a real ADO.NET connection to SQL Server and confirms it succeeds.
- Only after both checks pass does it start the MCP stdio transport and begin accepting tool calls.
MCP error -32000: Connection closed), check the log file for details:| Scenario | Log location |
|---|---|
LOG_FILE_PATH set to a file | That file |
LOG_FILE_PATH set to a directory | mssql-mcp-<timestamp>.log inside it |
| Default (Windows) | %LOCALAPPDATA%\MssqlMcp\Logs\mssql-mcp-<timestamp>.log |
| Default (Linux/macOS) | ~/.local/share/MssqlMcp/Logs/mssql-mcp-<timestamp>.log |
Try your first prompt
Once the server is connected, open a chat in your MCP client and try:
“List tables in the database”The agent should call the
ListObjects tool with objectType=Table and return the table names from your database. From there you can ask it to describe a table, read some rows, or inspect a stored procedure.First-time AI Insights workflow
The AI Insights layer caches object summaries inside the target database. It is enabled by default but must be installed once per database. When you connect to a new database, follow this sequence:GetServerInfo— confirm the server version, edition, and user database count.InsightsCheck— check whether the Insights schema, DDL audit trigger, and watermark table are present.InstallInsightsLayer— ifInsightsCheckreports the schema or trigger as missing, run this tool once. The install is idempotent; re-running it is safe.ListObjects(objectType=Table) — enumerate tables; the server auto-generates mechanical baseline insights for each one whenINSIGHTS_AUTOPOPULATEis enabled.DescribeTable— inspect a table and review theinsight,insightFreshness, andenrichmentSuggestedfields in the response.UpsertInsight— whenenrichmentSuggestedistrue, submit the pre-filled payload from the response to upgrade the mechanical baseline to a richer, LLM-authored insight.
MCP-Insight-Enrichment-v1).
Multi-batch
GO scripts are not supported by ExecuteSQL. The tool accepts only a single T-SQL statement per call. Split multi-statement scripts at GO boundaries and issue each statement individually.