# SQL Server MCP

> SQL Server MCP is an open-source MCP server for databases. Local MCP for DBAs to query many SQL Server instances, plans and indexes from one entry. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, self-hosted
- **Repository:** https://github.com/cvelasquez/mcp-sqlserver
- **MCP Registry name:** io.github.cvelasquez/mcp-sqlserver
- **Categories:** [databases](https://ai-powered.com/categories/databases), [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-11-18

## About

Where most SQL Server MCP servers take a single connection string, this one reads a connections.json that can hold dozens of instances, grouped by client or environment and reloaded without restarting the agent. Every response carries metadata naming the connection that answered, so the answer is traceable to the right client.

Beyond queries it can return table schemas, index layouts, execution plans (SHOWPLAN XML without running the query) and stored procedure source. A per-connection readOnly flag rejects writing statements, queries are capped at 1,000 rows by default (up to 10,000) and cancelled on the server when the cap is hit, with a truncation notice placed before the rows. Passwords can reference environment variables, and a connection with a missing variable is disabled with a clear message.

It supports SQL authentication, NTLM and Entra ID through the tedious driver; fully integrated authentication is not supported. A --check command tests all connections in parallel. Needs Node.js 22 or newer; MIT licensed.

## Features

- **Many connections:** One MCP entry covers every configured instance, grouped by client.
- **Hot reload:** Edit the file and call reload_connections without restarting.
- **Execution plans:** Fetch SHOWPLAN XML without running the query.
- **Read-only rail:** Mark connections readOnly to reject writing statements.
- **Row caps:** Large results are cancelled server-side and flagged as truncated.
- **Connection check:** A --check command tests every entry and exits non-zero on failure.

## Good for

- Run a query across a consultant's client databases
- Audit indexes on a slow table
- Inspect an execution plan without running it
- Read a stored procedure's source
- Check which connections broke after a password rotation

## Install

### Claude Code (Terminal)

```sh
claude mcp add mcp-sqlserver --env MSSQL_MCP_CONNECTIONS_JSON='<MSSQL_MCP_CONNECTIONS_JSON>' -- npx -y @cevelas/mcp-sqlserver
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "mcp-sqlserver": {
      "command": "npx",
      "args": [
        "-y",
        "@cevelas/mcp-sqlserver"
      ],
      "env": {
        "MSSQL_MCP_CONNECTIONS_JSON": "<MSSQL_MCP_CONNECTIONS_JSON>"
      }
    }
  }
}
```

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "mcp-sqlserver": {
      "command": "npx",
      "args": [
        "-y",
        "@cevelas/mcp-sqlserver"
      ],
      "env": {
        "MSSQL_MCP_CONNECTIONS_JSON": "<MSSQL_MCP_CONNECTIONS_JSON>"
      }
    }
  }
}
```

### VS Code (.vscode/mcp.json)

```json
{
  "servers": {
    "mcp-sqlserver": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@cevelas/mcp-sqlserver"
      ],
      "env": {
        "MSSQL_MCP_CONNECTIONS_JSON": "<MSSQL_MCP_CONNECTIONS_JSON>"
      }
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

```json
{
  "mcpServers": {
    "mcp-sqlserver": {
      "command": "npx",
      "args": [
        "-y",
        "@cevelas/mcp-sqlserver"
      ],
      "env": {
        "MSSQL_MCP_CONNECTIONS_JSON": "<MSSQL_MCP_CONNECTIONS_JSON>"
      }
    }
  }
}
```

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "mcp-sqlserver": {
      "command": "npx",
      "args": [
        "-y",
        "@cevelas/mcp-sqlserver"
      ],
      "env": {
        "MSSQL_MCP_CONNECTIONS_JSON": "<MSSQL_MCP_CONNECTIONS_JSON>"
      }
    }
  }
}
```

## Tools

- `list_connections`: List every connection, grouped
- `reload_connections`: Re-read the connections file and drop open pools
- `query`: Run a query with a row cap
- `get_schema`: Columns, types, nullability and defaults
- `get_indexes`: Indexes with key and included columns
- `get_execution_plan`: SHOWPLAN XML for a query without running it
- `get_stored_procedure`: Source of a stored procedure

## FAQ

### How do I add instances?

Edit connections.json (create one with --init) and call reload_connections.

### Can it modify data?

Not if a connection is marked readOnly, which rejects writing statements.

### Which authentication works?

SQL logins, NTLM and Entra ID; fully integrated authentication is not bundled.

### What Node version?

Node.js 22 or newer.

### Is SQL Server MCP free?

Yes. SQL Server MCP is open source, so you can use and self-host it for free.

### How do I add SQL Server MCP to Claude Code?

Run this command in your terminal: claude mcp add mcp-sqlserver --env MSSQL_MCP_CONNECTIONS_JSON='<MSSQL_MCP_CONNECTIONS_JSON>' -- npx -y @cevelas/mcp-sqlserver

### What are the best alternatives to SQL Server MCP?

The closest alternatives to SQL Server MCP are REA, Context7, Chrome DevTools MCP, Codebase Memory and GitHub.

## Where this comes from

- Description: written from the project's README.
- Install steps: from the official MCP Registry entry.

## Alternatives

- [REA](https://ai-powered.com/mcp/rea): REA is an open-source MCP server for developer tools.
- [Context7](https://ai-powered.com/mcp/context7): Context7 is a freemium MCP server for developer tools.
- [Chrome DevTools MCP](https://ai-powered.com/mcp/chrome-devtools-mcp-2): Chrome DevTools MCP is an open-source MCP server for browser automation.
- [Codebase Memory](https://ai-powered.com/mcp/codebase-memory): Codebase Memory is an open-source MCP server for knowledge and memory.
- [GitHub](https://ai-powered.com/mcp/github-2): GitHub is an open-source MCP server for developer tools.
- [Serena MCP: the IDE for your agent](https://ai-powered.com/mcp/serena-mcp-the-ide-for-your-agent): Serena MCP: the IDE for your agent is an open-source MCP server for developer tools.
- [awesome-mcp-servers](https://ai-powered.com/mcp/awesome-mcp-servers-2): awesome-mcp-servers is an open-source MCP server for developer tools.
- [XERJ](https://ai-powered.com/mcp/xerj): XERJ is an open-source MCP server for knowledge and memory.

---
Source: https://ai-powered.com/mcp/sql-server-mcp
