# DBHub MCP server

> Connects AI clients to PostgreSQL, MySQL, SQL Server, Oracle, MariaDB, and SQLite to explore schemas and execute SQL queries.

- Repository: https://github.com/bytebase/dbhub
- Page: https://hostedmcp.org/servers/bytebase/dbhub
- Transport: stdio
- Stars: 3843
- License: MIT
- Latest version: 1.6.1

## Install

### Claude Code

```sh
claude mcp add --env DB_PASSWORD=<YOUR_DB_PASSWORD> --env DSN=<YOUR_DSN> --env SSH_PASSPHRASE=<YOUR_SSH_PASSPHRASE> --env SSH_PASSWORD=<YOUR_SSH_PASSWORD> dbhub -- npx -y @bytebase/dbhub
```

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

```json
{
  "mcpServers": {
    "dbhub": {
      "command": "npx",
      "args": [
        "-y",
        "@bytebase/dbhub"
      ],
      "env": {
        "DB_PASSWORD": "<YOUR_DB_PASSWORD>",
        "DSN": "<YOUR_DSN>",
        "SSH_PASSPHRASE": "<YOUR_SSH_PASSPHRASE>",
        "SSH_PASSWORD": "<YOUR_SSH_PASSWORD>"
      }
    }
  }
}
```

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

```json
{
  "servers": {
    "dbhub": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@bytebase/dbhub"
      ],
      "env": {
        "DB_PASSWORD": "<YOUR_DB_PASSWORD>",
        "DSN": "<YOUR_DSN>",
        "SSH_PASSPHRASE": "<YOUR_SSH_PASSPHRASE>",
        "SSH_PASSWORD": "<YOUR_SSH_PASSWORD>"
      }
    }
  }
}
```

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

```json
{
  "mcpServers": {
    "dbhub": {
      "command": "npx",
      "args": [
        "-y",
        "@bytebase/dbhub"
      ],
      "env": {
        "DB_PASSWORD": "<YOUR_DB_PASSWORD>",
        "DSN": "<YOUR_DSN>",
        "SSH_PASSPHRASE": "<YOUR_SSH_PASSPHRASE>",
        "SSH_PASSWORD": "<YOUR_SSH_PASSWORD>"
      }
    }
  }
}
```

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

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

[mcp_servers.dbhub.env]
DB_PASSWORD = "<YOUR_DB_PASSWORD>"
DSN = "<YOUR_DSN>"
SSH_PASSPHRASE = "<YOUR_SSH_PASSPHRASE>"
SSH_PASSWORD = "<YOUR_SSH_PASSWORD>"
```

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

```json
{
  "mcpServers": {
    "dbhub": {
      "command": "npx",
      "args": [
        "-y",
        "@bytebase/dbhub"
      ],
      "env": {
        "DB_PASSWORD": "<YOUR_DB_PASSWORD>",
        "DSN": "<YOUR_DSN>",
        "SSH_PASSPHRASE": "<YOUR_SSH_PASSPHRASE>",
        "SSH_PASSWORD": "<YOUR_SSH_PASSWORD>"
      }
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `DB_PASSWORD` | no | yes | Database password |
| `DSN` | no | yes | Database connection string (e.g., postgres://user:pass@host:5432/db) |
| `SSH_PASSPHRASE` | no | yes | SSH key passphrase |
| `SSH_PASSWORD` | no | yes | SSH password |
| `DB_HOST` | no | no | Database hostname |
| `DB_NAME` | no | no | Database name or SQLite file path |
| `DB_PORT` | no | no | Database port |
| `DB_TYPE` | no | no | Database type: postgres, mysql, mariadb, sqlserver, oracle, sqlite |
| `DB_USER` | no | no | Database username |
| `ID` | no | no | Instance identifier for tool names |
| `PORT` | no | no | HTTP server port (default: 8080) |
| `SSH_AUTH_SOCK` | no | no | Path to SSH agent socket |
| `SSH_HOST` | no | no | SSH server hostname |
| `SSH_KEY` | no | no | Path to SSH private key |
| `SSH_PORT` | no | no | SSH server port (default: 22) |
| `SSH_USER` | no | no | SSH username |
| `TRANSPORT` | no | no | Transport mode: stdio or http |

## FAQ

### Which databases can DBHub connect to?

DBHub connects to PostgreSQL, MySQL, SQL Server, MariaDB, Oracle, and SQLite through a single interface.

### What MCP tools does DBHub provide?

By default it loads two tools, execute_sql and search_objects, with opt-in explain_sql, health_check, and custom tools.

### Can DBHub connect to multiple databases at once?

Yes, multi-connection is supported through TOML configuration.

### Does DBHub have read-only safety controls?

Yes, it offers read-only mode, row limiting, and query timeouts to prevent runaway operations.

### How do I run DBHub?

You can start it with npx using the HTTP transport, and it is also available as a Docker image, MCP Bundle, and Claude Code plugin.
