Skip to main content

CLI

For local database connections, use stdio transport:
claude mcp add --transport stdio dbhub -- npx @bytebase/dbhub --transport stdio --dsn "postgres://user:password@localhost:5432/dbname"
The -- separates Claude’s flags from DBHub’s arguments. Everything after -- is the DBHub command.

Project Configuration

For project-specific database connections shared with your team, create .mcp.json in your project root.
.mcp.json
{
  "mcpServers": {
    "dbhub": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "@bytebase/dbhub",
        "--transport",
        "stdio",
        "--dsn",
        "postgres://user:password@localhost:5432/dbname"
      ]
    }
  }
}
Use environment variable expansion for sensitive values:
.mcp.json
{
  "mcpServers": {
    "dbhub": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "@bytebase/dbhub",
        "--transport",
        "stdio",
        "--dsn",
        "${DATABASE_URL}"
      ]
    }
  }
}

User Configuration

For personal configuration across all projects, add to your user scope:
claude mcp add --scope user dbhub -- npx @bytebase/dbhub --transport stdio --dsn "postgres://user:password@localhost:5432/dbname"
Or manually edit the user configuration file:
Edit ~/.claude/settings.json and add to the mcpServers section.

Using DBHub

Start Claude Code in your project directory:
claude
Verify DBHub is loaded:
/mcp

References