MCP HubMCP Hub
bytebase

dbhub

by: bytebase

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

247created 09/03/2025
Visit
database
universal

πŸ“ŒOverview

Purpose: To provide a universal database gateway that enables MCP-compatible clients to connect to and explore various databases seamlessly.

Overview: DBHub implements the Model Context Protocol (MCP) server interface, allowing for versatile database integration. It connects multiple database systems such as PostgreSQL, MySQL, SQL Server, and SQLite, providing a unified way to interact with diverse data sources.

Key Features:

  • Multi-Database Support: DBHub supports multiple database systems, allowing users to seamlessly query and manage data from different sources through a single gateway.

  • Transport Modes: Offers various transport options, including stdio for command line integration and sse for browser-based clients, enhancing flexibility according to user needs.

  • Command Capabilities: Features commands for executing queries, generating SQL, and explaining database elements, thus providing comprehensive data management and exploration tools.


DBHub

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        |
 |                  |    |              |    |                  |
 |                  |    |              +--->+    MariaDB       |
 |                  |    |              |    |                  |
 +------------------+    +--------------+    +------------------+
      MCP Clients           MCP Server             Databases

Demo SSE Endpoint

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

Supported Matrix

Database Resources

Resource NameURI FormatPostgreSQLMySQLMariaDBSQL ServerSQLite
schemasdb://schemasβœ…βœ…βœ…βœ…βœ…
tables_in_schemadb://schemas/{schemaName}/tablesβœ…βœ…βœ…βœ…βœ…
table_structure_in_schemadb://schemas/{schemaName}/tables/{tableName}βœ…βœ…βœ…βœ…βœ…
indexes_in_tabledb://schemas/{schemaName}/tables/{tableName}/indexesβœ…βœ…βœ…βœ…βœ…
procedures_in_schemadb://schemas/{schemaName}/proceduresβœ…βœ…βœ…βœ…βŒ
procedure_details_in_schemadb://schemas/{schemaName}/procedures/{procedureName}βœ…βœ…βœ…βœ…βŒ

Database Tools

ToolCommand NamePostgreSQLMySQLMariaDBSQL ServerSQLite
Execute Queryrun_queryβœ…βœ…βœ…βœ…βœ…
List Connectorslist_connectorsβœ…βœ…βœ…βœ…βœ…

Prompt Capabilities

PromptCommand NamePostgreSQLMySQLMariaDBSQL ServerSQLite
Generate SQLgenerate_sqlβœ…βœ…βœ…βœ…βœ…
Explain DB Elementsexplain_dbβœ…βœ…βœ…βœ…βœ…

Installation

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

# 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, salaries, and more.

Claude Desktop

  • Claude Desktop only supports stdio transport.
// 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"]
    }
  }
}

Cursor

  • Cursor supports both stdio and sse.
  • Follow the Cursor MCP guide and make sure to use Agent mode.

Usage

Configure your database connection

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

npx @bytebase/dbhub --demo

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

  • Command line argument (highest priority):

    npx @bytebase/dbhub --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
    
  • Environment variable (second priority):

    export DSN="postgres://user:password@localhost:5432/dbname?sslmode=disable"
    npx @bytebase/dbhub
    
  • 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
    

Warning
When running in Docker, use host.docker.internal instead of localhost to connect to databases running on your host machine. For example: mysql://user:password@host.docker.internal:3306/dbname

DBHub supports the following database connection string formats:

DatabaseDSN FormatExample
MySQLmysql://[user]:[password]@[host]:[port]/[database]mysql://user:password@localhost:3306/dbname
MariaDBmariadb://[user]:[password]@[host]:[port]/[database]mariadb://user:password@localhost:3306/dbname
PostgreSQLpostgres://[user]:[password]@[host]:[port]/[database]postgres://user:password@localhost:5432/dbname?sslmode=disable
SQL Serversqlserver://[user]:[password]@[host]:[port]/[database]sqlserver://user:password@localhost:1433/dbname
SQLitesqlite:///[path/to/file] or sqlite::memory:sqlite:///path/to/database.db or sqlite::memory:

SQL Server Extra

Extra query parameters:

  • authentication=azure-active-directory-access-token - Only applicable when running from Azure.

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

OptionDescriptionDefault
demoRun in demo mode with sample employee databasefalse
dsnDatabase connection stringRequired if not in demo mode
transportTransport mode: stdio or ssestdio
portHTTP 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, salaries, department employees, and department managers. The sample database includes SQL scripts for table creation, data loading, and testing.

Development

  1. Install dependencies:

    pnpm install
    
  2. Run in development mode:

    pnpm dev
    
  3. Build for production:

    pnpm build
    pnpm start --transport stdio --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
    

Debug with MCP Inspector

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

# 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.