# SQL Server DBA (read-only)

> SQL Server DBA (read-only) is an open-source MCP server for databases. Read-only MCP server giving AI assistants DBA-style health checks for SQL Server. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Pricing:** Open source
- **Platforms:** CLI, macOS, Windows, Linux, Self-hosted
- **Repository:** https://github.com/shadow-dba/mssql-dba-mcp
- **MCP Registry name:** io.github.shadow-dba/mssql-dba-mcp
- **Categories:** [databases](https://ai-powered.com/categories/databases)
- **Listing updated:** 2026-11-27

## About

Connects AI coding assistants and chat clients to a SQL Server instance through 42 tools that inspect it the way a database administrator would. Covered areas include wait statistics, slow queries and their cached plans, blocking, index usage, backup status, CHECKDB history, SQL Agent jobs, the error log and instance configuration.

Every tool reads system views and DMVs, and the server refuses to start under a sysadmin or db_owner login. A lexer also vets the one free-form query tool so that only a single SELECT or WITH statement gets through. The AI can propose an index, a setting or a script, but a person decides whether to run it.

The server is aimed at DBAs and developers who want an assistant to triage performance problems or review server hygiene without giving it write access. Table row data stays out of reach by default; granting it is a separate, optional step described in the documentation.

## Features

- **Health check tools:** Version, wait stats, memory, I/O latency, TempDB and storage checks in one pass.
- **Query performance analysis:** Ranks top queries by CPU, reads, spills and duration and returns cached plan XML.
- **Live blocking view:** Shows active requests, blocked sessions and the sessions blocking them.
- **Index and schema review:** Reports unused or fragmented indexes, missing index suggestions, untrusted keys and risky column types.
- **Backup and CHECKDB status:** Lists latest backups per database, last good CHECKDB and suspect pages.
- **Agent job monitoring:** Reviews SQL Agent jobs, schedules, recent failures and alert configuration.
- **Enforced read-only access:** Startup check rejects admin logins and a SQL-level lexer blocks writes in the free-form query tool.

## Good for

- Running a routine health check on a SQL Server instance from an AI assistant
- Diagnosing why a server is slow right now by reviewing waits and blocking
- Finding unused or missing indexes on a specific table before a tuning session
- Confirming that backups and CHECKDB runs are current across databases
- Reviewing SQL Agent jobs that failed in the past week

## Install

### Claude Code: Add with the CLI (Terminal)

```sh
claude mcp add mssql-dba-mcp --env DB_AUTH_TYPE='<DB_AUTH_TYPE>' --env DB_HOST='<DB_HOST>' --env DB_NAME='<DB_NAME>' --env DB_USER='<DB_USER>' --env DB_PASSWORD='<DB_PASSWORD>' -- npx -y @shadow-dba/mssql-dba-mcp
```

Add --scope user to use it in every project, or --scope project to share it in .mcp.json.

### Claude Code: Or share it with your project (.mcp.json)

```json
{
  "mcpServers": {
    "mssql-dba-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@shadow-dba/mssql-dba-mcp"
      ],
      "env": {
        "DB_AUTH_TYPE": "<DB_AUTH_TYPE>",
        "DB_HOST": "<DB_HOST>",
        "DB_NAME": "<DB_NAME>",
        "DB_USER": "<DB_USER>",
        "DB_PASSWORD": "<DB_PASSWORD>"
      }
    }
  }
}
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "mssql-dba-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@shadow-dba/mssql-dba-mcp"
      ],
      "env": {
        "DB_AUTH_TYPE": "<DB_AUTH_TYPE>",
        "DB_HOST": "<DB_HOST>",
        "DB_NAME": "<DB_NAME>",
        "DB_USER": "<DB_USER>",
        "DB_PASSWORD": "<DB_PASSWORD>"
      }
    }
  }
}
```

Settings → Developer → Edit Config, then quit and reopen Claude Desktop.

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

```json
{
  "mcpServers": {
    "mssql-dba-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@shadow-dba/mssql-dba-mcp"
      ],
      "env": {
        "DB_AUTH_TYPE": "<DB_AUTH_TYPE>",
        "DB_HOST": "<DB_HOST>",
        "DB_NAME": "<DB_NAME>",
        "DB_USER": "<DB_USER>",
        "DB_PASSWORD": "<DB_PASSWORD>"
      }
    }
  }
}
```

Use .cursor/mcp.json in a project to share it with the project.

### VS Code (~/.copilot/mcp-config.json)

```json
{
  "mcpServers": {
    "mssql-dba-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@shadow-dba/mssql-dba-mcp"
      ],
      "env": {
        "DB_AUTH_TYPE": "<DB_AUTH_TYPE>",
        "DB_HOST": "<DB_HOST>",
        "DB_NAME": "<DB_NAME>",
        "DB_USER": "<DB_USER>",
        "DB_PASSWORD": "<DB_PASSWORD>"
      }
    }
  }
}
```

Or put the same entry in .mcp.json at your workspace root to share it.

### Codex: Add with the CLI (Terminal)

```sh
codex mcp add mssql-dba-mcp --env DB_AUTH_TYPE='<DB_AUTH_TYPE>' --env DB_HOST='<DB_HOST>' --env DB_NAME='<DB_NAME>' --env DB_USER='<DB_USER>' --env DB_PASSWORD='<DB_PASSWORD>' -- npx -y @shadow-dba/mssql-dba-mcp
```

### Codex: Or add to config.toml (~/.codex/config.toml)

```toml
[mcp_servers.mssql-dba-mcp]
command = "npx"
args = ["-y", "@shadow-dba/mssql-dba-mcp"]
env = { DB_AUTH_TYPE = "<DB_AUTH_TYPE>", DB_HOST = "<DB_HOST>", DB_NAME = "<DB_NAME>", DB_USER = "<DB_USER>", DB_PASSWORD = "<DB_PASSWORD>" }
```

### Gemini CLI and Antigravity: Gemini CLI (~/.gemini/settings.json)

```json
{
  "mcpServers": {
    "mssql-dba-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@shadow-dba/mssql-dba-mcp"
      ],
      "env": {
        "DB_AUTH_TYPE": "<DB_AUTH_TYPE>",
        "DB_HOST": "<DB_HOST>",
        "DB_NAME": "<DB_NAME>",
        "DB_USER": "<DB_USER>",
        "DB_PASSWORD": "<DB_PASSWORD>"
      }
    }
  }
}
```

Or run: gemini mcp add -s user -e DB_AUTH_TYPE='<DB_AUTH_TYPE>' -e DB_HOST='<DB_HOST>' -e DB_NAME='<DB_NAME>' -e DB_USER='<DB_USER>' -e DB_PASSWORD='<DB_PASSWORD>' mssql-dba-mcp npx -- -y @shadow-dba/mssql-dba-mcp

### Gemini CLI and Antigravity: Antigravity (~/.gemini/config/mcp_config.json)

```json
{
  "mcpServers": {
    "mssql-dba-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@shadow-dba/mssql-dba-mcp"
      ],
      "env": {
        "DB_AUTH_TYPE": "<DB_AUTH_TYPE>",
        "DB_HOST": "<DB_HOST>",
        "DB_NAME": "<DB_NAME>",
        "DB_USER": "<DB_USER>",
        "DB_PASSWORD": "<DB_PASSWORD>"
      }
    }
  }
}
```

Use .agents/mcp_config.json to add it to one workspace only.

### Devin Desktop (~/.config/devin/mcp_config.json)

```json
{
  "mcpServers": {
    "mssql-dba-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@shadow-dba/mssql-dba-mcp"
      ],
      "env": {
        "DB_AUTH_TYPE": "<DB_AUTH_TYPE>",
        "DB_HOST": "<DB_HOST>",
        "DB_NAME": "<DB_NAME>",
        "DB_USER": "<DB_USER>",
        "DB_PASSWORD": "<DB_PASSWORD>"
      }
    }
  }
}
```

On Windows the file is %APPDATA%\\devin\\mcp_config.json. Use .devin/mcp_config.json to share it with a project.

### Cline (cline_mcp_settings.json)

```json
{
  "mcpServers": {
    "mssql-dba-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@shadow-dba/mssql-dba-mcp"
      ],
      "env": {
        "DB_AUTH_TYPE": "<DB_AUTH_TYPE>",
        "DB_HOST": "<DB_HOST>",
        "DB_NAME": "<DB_NAME>",
        "DB_USER": "<DB_USER>",
        "DB_PASSWORD": "<DB_PASSWORD>"
      }
    }
  }
}
```

Open it from the MCP Servers icon → Configure → Configure MCP Servers.

### Zed (Zed settings.json)

```json
{
  "context_servers": {
    "mssql-dba-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@shadow-dba/mssql-dba-mcp"
      ],
      "env": {
        "DB_AUTH_TYPE": "<DB_AUTH_TYPE>",
        "DB_HOST": "<DB_HOST>",
        "DB_NAME": "<DB_NAME>",
        "DB_USER": "<DB_USER>",
        "DB_PASSWORD": "<DB_PASSWORD>"
      }
    }
  }
}
```

Open it with zed: open settings file. Merge context_servers into the settings you already have.

### JetBrains AI Assistant and Junie: AI Assistant (Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add)

```json
{
  "mcpServers": {
    "mssql-dba-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@shadow-dba/mssql-dba-mcp"
      ],
      "env": {
        "DB_AUTH_TYPE": "<DB_AUTH_TYPE>",
        "DB_HOST": "<DB_HOST>",
        "DB_NAME": "<DB_NAME>",
        "DB_USER": "<DB_USER>",
        "DB_PASSWORD": "<DB_PASSWORD>"
      }
    }
  }
}
```

The AI Assistant docs only show command and args. If the env block is ignored, use Junie for this server.

### JetBrains AI Assistant and Junie: Junie (~/.junie/mcp/mcp.json)

```json
{
  "mcpServers": {
    "mssql-dba-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@shadow-dba/mssql-dba-mcp"
      ],
      "env": {
        "DB_AUTH_TYPE": "<DB_AUTH_TYPE>",
        "DB_HOST": "<DB_HOST>",
        "DB_NAME": "<DB_NAME>",
        "DB_USER": "<DB_USER>",
        "DB_PASSWORD": "<DB_PASSWORD>"
      }
    }
  }
}
```

Use .junie/mcp/mcp.json to share it with a project.

### Kiro (~/.kiro/settings/mcp.json)

```json
{
  "mcpServers": {
    "mssql-dba-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@shadow-dba/mssql-dba-mcp"
      ],
      "env": {
        "DB_AUTH_TYPE": "<DB_AUTH_TYPE>",
        "DB_HOST": "<DB_HOST>",
        "DB_NAME": "<DB_NAME>",
        "DB_USER": "<DB_USER>",
        "DB_PASSWORD": "<DB_PASSWORD>"
      }
    }
  }
}
```

Use .kiro/settings/mcp.json to add it to one workspace only.

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

```json
{
  "mcpServers": {
    "mssql-dba-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@shadow-dba/mssql-dba-mcp"
      ],
      "env": {
        "DB_AUTH_TYPE": "<DB_AUTH_TYPE>",
        "DB_HOST": "<DB_HOST>",
        "DB_NAME": "<DB_NAME>",
        "DB_USER": "<DB_USER>",
        "DB_PASSWORD": "<DB_PASSWORD>"
      }
    }
  }
}
```

## Tools

From the tool list in its README, going by the names, 1 of 12 tools changes data; 10 names don't say. From the server's own tool labels and tool names; not verified by us.

- `mssql_server_version`: Version, edition, patch level, collation, HADR, licensing.
- `mssql_wait_stats`: Top wait types, optionally sampled over a window.
- `mssql_top_queries`: Top queries by CPU, reads, memory grant, spills, duration or executions.
- `mssql_run_select` (name suggests: changes): One read-only SELECT written by the AI, max 500 rows.
- `mssql_execution_plan`: Cached plan XML for a plan handle.
- `mssql_running_requests`: Active requests with CPU, reads, waits and blocking.
- `mssql_blocking`: Blocked sessions and their blockers.
- `mssql_recent_backups`: Latest Full, Diff and Log backup per database.
- `mssql_checkdb_status` (name suggests: reads): Last good CHECKDB per database and suspect pages.
- `mssql_agent_failed_jobs`: Agent jobs that failed in the last 7 days.
- `mssql_db_index_health`: Index usage, fragmentation, fill factor and maintenance script per index.
- `mssql_db_missing_indexes`: Ranked missing-index suggestions.

## FAQ

### Can the AI change data or settings through SQL Server DBA (read-only)?

The setup script grants only view permissions and SELECT on a few msdb tables, and the server refuses to start under sysadmin, CONTROL SERVER or db_owner logins. Tools run fixed read-only SQL, and the free-form query tool rejects anything that writes or changes the session.

### Can the AI read rows from my application tables?

Not by default. The setup script does not grant row access, so the query tool works against system views and DMVs. Row access can be granted separately, and the documentation explains the data-handling implications.

### Which SQL Server versions are supported?

The README lists SQL Server 2016 and later, Azure SQL Managed Instance and Azure SQL Database. Azure SQL Database only exposes the database named in DB_NAME, and instance-level tools are unavailable there.

### How do I connect SQL Server DBA (read-only) to my MCP client?

Add the server with npx using the @shadow-dba/mssql-dba-mcp package and set the database host, name, read-only login and password as environment variables. Claude Code, Claude Desktop, Cursor and VS Code are covered by the README examples.

### Is SQL Server DBA (read-only) free?

Yes. SQL Server DBA (read-only) is open source, so you can use and self-host it for free.

### How do I add SQL Server DBA (read-only) to Claude Code?

Run this command in your terminal: claude mcp add mssql-dba-mcp --env DB_AUTH_TYPE='<DB_AUTH_TYPE>' --env DB_HOST='<DB_HOST>' --env DB_NAME='<DB_NAME>' --env DB_USER='<DB_USER>' --env DB_PASSWORD='<DB_PASSWORD>' -- npx -y @shadow-dba/mssql-dba-mcp

### What are the best alternatives to SQL Server DBA (read-only)?

The closest alternatives to SQL Server DBA (read-only) are SQL Server, MCP Sql Querystore, mssql-readonly-mcp, SqlServerMcp and SQL Server MCP (Windows).

## Where this comes from

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

## Alternatives

- [SQL Server](https://ai-powered.com/mcp/sql-server): SQL Server is an open-source MCP server for databases.
- [MCP Sql Querystore](https://ai-powered.com/mcp/mcp-sql-querystore): MCP Sql Querystore is an open-source MCP server for databases.
- [mssql-readonly-mcp](https://ai-powered.com/mcp/mssql-readonly-mcp): mssql-readonly-mcp is an open-source MCP server for databases.
- [SqlServerMcp](https://ai-powered.com/mcp/sqlservermcp): SqlServerMcp is an open-source MCP server for databases.
- [SQL Server MCP (Windows)](https://ai-powered.com/mcp/sql-server-mcp-windows): SQL Server MCP (Windows) is an open-source MCP server for databases.
- [JDBC MCP Server](https://ai-powered.com/mcp/jdbc-mcp-server): JDBC MCP Server is an open-source MCP server for databases.
- [Elekto MCP for SQL Server](https://ai-powered.com/mcp/elekto-mcp-for-sql-server): Elekto MCP for SQL Server is an open-source MCP server for databases.
- [AI2SQL](https://ai-powered.com/mcp/ai2sql): AI2SQL is a freemium MCP server for databases.

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