db

dbhub

Universal database MCP server supporting mainstream databases.

Publisherdbhub
Submitted date4/13/2025

DBHub: Bridging LLMs and Databases with the Model Context Protocol

DBHub is a versatile database gateway meticulously engineered to implement the Model Context Protocol (MCP) server interface. This strategic implementation empowers MCP-compatible clients with the ability to seamlessly connect to and explore a diverse range of databases, unlocking new possibilities for AI-driven data interaction.

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

Interactive Demo: SSE Endpoint

Experience DBHub in action through our live demo SSE endpoint: https://demo.dbhub.ai/sse. This endpoint is pre-configured with a sample employee database, allowing you to immediately test its capabilities with tools like Cursor or the MCP Inspector.

mcp-inspector

Comprehensive Support Matrix

DBHub boasts an extensive support matrix, ensuring compatibility and feature parity across various database systems.

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

Streamlined Installation

DBHub offers flexible installation options to suit your environment.

Docker Deployment

Leverage Docker for containerized deployment:

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

Install and run DBHub using 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 pre-configured SQLite database named "employee" containing tables for employees, departments, salaries, and more.

Integration with Claude Desktop

claude-desktop

  • Claude Desktop exclusively supports the stdio transport (see discussion).
// 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:[email protected]: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"] } } }

Integration with Cursor

cursor

  • Cursor supports both stdio and sse transports.
  • Refer to the official Cursor MCP guide and ensure you are using Agent mode.

Getting Started

Database Connection Configuration

DBHub can be launched in demo mode with a sample employee database for initial exploration:

npx @bytebase/dbhub --demo

For connecting to real databases, a Database Source Name (DSN) is mandatory. The DSN can be provided via:

  • Command line argument (highest precedence):

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

    export DSN="postgres://user:password@localhost:5432/dbname?sslmode=disable" npx @bytebase/dbhub
  • Environment file (lowest precedence):

    • 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 DBHub within Docker, use host.docker.internal instead of localhost to connect to databases running on your host machine. Example: mysql://user:[email protected]: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, sqlite:C:/Users/YourName/data/database.db (windows) or sqlite::memory:

SQL Server

Extra query parameters:

authentication

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

Transport Options

  • stdio (default): Ideal for direct integration with tools like Claude Desktop.

    npx @bytebase/dbhub --transport stdio --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
  • sse: Suited for browser-based and network clients.

    npx @bytebase/dbhub --transport sse --port 5678 --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"

Command-Line Arguments

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 utilizes an in-memory SQLite database pre-loaded with the sample employee database, featuring 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 Workflow

  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"

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

Star History

Star History Chart

Visit More

View All