A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/bytebase/dbhub/ below:

bytebase/dbhub: Universal database MCP server connecting to MySQL, PostgreSQL, SQL Server, MariaDB.

Note

Brought to you by Bytebase, open-source database DevSecOps platform.

Add to Cursor by copying the below link to browser

cursor://anysphere.cursor-deeplink/mcp/install?name=dbhub&config=eyJjb21tYW5kIjoibnB4IEBieXRlYmFzZS9kYmh1YiIsImVudiI6eyJUUkFOU1BPUlQiOiJzdGRpbyIsIkRTTiI6InBvc3RncmVzOi8vdXNlcjpwYXNzd29yZEBsb2NhbGhvc3Q6NTQzMi9kYm5hbWU%2Fc3NsbW9kZT1kaXNhYmxlIiwiUkVBRE9OTFkiOiJ0cnVlIn19

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    |
 |                  |    |              |    |                  |
 |  Claude Code     +--->+              +--->+    SQL Server    |
 |                  |    |              |    |                  |
 |  Cursor          +--->+    DBHub     +--->+    SQLite        |
 |                  |    |              |    |                  |
 |  Other Clients   +--->+              +--->+    MySQL         |
 |                  |    |              |    |                  |
 |                  |    |              +--->+    MariaDB       |
 |                  |    |              |    |                  |
 |                  |    |              |    |                  |
 +------------------+    +--------------+    +------------------+
      MCP Clients           MCP Server             Databases

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

Resource Name URI Format PostgreSQL MySQL MariaDB 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} ✅ ✅ ✅ ✅ ❌ Tool Command Name Description PostgreSQL MySQL MariaDB SQL Server SQLite Execute SQL execute_sql Execute single or multiple SQL statements (separated by semicolons) ✅ ✅ ✅ ✅ ✅ Prompt Command Name PostgreSQL MySQL MariaDB SQL Server SQLite Generate SQL generate_sql ✅ ✅ ✅ ✅ ✅ Explain DB Elements explain_db ✅ ✅ ✅ ✅ ✅
# PostgreSQL example
docker run --rm --init \
   --name dbhub \
   --publish 8080:8080 \
   bytebase/dbhub \
   --transport http \
   --port 8080 \
   --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
# Demo mode with sqlite sample employee database
docker run --rm --init \
   --name dbhub \
   --publish 8080:8080 \
   bytebase/dbhub \
   --transport http \
   --port 8080 \
   --demo
# PostgreSQL example
npx @bytebase/dbhub --transport http --port 8080 --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"

# Demo mode with sqlite sample employee database
npx @bytebase/dbhub --transport http --port 8080 --demo
# Demo mode with sample employee database
npx @bytebase/dbhub --transport http --port 8080 --demo

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

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

Check https://docs.anthropic.com/en/docs/claude-code/mcp

Add to Cursor by copying the below link to browser

cursor://anysphere.cursor-deeplink/mcp/install?name=dbhub&config=eyJjb21tYW5kIjoibnB4IEBieXRlYmFzZS9kYmh1YiIsImVudiI6eyJUUkFOU1BPUlQiOiJzdGRpbyIsIkRTTiI6InBvc3RncmVzOi8vdXNlcjpwYXNzd29yZEBsb2NhbGhvc3Q6NTQzMi9kYm5hbWU%2Fc3NsbW9kZT1kaXNhYmxlIiwiUkVBRE9OTFkiOiJ0cnVlIn19

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.

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

Database sslmode=disable sslmode=require Default SSL Behavior PostgreSQL ✅ ✅ Certificate verification MySQL ✅ ✅ Certificate verification MariaDB ✅ ✅ Certificate verification SQL Server ✅ ✅ Certificate verification SQLite ❌ ❌ N/A (file-based)

SSL Mode Options:

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

DBHub supports connecting to databases through SSH tunnels, enabling secure access to databases in private networks or behind firewalls.

Using SSH Config File (Recommended)

DBHub can read SSH connection settings from your ~/.ssh/config file. Simply use the host alias from your SSH config:

# If you have this in ~/.ssh/config:
# Host mybastion
#   HostName bastion.example.com
#   User ubuntu
#   IdentityFile ~/.ssh/id_rsa

npx @bytebase/dbhub \
  --dsn "postgres://dbuser:dbpass@database.internal:5432/mydb" \
  --ssh-host mybastion

DBHub will automatically use the settings from your SSH config, including hostname, user, port, and identity file. If no identity file is specified in the config, DBHub will try common default locations (~/.ssh/id_rsa, ~/.ssh/id_ed25519, etc.).

SSH with Password Authentication
npx @bytebase/dbhub \
  --dsn "postgres://dbuser:dbpass@database.internal:5432/mydb" \
  --ssh-host bastion.example.com \
  --ssh-user ubuntu \
  --ssh-password mypassword
SSH with Private Key Authentication
npx @bytebase/dbhub \
  --dsn "postgres://dbuser:dbpass@database.internal:5432/mydb" \
  --ssh-host bastion.example.com \
  --ssh-user ubuntu \
  --ssh-key ~/.ssh/id_rsa
