DBHub MCP Server for MySQL, PostgreSQL, Oracle
Connect to MySQL, PostgreSQL, Oracle and more with the DBHub MCP server for universal database access and management.
Overview
DBHub MCP Server implements the Model Context Protocol (MCP) to provide unified, programmatic access to relational databases such as MySQL, PostgreSQL, and Oracle. It acts as a connector layer between developer tools, AI systems, and databases, exposing database metadata, query execution, and schema context in a standard, secure HTTP interface. This makes it easier to integrate databases into tooling that expects a consistent context-provider API (for example, LLM agents, observability tools, or custom orchestration scripts).
By centralizing connection logic and access policies, the server reduces the boilerplate required to instrument multiple database engines. Developers can rely on the MCP surface to inspect schema, run safe queries, and retrieve contextual information that can be consumed by downstream services or language models without embedding credentials and engine-specific logic throughout their stack.
Features
- Unified connector layer for MySQL, PostgreSQL, Oracle (and pluggable adapters for other engines)
- HTTP API exposing metadata, schema introspection, and query execution
- Connection management via environment variables or config file
- Optional TLS and authentication support for secure access
- Role-based or token-based access control hooks (configurable)
- Docker and binary deployment options for easy self-hosting
- Request throttling and query timeout settings to protect production databases
- Logging and metrics-compatible output for observability
Installation / Configuration
You can run the DBHub MCP server as a standalone binary, or as a container. The simplest way to try it locally is with Docker.
Docker (quickstart)
# Pull the image (replace tag with latest)
# Run with environment variables for a single database connection
Docker Compose (example)
version: "3.8"
services:
dbhub-mcp:
image: bytebase/dbhub-mcp:latest
ports:
- "8080:8080"
environment:
MCP_ADDR: "0.0.0.0:8080"
MCP_TOKEN: "supersecret"
# Example MySQL connection
DB_MYSQL_HOST: "mysql"
DB_MYSQL_PORT: "3306"
DB_MYSQL_USER: "app_user"
DB_MYSQL_PASSWORD: "topsecret"
DB_MYSQL_DATABASE: "app_db"
restart: unless-stopped
Configuration file (YAML)
server:
address: "0.0.0.0:8080"
tls:
enabled: false
auth:
token: "supersecret"
databases:
- name: "primary-mysql"
engine: "mysql"
host: "mysql.example.com"
port: 3306
user: "app_user"
password: "topsecret"
database: "app_db"
- name: "analytics-pg"
engine: "postgres"
host: "pg.example.com"
port: 5432
user: "analytics"
password: "pgpass"
database: "analytics_db"
- name: "legacy-oracle"
engine: "oracle"
host: "oracle.example.com"
port: 1521
user: "ora_user"
password: "orapass"
service: "ORCLPDB1"
Environment variables and config fields typically include: host, port, user, password, database (or service for Oracle), and optional sslmode / tls settings.
Available Resources
- GitHub repository: https://github.com/bytebase/dbhub/
- Docker images: Docker Hub (image: bytebase/dbhub-mcp)
- Example configs and integration samples bundled in the GitHub repo (look for /examples or /configs)
- Logs and metrics can be exposed via standard output; integrate with Prometheus/Grafana using sidecar exporters or custom metrics endpoints
Use Cases
Schema-aware LLM integrations
- Provide an LLM with current schema details and table samples so it can generate valid, safe SQL. Use the MCP introspection endpoint to fetch table/column metadata before asking the model to synthesize queries.
Centralized query gateway for microservices
- Route application or tool queries through the MCP server to centralize connection pooling, auditing, and throttling. This avoids embedding credentials in multiple services.
Cross-engine schema migration
- Export schema metadata from Oracle and import it into PostgreSQL with automated transformation tooling. Use the MCP API to extract CREATE TABLE statements and column definitions programmatically.
Ad-hoc analytics and safe execution
- Provide data analysts with a token-scoped interface that permits read-only queries and limits runtime to prevent heavy scans against production systems.
Observability and auditing
- Instrument the server to log query metadata and execution times. Feed logs into your observability stack to monitor slow queries and usage patterns across engines.
Example: Run a Query via HTTP
This is a simplified example showing how a client might execute a read-only query.
Response (JSON)
Security considerations
- Always use TLS for production deployments and avoid embedding long-lived credentials in client code.
- Prefer token-based or OAuth integrations and rotate secrets regularly.
- Configure query timeouts and maximum row limits to protect backend databases.
This MCP server is intended as a building block to simplify database access patterns across tools and services — use it to centralize connection logic, standardize metadata delivery, and safely expose database context to downstream consumers.