DBHub

by bytebase
MIT License
12
403
  • Linux
  • Apple

Integrations

  • Provides Docker container deployment options for running the DBHub server with configurable database connections and transport options.

  • Supports connecting to DuckDB databases to explore tables, access schema information, and perform read-only SQL queries with safety measures.

  • Provides access to MySQL databases for browsing tables, viewing schema information, and executing read-only SQL queries with safety protections.

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

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.

Supported Matrix

Database Resources

Resource NameURI FormatPostgreSQLMySQLMariaDBSQL ServerSQLiteOracle
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 ServerSQLiteOracle
Execute SQLexecute_sql
List Connectorslist_connectors

Prompt Capabilities

PromptCommand NamePostgreSQLMySQLMariaDBSQL ServerSQLiteOracle
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
# Oracle example docker run --rm --init \ --name dbhub \ --publish 8080:8080 \ bytebase/dbhub \ --transport sse \ --port 8080 \ --dsn "oracle://username:password@localhost:1521/service_name"
# Oracle example with thick mode for connecting to 11g or older docker run --rm --init \ --name dbhub \ --publish 8080:8080 \ bytebase/dbhub-oracle-thick \ --transport sse \ --port 8080 \ --dsn "oracle://username:password@localhost:1521/service_name"

NPM

# PostgreSQL example npx @bytebase/dbhub --transport sse --port 8080 --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
# 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_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

Usage

SSL Connections

You can specify the SSL mode using the sslmode parameter in your DSN string:

Databasesslmode=disablesslmode=requireDefault SSL Behavior
PostgreSQLCertificate verification
MySQLCertificate verification
MariaDBCertificate verification
SQL ServerCertificate verification
OracleN/A (use Oracle client config)
SQLiteN/A (file-based)

SSL Mode Options:

  • sslmode=disable: All SSL/TLS encryption is turned off. Data is transmitted in plaintext.
  • sslmode=require: Connection is encrypted, but the server's certificate is not verified. This provides protection against packet sniffing but not against man-in-the-middle attacks. You may use this for trusted self-signed CA.

Without specifying sslmode, most databases default to certificate verification, which provides the highest level of security.

Example usage:

# Disable SSL postgres://user:password@localhost:5432/dbname?sslmode=disable # Require SSL without certificate verification postgres://user:password@localhost:5432/dbname?sslmode=require # Standard SSL with certificate verification (default) postgres://user:password@localhost:5432/dbname

Read-only Mode

You can run DBHub in read-only mode, which restricts SQL query execution to read-only operations:

# Enable read-only mode npx @bytebase/dbhub --readonly --dsn "postgres://user:password@localhost:5432/dbname"

In read-only mode, only readonly SQL operations are allowed.

This provides an additional layer of security when connecting to production databases.

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?sslmode=disable
MariaDBmariadb://[user]:[password]@[host]:[port]/[database]mariadb://user:password@localhost:3306/dbname?sslmode=disable
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?sslmode=disable
SQLitesqlite:///[path/to/file] or sqlite::memory:sqlite:///path/to/database.db, sqlite:C:/Users/YourName/data/database.db (windows) or sqlite::memory:
Oracleoracle://[user]:[password]@[host]:[port]/[service_name]oracle://username:password@localhost:1521/service_name?sslmode=disable
Oracle

If you see the error "NJS-138: connections to this database server version are not supported by node-oracledb in Thin mode", you need to use Thick mode as described below.

Docker

Use bytebase/dbhub-oracle-thick instead of bytebase/dbhub docker image.

npx
  1. Download and install Oracle Instant Client for your platform
  2. Set the ORACLE_LIB_DIR environment variable to the path of your Oracle Instant Client:
# Set environment variable to Oracle Instant Client directory export ORACLE_LIB_DIR=/path/to/instantclient_19_8 # Then run DBHub npx @bytebase/dbhub --dsn "oracle://username:password@localhost:1521/service_name"
SQL Server

Extra query parameters:

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

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
readonlyRestrict SQL execution to read-only operationsfalse

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

Contributors

Star History

-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

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

  1. Supported Matrix
    1. Database Resources
    2. Database Tools
    3. Prompt Capabilities
  2. Installation
    1. Docker
    2. NPM
    3. Claude Desktop
    4. Cursor
  3. Usage
    1. SSL Connections
    2. Read-only Mode
    3. Configure your database connection
    4. Transport
    5. Command line options
  4. Development
    1. Debug with MCP Inspector
  5. Contributors
    1. Star History

      Related MCP Servers

      • -
        security
        F
        license
        -
        quality
        An MCP server that provides safe, read-only access to SQLite databases through MCP. This server is built with the FastMCP framework, which enables LLMs to explore and query SQLite databases with built-in safety features and query validation.
        Last updated -
        21
        Python
      • -
        security
        A
        license
        -
        quality
        MCP to access any database accessible via JDBC such as Postgres, Oracle, mysql, mariadb, sqlite etc.
        Last updated -
        103
        Apache 2.0
      • A
        security
        A
        license
        A
        quality
        An MCP server that provides read-only access to MySQL databases.
        Last updated -
        4
        695
        17
        JavaScript
        MIT License
        • Linux
        • Apple

      View all related MCP servers

      ID: a01xnguu8x