# dbhub

> MCP Server

DBHub is a universal database gateway that implements the Model Context Protocol (MCP) server interface, enabling MCP-compatible clients to connect to and explore various databases. DBHub is a universal database

## Overview

- **Category:** Database
- **Language:** TypeScript
- **Stars:** 3360
- **Forks:** 11
- **Owner:** bytebase
- **GitHub:** https://github.com/bytebase/dbhub
- **Created:** 2025-03-09T16:36:38+00:00
- **Updated:** 2025-03-28T20:51:11+00:00
- **Source:** https://model-context-protocol.com/servers/universal-database-gateway-mcp-server

## Setup

## Setup

1.  **Docker:**
    *   PostgreSQL example:

        ```bash
        docker run --rm --init \
           --name dbhub \
           --publish 8080:8080 \
           bytebase/dbhub \
           --transport sse \
           --port 8080 \
           --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
        ```
    *   Demo mode:

        ```bash
        docker run --rm --init \
           --name dbhub \
           --publish 8080:8080 \
           bytebase/dbhub \
           --transport sse \
           --port 8080 \
           --demo
        ```

2.  **NPM:**
    *   PostgreSQL example:

        ```bash
        npx @bytebase/dbhub --transport sse --port 8080 --dsn "postgres://user:password@localhost:5432/dbname"
        ```
    *   Demo mode:

        ```bash
        npx @bytebase/dbhub --transport sse --port 8080 --demo
        ```

3.  **Claude Desktop:**
    *   Create `claude_desktop_config.json` with the following content:

        ```json
        // claude_desktop_config.json
        {
          "mcpServers": {
            "dbhub-postgres-docker": {
              "command": "docker",
              "args": [
                "run",
                "-i",
                "--rm",
                "bytebase/dbhub",
                "--transport",
                "stdio",
                "--dsn",
                // Use host.docker.internal as the host if connecting to the local db
                "postgres://user:password@host.docker.internal:5432/dbname?sslmode=disable"
              ]
            },
            "dbhub-postgres-npx": {
              "command": "npx",
              "args": [
                "-y",
                "@bytebase/dbhub",
                "--transport",
                "stdio",
                "--dsn",
                "postgres://user:password@localhost:5432/dbname?sslmode=disable"
              ]
            },
            "dbhub-demo": {
              "command": "npx",
              "args": ["-y", "@bytebase/dbhub", "--transport", "stdio", "--demo"]
            }
          }
        }
        ```

4.  **Cursor:**
    *   Follow [Cursor MCP guide](https://docs.cursor.com/context/model-context-protocol) and use [Agent](https://docs.cursor.com/chat/agent) mode.

5.  **Configure Database Connection:**
    *   Use `--demo` for a sample database or provide a DSN via command line, environment variable, or environment file.

6.  **Transport:**
    *   Use `--transport stdio` for Claude Desktop or `--transport sse` for browser and network clients.

7.  **Development:**
    *   Install dependencies: `pnpm install`
    *   Run in development mode: `pnpm dev`
    *   Build for production: `pnpm build && pnpm start --transport stdio --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"`

8.  **Debug with MCP Inspector:**
    *   For stdio: `TRANSPORT=stdio DSN="postgres://user:password@localhost:5432/dbname?sslmode=disable" npx @modelcontextprotocol/inspector node /path/to/dbhub/dist/index.js`
    *   For SSE: Start DBHub with `pnpm dev --transport=sse --port=8080` and then start MCP Inspector in another terminal with `npx @modelcontextprotocol/inspector` and connect to the `/sse` endpoint.

## Tools

## Available Tools

1.  **Database Gateway:** Implements the Model Context Protocol (MCP) server interface.
2.  **Demo SSE Endpoint:** Provides a sample employee database for testing.
3.  **Database Resources:** Exposes schemas, tables, indexes, procedures, and their details via URIs.
4.  **Database Tools:** Supports executing queries and listing connectors.
5.  **Prompt Capabilities:** Enables generating SQL and explaining database elements.
6.  **Demo Mode:** Runs with a sample employee database.
7.  **Transport Options:** Supports `stdio` and `sse` transport modes.