SSH with Private Key and Passphrase
npx @bytebase/dbhub \
  --dsn "postgres://dbuser:dbpass@database.internal:5432/mydb" \
  --ssh-host bastion.example.com \
  --ssh-port 2222 \
  --ssh-user ubuntu \
  --ssh-key ~/.ssh/id_rsa \
  --ssh-passphrase mykeypassphrase
Using Environment Variables
export SSH_HOST=bastion.example.com
export SSH_USER=ubuntu
export SSH_KEY=~/.ssh/id_rsa
npx @bytebase/dbhub --dsn "postgres://dbuser:dbpass@database.internal:5432/mydb"

Note: When using SSH tunnels, the database host in your DSN should be the hostname/IP as seen from the SSH server (bastion host), not from your local machine.

Configure your database connection

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

npx @bytebase/dbhub  --demo

Warning

If your user/password contains special characters, you need to escape them first. (e.g. pass#word should be escaped as pass%23word)

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

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:

Database DSN Format Example MySQL mysql://[user]:[password]@[host]:[port]/[database] mysql://user:password@localhost:3306/dbname?sslmode=disable MariaDB mariadb://[user]:[password]@[host]:[port]/[database] mariadb://user:password@localhost:3306/dbname?sslmode=disable PostgreSQL postgres://[user]:[password]@[host]:[port]/[database] postgres://user:password@localhost:5432/dbname?sslmode=disable SQL Server sqlserver://[user]:[password]@[host]:[port]/[database] sqlserver://user:password@localhost:1433/dbname?sslmode=disable SQLite sqlite:///[path/to/file] or sqlite:///:memory: sqlite:///path/to/database.db, sqlite:C:/Users/YourName/data/database.db (windows) or sqlite:///:memory:

Extra query parameters:

Option Environment Variable Description Default dsn DSN Database connection string Required if not in demo mode transport TRANSPORT Transport mode: stdio or http stdio port PORT HTTP server port (only applicable when using --transport=http) 8080 readonly READONLY Restrict SQL execution to read-only operations false demo N/A Run in demo mode with sample employee database false ssh-host SSH_HOST SSH server hostname for tunnel connection N/A ssh-port SSH_PORT SSH server port 22 ssh-user SSH_USER SSH username N/A ssh-password SSH_PASSWORD SSH password (for password authentication) N/A ssh-key SSH_KEY Path to SSH private key file N/A ssh-passphrase SSH_PASSPHRASE Passphrase for SSH private key N/A

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.

  1. Install dependencies:

  2. Run in development mode:

  3. Build for production:

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

The project uses Vitest for comprehensive unit and integration testing:

DBHub includes comprehensive integration tests for all supported database connectors using Testcontainers. These tests run against real database instances in Docker containers, ensuring full compatibility and feature coverage.

Running Integration Tests

Note: This command runs all integration tests in parallel, which may take 5-15 minutes depending on your system resources and network speed.

# Run all database integration tests
pnpm test:integration
# Run only PostgreSQL integration tests
pnpm test src/connectors/__tests__/postgres.integration.test.ts
# Run only MySQL integration tests
pnpm test src/connectors/__tests__/mysql.integration.test.ts
# Run only MariaDB integration tests
pnpm test src/connectors/__tests__/mariadb.integration.test.ts
# Run only SQL Server integration tests
pnpm test src/connectors/__tests__/sqlserver.integration.test.ts
# Run only SQLite integration tests
pnpm test src/connectors/__tests__/sqlite.integration.test.ts
# Run JSON RPC integration tests
pnpm test src/__tests__/json-rpc-integration.test.ts

All integration tests follow these patterns:

  1. Container Lifecycle: Start database container → Connect → Setup test data → Run tests → Cleanup
  2. Shared Test Utilities: Common test patterns implemented in IntegrationTestBase class
  3. Database-Specific Features: Each database includes tests for unique features and capabilities
  4. Error Handling: Comprehensive testing of connection errors, invalid SQL, and edge cases
Troubleshooting Integration Tests

Container Startup Issues:

# Check Docker is running
docker ps

# Check available memory
docker system df

# Pull images manually if needed
docker pull postgres:15-alpine
docker pull mysql:8.0
docker pull mariadb:10.11
docker pull mcr.microsoft.com/mssql/server:2019-latest

SQL Server Timeout Issues:

Network/Resource Issues:

# Run tests with verbose output
pnpm test:integration --reporter=verbose

# Run single database test to isolate issues
pnpm test:integration -- --testNamePattern="PostgreSQL"

# Check Docker container logs if tests fail
docker logs <container_id>
Pre-commit Hooks (for Developers)

The project includes pre-commit hooks to run tests automatically before each commit:

  1. After cloning the repository, set up the pre-commit hooks:

  2. This ensures the test suite runs automatically whenever you create a commit, preventing commits that would break tests.

# PostgreSQL example
TRANSPORT=stdio DSN="postgres://user:password@localhost:5432/dbname?sslmode=disable" npx @modelcontextprotocol/inspector node /path/to/dbhub/dist/index.js
# Start DBHub with HTTP transport
pnpm dev --transport=http --port=8080

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

Connect to the DBHub server /message endpoint


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4