# SQL MCP server

> Allows an AI client to perform read-only queries and schema introspection on Postgres and SQLite databases with gated write capabilities.

- Repository: https://github.com/Abhishekkumar2021/mcp-suite
- Page: https://hostedmcp.org/servers/abhishekkumar2021/sql
- Transport: stdio
- Stars: 1
- License: MIT
- Latest version: 0.1.0

## Install

### Claude Code

```sh
claude mcp add --env 'DB_CONN_default=<YOUR_DB_CONN_default>' sql -- npx -y @abhishekmcp/sql
```

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

```json
{
  "mcpServers": {
    "sql": {
      "command": "npx",
      "args": [
        "-y",
        "@abhishekmcp/sql"
      ],
      "env": {
        "DB_CONN_default": "<YOUR_DB_CONN_default>"
      }
    }
  }
}
```

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

```json
{
  "servers": {
    "sql": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@abhishekmcp/sql"
      ],
      "env": {
        "DB_CONN_default": "<YOUR_DB_CONN_default>"
      }
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"sql","type":"stdio","command":"npx","args":["-y","@abhishekmcp/sql"],"env":{"DB_CONN_default":"<YOUR_DB_CONN_default>"}}'
```

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

```json
{
  "mcpServers": {
    "sql": {
      "command": "npx",
      "args": [
        "-y",
        "@abhishekmcp/sql"
      ],
      "env": {
        "DB_CONN_default": "<YOUR_DB_CONN_default>"
      }
    }
  }
}
```

### Codex

```sh
codex mcp add sql --env 'DB_CONN_default=<YOUR_DB_CONN_default>' -- npx -y @abhishekmcp/sql
```

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

```toml
[mcp_servers.sql]
command = "npx"
args = ["-y", "@abhishekmcp/sql"]

[mcp_servers.sql.env]
DB_CONN_default = "<YOUR_DB_CONN_default>"
```

### Gemini CLI

```sh
gemini mcp add -s user -e 'DB_CONN_default=<YOUR_DB_CONN_default>' sql npx -- -y @abhishekmcp/sql
```

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

```json
{
  "mcpServers": {
    "sql": {
      "command": "npx",
      "args": [
        "-y",
        "@abhishekmcp/sql"
      ],
      "env": {
        "DB_CONN_default": "<YOUR_DB_CONN_default>"
      }
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `DB_CONN_default` | no | yes | Connection URL for the 'default' connection (postgres://… or sqlite:/abs/path). Additional connections use DB_CONN_<name>. Carries credentials — treated as secret. |
| `DB_WRITABLE` | no | no | Set to 1 or true to enable the write tools (execute, execute_script). |
| `NOTES_DIR` | no | no |  |

## FAQ

### Which databases does the SQL server support?

The server supports querying and schema introspection for both Postgres and SQLite.

### How is the SQLite engine implemented?

The server uses the sql.js WASM engine for SQLite functionality.
