# mssql MCP server

> Allows AI agents to safely query Microsoft SQL Server with read-only defaults, AST validation, and transaction rollback support.

- Repository: https://github.com/codegiveness/mssql-mcp
- Page: https://hostedmcp.org/servers/codegiveness/mssql-mcp
- Transport: stdio
- Stars: 7
- License: MIT

## Install

### Claude Code

```sh
claude mcp add mssql-mcp -- npx -y @codegiveness/mssql-mcp
```

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

```json
{
  "mcpServers": {
    "mssql-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@codegiveness/mssql-mcp"
      ]
    }
  }
}
```

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

```json
{
  "servers": {
    "mssql-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@codegiveness/mssql-mcp"
      ]
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"mssql-mcp","type":"stdio","command":"npx","args":["-y","@codegiveness/mssql-mcp"]}'
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "mssql-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@codegiveness/mssql-mcp"
      ]
    }
  }
}
```

### Codex

```sh
codex mcp add mssql-mcp -- npx -y @codegiveness/mssql-mcp
```

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.mssql-mcp]
command = "npx"
args = ["-y", "@codegiveness/mssql-mcp"]
```

### Gemini CLI

```sh
gemini mcp add -s user mssql-mcp npx -- -y @codegiveness/mssql-mcp
```

### Gemini settings.json (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "mssql-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@codegiveness/mssql-mcp"
      ]
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `MSSQL_ACCESS_MODE` | no | no |  |
| `MSSQL_CONNECTION_STRING` | no | no |  |

## Tools (18)

- `list_databases`
- `list_schemas`
- `list_objects`
- `get_object_details`
- `execute_sql`
- `explain_query`
- `analyze_indexes`
- `get_top_queries`
- `analyze_db_health`
- `database`
- `schema`
- `type`
- `limit`
- `name`
- `sql`
- `format`
- `query`
- `order_by`

## FAQ

### Is the server secure by default?

Yes, the server runs in Restricted mode (read-only) by default to ensure safety.

### How do I provide my database credentials?

Secrets should be passed via the MSSQL_CONNECTION_STRING environment variable rather than command-line arguments.

### Does it support Windows Integrated Authentication?

Yes, Windows Integrated Authentication is supported, though Entra authentication has been removed.

### How can I verify my connection is working?

You can run the validation command to check if the connection is successful.
