bytebase/dbhub

Databases

Universal database MCP server connecting to MySQL, PostgreSQL, SQL Server, SQLite, and etc.

TypeScript codebaseLocal Service

Installation

Claude Desktop

Installation Command

Configuration

// claude_desktop_config.json
{
  "mcpServers": {
    "dbhub-postgres-docker": {
      "command": "docker",
      "args": [        
        "run",        
        "-i",        
        "--rm",        
        "bytebase/dbhub",        
        "--transport",        
        "stdio",        
        "--dsn",        
        "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"]
    }
  }
}

README

bytebase/dbhub

Universal database MCP server connecting to MySQL, PostgreSQL, SQL Server, SQLite, and etc.

DBHub Logo

DBHub is a universal database gateway implementing the Model Context Protocol (MCP) server interface. This gateway allows MCP-compatible clients to connect to and explore different databases.

 +------------------+    +--------------+    +------------------+
 |                  |    |              |    |                  |
 |                  |    |              |    |                  |
 |  Claude Desktop  +--->+              +--->+    PostgreSQL    |
 |                  |    |              |    |                  |
 |      Cursor      +--->+    DBHub     +--->+    SQL Server    |
 |                  |    |              |    |                  |
 |     Other MCP    +--->+              +--->+     SQLite       |
 |      Clients     |    |              |    |                  |
 |                  |    |              +--->+     MySQL        |
 |                  |    |              |    |                  |
 |                  |    |              +--->+  Other Databases |
 |                  |    |              |    |                  |
 +------------------+    +--------------+    +------------------+
      MCP Clients           MCP Server             Databases

Demo SSE Endpoint

Permalink: Demo SSE Endpoint

https://demo.dbhub.ai/sse connects a sample employee database. You can point Cursor or MCP Inspector to it to see it in action.

MCP Inspector

Supported Matrix

Database Resources

Permalink: Database Resources

| Resource | URI Format | PostgreSQL | MySQL | SQL Server | SQLite | | --- | :-: | :-: | :-: | :-: | :-: | | Tables | db://tables | ✅ | ✅ | ✅ | ✅ | | Schema | db://schema/{tableName} | ✅ | ✅ | ✅ | ✅ |

Database Tools

Permalink: Database Tools

| Tool | Command Name | PostgreSQL | MySQL | SQL Server | SQLite | | --- | :-: | :-: | :-: | :-: | :-: | | Execute Query | run_query | ✅ | ✅ | ✅ | ✅ | | List Connectors | list_connectors | ✅ | ✅ | ✅ | ✅ |

Prompt Capabilities

Permalink: Prompt Capabilities

| Prompt | Command Name | PostgreSQL | MySQL | SQL Server | SQLite | | --- | :-: | :-: | :-: | :-: | :-: | | Generate SQL | generate_sql | ✅ | ✅ | ✅ | ✅ | | Explain DB Elements | explain_db | ✅ | ✅ | ✅ | ✅ |

Installation

Permalink: Installation

Docker

Permalink: Docker

# PostgreSQL example
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 with sample employee database
docker run --rm --init \
   --name dbhub \
   --publish 8080:8080 \
   bytebase/dbhub \
   --transport sse \
   --port 8080 \
   --demo

NPM

Permalink: NPM

# PostgreSQL example
npx @bytebase/dbhub --transport sse --port 8080 --dsn "postgres://user:password@localhost:5432/dbname"
# Demo mode with sample employee database
npx @bytebase/dbhub --transport sse --port 8080 --demo

Note: The demo mode includes a bundled SQLite sample "employee" database with tables for employees, departments, and salaries.

Claude Desktop

Permalink: Claude Desktop

Claude Desktop

// 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"]
    }
  }
}

Cursor

Permalink: Cursor

Cursor

Usage

Permalink: Usage

Configure your database connection

Permalink: Configure your database connection

You can use DBHub in demo mode with a sample employee database for testing:

pnpm dev --demo

For real databases, a Database Source Name (DSN) is required. You can provide this in several ways:

  • Command line argument (highest priority):
pnpm dev --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
  • Environment variable (second priority):
export DSN="postgres://user:password@localhost:5432/dbname?sslmode=disable"
pnpm dev
  • Environment file (third priority):

    • For development: Create .env.local with your DSN
    • For production: Create .env with your DSN
DSN=postgres://user:password@localhost:5432/dbname?sslmode=disable

DBHub supports the following database connection string formats:

| Database | DSN Format | Example | | --- | --- | --- | | PostgreSQL | postgres://[user]:[password]@[host]:[port]/[database] | postgres://user:password@localhost:5432/dbname?sslmode=disable | | SQLite | sqlite:///[path/to/file] or sqlite::memory: | sqlite:///path/to/database.db or sqlite::memory: | | SQL Server | sqlserver://[user]:[password]@[host]:[port]/[database] | sqlserver://user:password@localhost:1433/dbname | | MySQL | mysql://[user]:[password]@[host]:[port]/[database] | mysql://user:password@localhost:3306/dbname |

Transport

Permalink: Transport

  • stdio (default) - for direct integration with tools like Claude Desktop:
npx @bytebase/dbhub --transport stdio --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
  • sse
  • for browser and network clients:
npx @bytebase/dbhub --transport sse --port 5678 --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"

Command line options

Permalink: Command line options

| Option | Description | Default | | :-- | :-- | :-- | | demo | Run in demo mode with sample employee database | false | | dsn | Database connection string | Required if not in demo mode | | transport | Transport mode: stdio or sse | stdio | | port | HTTP server port (only applicable when using --transport=sse) | 8080 |

The demo mode uses an in-memory SQLite database loaded with the sample employee database that includes tables for employees, departments, titles, and salaries.

Development

Permalink: Development

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

Debug with MCP Inspector

Permalink: Debug with MCP Inspector

stdio

Permalink: stdio

# PostgreSQL example
TRANSPORT=stdio DSN="postgres://user:password@localhost:5432/dbname?sslmode=disable" npx @modelcontextprotocol/inspector node /path/to/dbhub/dist/index.js

SSE

Permalink: SSE

# Start DBHub with SSE transport
pnpm dev --transport=sse --port=8080

# Start the MCP Inspector in another terminal
npx @modelcontextprotocol/inspector

Connect to the DBHub server /sse endpoint

About

Universal database MCP server connecting to MySQL, PostgreSQL, SQL Server, SQLite, and etc.

Topics

mysql postgres database ai sqlite mcp cursor sqlserver claude anthropic claude-ai cursorai mcp-server

Resources

Readme

License

MIT license

Activity