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.
1 +------------------+ +--------------+ +------------------+ 2 | | | | | | 3 | | | | | | 4 | Claude Desktop +--->+ +--->+ PostgreSQL | 5 | | | | | | 6 | Cursor +--->+ DBHub +--->+ SQL Server | 7 | | | | | | 8 | Other MCP +--->+ +--->+ SQLite | 9 | Clients | | | | | 10 | | | +--->+ MySQL | 11 | | | | | | 12 | | | +--->+ Other Databases | 13 | | | | | | 14 +------------------+ +--------------+ +------------------+ 15 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 Name | URI Format | PostgreSQL | MySQL | SQL Server | SQLite |
| --------------------------- | ------------------------------------------------------ | :--------: | :---: | :--------: | :----: |
| schemas | db://schemas
| ✅ | ✅ | ✅ | ✅ |
| tables_in_schema | db://schemas/{schemaName}/tables
| ✅ | ✅ | ✅ | ✅ |
| table_structure_in_schema | db://schemas/{schemaName}/tables/{tableName}
| ✅ | ✅ | ✅ | ✅ |
| indexes_in_table | db://schemas/{schemaName}/tables/{tableName}/indexes
| ✅ | ✅ | ✅ | ✅ |
| procedures_in_schema | db://schemas/{schemaName}/procedures
| ✅ | ✅ | ✅ | ❌ |
| procedure_details_in_schema | db://schemas/{schemaName}/procedures/{procedureName}
| ✅ | ✅ | ✅ | ❌ |
Database Tools
| Tool | Command Name | PostgreSQL | MySQL | SQL Server | SQLite |
| --------------- | ----------------- | :--------: | :---: | :--------: | :----: |
| Execute Query | run_query
| ✅ | ✅ | ✅ | ✅ |
| List Connectors | list_connectors
| ✅ | ✅ | ✅ | ✅ |
Prompt Capabilities
| Prompt | Command Name | PostgreSQL | MySQL | SQL Server | SQLite |
| ------------------- | -------------- | :--------: | :---: | :--------: | :----: |
| Generate SQL | generate_sql
| ✅ | ✅ | ✅ | ✅ |
| Explain DB Elements | explain_db
| ✅ | ✅ | ✅ | ✅ |
Installation
Docker
1# PostgreSQL example 2docker run --rm --init \ 3 --name dbhub \ 4 --publish 8080:8080 \ 5 bytebase/dbhub \ 6 --transport sse \ 7 --port 8080 \ 8 --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
1# Demo mode with sample employee database 2docker run --rm --init \ 3 --name dbhub \ 4 --publish 8080:8080 \ 5 bytebase/dbhub \ 6 --transport sse \ 7 --port 8080 \ 8 --demo
NPM
1# PostgreSQL example 2npx @bytebase/dbhub --transport sse --port 8080 --dsn "postgres://user:password@localhost:5432/dbname"
1# Demo mode with sample employee database 2npx @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 https://github.com/orgs/modelcontextprotocol/discussions/16
1// claude_desktop_config.json 2{ 3 "mcpServers": { 4 "dbhub-postgres-docker": { 5 "command": "docker", 6 "args": [ 7 "run", 8 "-i", 9 "--rm", 10 "bytebase/dbhub", 11 "--transport", 12 "stdio", 13 "--dsn", 14 // Use host.docker.internal as the host if connecting to the local db 15 "postgres://user:[email protected]:5432/dbname?sslmode=disable" 16 ] 17 }, 18 "dbhub-postgres-npx": { 19 "command": "npx", 20 "args": [ 21 "-y", 22 "@bytebase/dbhub", 23 "--transport", 24 "stdio", 25 "--dsn", 26 "postgres://user:password@localhost:5432/dbname?sslmode=disable" 27 ] 28 }, 29 "dbhub-demo": { 30 "command": "npx", 31 "args": ["-y", "@bytebase/dbhub", "--transport", "stdio", "--demo"] 32 } 33 } 34}
Cursor
- Cursor supports both
stdio
andsse
. - Follow 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:
1npx @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):
1npx @bytebase/dbhub --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
-
Environment variable (second priority):
1export DSN="postgres://user:password@localhost:5432/dbname?sslmode=disable" 2npx @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
- For development: Create
[!WARNING] When running in Docker, use
host.docker.internal
instead oflocalhost
to connect to databases running on your host machine. For example:mysql://user:[email protected]:3306/dbname
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
-
stdio (default) - for direct integration with tools like Claude Desktop:
1npx @bytebase/dbhub --transport stdio --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
-
sse - for browser and network clients:
1npx @bytebase/dbhub --transport sse --port 5678 --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
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, salaries, department employees, and department managers. The sample database includes SQL scripts for table creation, data loading, and testing.
Development
-
Install dependencies:
1pnpm install
-
Run in development mode:
1pnpm dev
-
Build for production:
1pnpm build 2pnpm start --transport stdio --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
Debug with MCP Inspector
stdio
1# PostgreSQL example 2TRANSPORT=stdio DSN="postgres://user:password@localhost:5432/dbname?sslmode=disable" npx @modelcontextprotocol/inspector node /path/to/dbhub/dist/index.js
SSE
1# Start DBHub with SSE transport 2pnpm dev --transport=sse --port=8080 3 4# Start the MCP Inspector in another terminal 5npx @modelcontextprotocol/inspector
Connect to the DBHub server /sse
endpoint