home / mcp / mssql mcp server

MSSQL MCP Server

A production-ready MCP server for SQL Server with virtual filesystem, SP management, and safe write workflows.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "jpcanter-sql-server-mcp": {
      "command": "node",
      "args": [
        "/absolute/path/to/sql-server-mcp/dist/index.js"
      ],
      "env": {
        "DB_USER": "sa",
        "DB_SERVER": "localhost",
        "DB_ENCRYPT": "true",
        "DB_DATABASE": "MyDatabase",
        "DB_PASSWORD": "YourPassword",
        "DRAFT_SCHEMA": "dbo_draft",
        "MAX_ROWS_AFFECTED": "10000",
        "REQUIRE_TRANSACTIONS": "true",
        "ENABLE_SP_MODIFICATIONS": "true",
        "ENABLE_WRITE_OPERATIONS": "true",
        "AUTO_BACKUP_BEFORE_DEPLOY": "true",
        "DB_TRUST_SERVER_CERTIFICATE": "false"
      }
    }
  }
}

You can run the MSSQL MCP Server to manage Microsoft SQL Server objects through a Model Context Protocol (MCP). It exposes a virtual filesystem for database objects, supports safe write workflows for stored procedures, and provides discovery and performance tools for observability and governance.

How to use

You use an MCP client to connect to the MSSQL MCP Server and browse database objects as files, search for stored procedures, inspect schemas, and analyze dependencies. When you need to modify a stored procedure, you draft changes in a separate testing zone, test them with parameters, and then deploy with optional auto-backups. You can start transactions for safe data modifications, view execution statistics from the plan cache, and audit every operation.

How to install

Prerequisites: Node.js installed on your machine and access to a Microsoft SQL Server instance.

Step 1: Install dependencies and build the server.

npm install
npm run build

Configuration and usage notes

Configure environment variables to connect to SQL Server and control features. Copy the example and customize values like server, database, credentials, and feature toggles.

cp .env.example .env

Run the MCP server with your client

You connect a client by running the server locally with Node. Use the exact command and path shown to start the MCP server so your client can attach and interact with the virtual filesystem and SP lifecycle tools.

node /absolute/path/to/sql-server-mcp/dist/index.js

Example configuration for an MCP client (Claude-style setup)

The following snippet shows how to configure an MCP client to run the MSSQL MCP Server locally. Replace the absolute path with your actual build output path and provide real connection values.

{
  "mcpServers": {
    "mssql": {
      "command": "node",
      "args": ["/absolute/path/to/sql-server-mcp/dist/index.js"],
      "env": {
        "DB_SERVER": "localhost",
        "DB_DATABASE": "MyDatabase",
        "DB_USER": "sa",
        "DB_PASSWORD": "YourPassword",
        "ENABLE_WRITE_OPERATIONS": "true",
        "ENABLE_SP_MODIFICATIONS": "true"
      }
    }
  }
}

Configuration options you will adjust

Adjust these options in your environment to tailor behavior for your environment and security requirements. Typical settings include enabling or disabling write operations, requiring explicit transactions for modifications, setting row limits, and defining the draft schema for testing SPs.

Usage workflows

Draft → Test → Deploy → Rollback workflow for stored procedures helps you manage changes safely. Draft SPs go into a separate schema for testing, where you can run tests with parameters, validate results, and then deploy to production with automatic backups if enabled.

Security and safety

Reliability is enhanced through SQL validation, parameterized queries to prevent injection, row limits on data-modifying statements, and automatic transaction timeouts with audit logging.

Troubleshooting

If you encounter connection failures or permission issues, verify that the configured DB_SERVER, DB_DATABASE, DB_USER, and DB_PASSWORD are correct and that the MCP server process has network access to the SQL Server instance. Check that write operations are enabled if you plan to modify data or SPs.

Notes on testing and development

For a full test environment, you can run the included test harness that spins up a SQL Server container with predefined schemas and test data. Use the provided test scripts to validate connectivity and feature coverage before deploying to production.

Project structure and concepts

The server exposes a virtual filesystem perspective of database objects, supports discovery and schema inspection, and provides a lifecycle for stored procedures with version history and rollback capabilities.

Available tools

Discovery & Schema

List and inspect database objects, search stored procedures, fetch table schemas, analyze dependencies, and view performance statistics from the plan cache.

Execution

Safely execute write operations with validation and transaction awareness.

Transactions

Start, commit, and rollback transactions with timeout protection.

Stored Procedure Management

Draft, test, deploy, rollback, and version history for SPs.

Security

SQL validation, parameterization, row limits, and audit tracking.