Microsoft.SqlServer.SQLtools.MCPserver 1.0.0

Prefix Reserved
{
  "inputs": [
    {
      "type": "promptString",
      "id": "connection_string",
      "description": "SQL Server connection string",
      "password": true
    }
  ],
  "servers": {
    "Microsoft.SqlServer.SQLtools.MCPserver": {
      "type": "stdio",
      "command": "dnx",
      "args": ["Microsoft.SqlServer.SQLtools.MCPserver@1.0.0", "--yes"],
      "env": {
        "CONNECTION_STRING": "${input:connection_string}"
      }
    }
  }
}
                    
This package contains an MCP Server. The server can be used in VS Code by copying the generated JSON to your VS Code workspace's .vscode/mcp.json settings file.
dotnet tool install --global Microsoft.SqlServer.SQLtools.MCPserver --version 1.0.0
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local Microsoft.SqlServer.SQLtools.MCPserver --version 1.0.0
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=Microsoft.SqlServer.SQLtools.MCPserver&version=1.0.0
                    
nuke :add-package Microsoft.SqlServer.SQLtools.MCPserver --version 1.0.0
                    

SQL Tools MCP Server

A Model Context Protocol (MCP) server that gives AI agents tools for SQL Server, Azure SQL Database, Azure SQL Managed Instance and SQL database in Microsoft Fabric. An MCP client such as GitHub Copilot, Visual Studio Code, Claude Code, Codex or Cursor starts the server as a local process and talks to it over stdio.

With these tools an agent can:

  • connect to a database and list the connections it may use
  • explore the schema it needs to write a query
  • run queries, read-only unless you allow writes
  • capture and analyze execution plans, compare query rewrites, and try hints and hypothetical indexes
  • look up Extended Events fields, server properties and backup information

Requirements

  • .NET SDK 10 or later (dotnet --version). The dnx command that starts the server ships with the SDK.
  • Network access to the database and a login with the permissions the work needs.

Start the server from an MCP client

MCP clients start the server with this command:

dnx Microsoft.SqlServer.SQLtools.MCPserver@1.0.0 --yes

dnx downloads this exact version the first time it runs, and --yes accepts the download prompt. Give the server its connection string in the CONNECTION_STRING environment variable through the client's configuration. Keep connection strings out of files you commit.

Most clients take an entry of this shape. The top-level key is mcpServers in Claude Code, Cursor and Copilot CLI, and servers in the mcp.json of Visual Studio Code:

{
  "mcpServers": {
    "sql-tools": {
      "command": "dnx",
      "args": ["Microsoft.SqlServer.SQLtools.MCPserver@1.0.0", "--yes"],
      "env": {
        "CONNECTION_STRING": "Server=<server>;Database=<database>;Authentication=Active Directory Default;Encrypt=True"
      }
    }
  }
}

Some clients register a server from the command line, for example Claude Code:

claude mcp add sql-tools -e CONNECTION_STRING="<connection string>" -- dnx Microsoft.SqlServer.SQLtools.MCPserver@1.0.0 --yes

The microsoft-sql-admin plugin sets this server up for you in clients that support plugins, and adds SQL administration skills that use its tools. Its setup skill has the steps for each client.

Clients ask for your approval before they run a tool. For scripted or non-interactive use, allow this server's tools in the client's own permission settings.

To install the tool into a folder instead of starting it through dnx:

dotnet tool install Microsoft.SqlServer.SQLtools.MCPserver --version 1.0.0 --tool-path ./sql-tools

Then point the client at ./sql-tools/sql-tools-mcp (sql-tools-mcp.exe on Windows).

Safety

  • mssql_execute_query is read-only by default. It refuses statements that write data, change schema or change server settings, whatever the login is allowed to do. Set SQLTOOLS__ALLOWWRITES=Enabled to let it run them.
  • With writes enabled, this version still cannot run a statement that has to be the first in its batch, such as CREATE VIEW, CREATE PROCEDURE or CREATE FUNCTION. The statement fails with a syntax error. Create those objects with another client.
  • Every tool runs with the permissions of the login in the connection string. Use a login that has no more permissions than the task needs.
  • Some tools run the query you give them in order to measure it, for example to capture an actual execution plan or to compare hints. Their descriptions say so.
  • One query returns at most 10,000 rows. The reply says when a result was cut.

Settings

Set these as environment variables in the client's configuration for the server.

Variable Default Effect
CONNECTION_STRING none The connection the server offers to the agent. Without it the server starts and reports that no connection is configured.
SQLTOOLS__ALLOWWRITES Disabled Enabled lets mssql_execute_query run statements that write.
SQLTOOLS__INCLUDEPREVIEWFEATURES Disabled Enabled adds tools that are still in preview.
SQLTOOLS__SKILLCONTENTPROVIDER built-in skills offered External leaves SQL administration skills to a plugin installed in the client, as the microsoft-sql-admin plugin does. Internal offers the built-in skills through tools, McpResource as MCP resources.
SQLTOOLS__AUTOCONNECTTODEFAULT true false stops the server from opening the configured connection until the agent asks.
SQLTOOLS__MAXRESULTROWS 10000 Rows one query may return.
SQLTOOLS__MAXRESULTBYTES 1048576 Bytes of text one query may return.
SQLTOOLS__BACKUPVERIFYALLOWEDPATHS empty Folders, separated by semicolons, that mssql_backup_verify_file may read besides the server's default backup folder.
SQLTOOLS__TELEMETRYENABLED true false turns telemetry off.
MCPSERVERCONFIG__USESAMPLING true false stops the server from asking the client's model for help (MCP sampling).

Telemetry

The server sends telemetry to Microsoft by default. Set SQLTOOLS__TELEMETRYENABLED=false to turn it off.

Telemetry records which built-in tools and skills are used, how long calls take, whether they succeed, the category of an error with the exception type and stack trace, the name and version of the MCP client, and when the server starts and stops. It is designed to leave out query text, query results, connection strings and error messages. The Microsoft privacy statement applies.

License and notices

The server is licensed under the Microsoft Software License Terms in LICENSE.txt in this package. THIRD-PARTY-NOTICES.txt lists the components the package includes and their licenses.

Help and feedback

Report problems and send feedback at https://github.com/microsoft/microsoft-sql/issues.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.0.0 132 11/16/2026
0.1.246391418-preview 110 11/13/2026