█

AI/TLDR

Buy me a coffee
Buy me a coffee

DBHub

A token-efficient MCP server that lets AI agents explore and query your SQL databases

Workflow AutomationOpen source
Language
TypeScript
License
MIT
$npx @bytebase/dbhub@latest --transport http --port 8080 --demo
IN SHORT

What is DBHub?

DBHub is an open-source Model Context Protocol (MCP) server from Bytebase that sits between an MCP client — Claude Desktop, Claude Code, Cursor, VS Code, Copilot CLI and others — and your databases. It sits in the Workflow Automation category of the Agents & Automation tools and is open-source, written in TypeScript and licensed MIT.

Overview

DBHub is an open-source Model Context Protocol (MCP) server from Bytebase that sits between an MCP client — Claude Desktop, Claude Code, Cursor, VS Code, Copilot CLI and others — and your databases. One DBHub process speaks to PostgreSQL, MySQL, MariaDB, SQL Server, Oracle and SQLite, so an agent can browse schemas and run SQL through a single interface instead of a separate server per database. It is the example the Claude Code documentation uses for connecting to PostgreSQL over MCP.

The design goal is a small tool surface. By default DBHub loads only two tools — `execute_sql` and `search_objects`, which explores schemas, tables, columns, indexes and procedures with progressive disclosure — at about 1.4k tokens, which the project compares with 19k+ for some alternatives. `explain_sql` (a query plan without running the query) and `health_check` are opt-in, and you can define your own parameterized SQL tools in a `dbhub.toml` file. Guardrails include read-only mode, row limits and query timeouts, and connections can go through SSH tunnels and SSL/TLS.

Run with HTTP transport, DBHub also serves a built-in web Workbench: you can execute queries, run custom tools through a form, and read a trace of recent requests in the browser without any MCP client. It ships on npm as `@bytebase/dbhub` (Node.js 22.5.0 or later), as the `bytebase/dbhub` Docker image, as a read-only one-click MCP Bundle and as a Claude Code plugin. The project is written in TypeScript and MIT licensed; Bytebase points teams that need approval flows, access control, data masking and audit logging to its separate Bytebase product.

The DBHub Workbench in a browser, showing a local PostgreSQL source's connection details and its available tools, execute_sql in read-only mode limited to 1000 rows and search_objects
The built-in Workbench lists each configured source with its connection details and the MCP tools DBHub exposes for it.DBHub docs ↗

What it does

  • One MCP server for PostgreSQL, MySQL, MariaDB, SQL Server, Oracle and SQLite
  • Two default tools (`execute_sql`, `search_objects`) at about 1.4k tokens, plus opt-in `explain_sql` and `health_check`
  • Custom tools: reusable, parameterized SQL statements defined in `dbhub.toml` and exposed as MCP tools
  • Multiple databases at once through `[[sources]]` in a TOML config, with per-tool `readonly` and `max_rows` and hot reload on file changes
  • Guardrails against runaway queries: read-only mode, row limits and server-side query timeouts
  • SSH tunnelling and SSL/TLS for secure connections, and a built-in web Workbench with request traces

Getting started

Try the built-in demo database first, then point DBHub at your own database, register it with your MCP client, and move to a `dbhub.toml` file for multiple databases and guardrails. The npm package needs Node.js 22.5.0 or later; the Docker image bundles its own runtime.

Try demo mode and open the Workbench

Demo mode starts DBHub with a sample database. With HTTP transport, open http://localhost:8080 in your browser to use the Workbench.

bashbash
npx @bytebase/dbhub@latest --transport http --port 8080 --demo

Connect your own database

Pass a connection string with `--dsn`, via npx or the Docker image. From inside Docker, reach a database on your host with `host.docker.internal` instead of `localhost`.

bashbash
npx @bytebase/dbhub@latest \
  --transport http \
  --port 8080 \
  --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"

# or with Docker
docker run --rm --init \
  --name dbhub \
  --publish 8080:8080 \
  bytebase/dbhub \
  --transport http \
  --port 8080 \
  --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"

Register it with your MCP client

In Claude Code, add DBHub over stdio for a local database, or point at a running HTTP server. Everything after `--` is the DBHub command. Codex works the same way with `codex mcp add`.

bashbash
# stdio (local)
claude mcp add --transport stdio dbhub -- npx @bytebase/dbhub@latest --transport stdio --dsn "postgres://user:password@localhost:5432/dbname"

# HTTP (a DBHub server already running on port 8080)
claude mcp add --transport http dbhub http://localhost:8080/mcp

Configure several databases with dbhub.toml

Define each database as a `[[sources]]` entry and set guardrails per tool, then start DBHub with `--config` (a `./dbhub.toml` in the working directory is loaded automatically). `--config` and `--dsn` cannot be combined.

tomltoml
[[sources]]
id = "production"
dsn = "postgres://user:pass@localhost:5432/mydb"
connection_timeout = 60

[[sources]]
id = "staging"
dsn = "mysql://root:pass@localhost:3306/myapp"

[[tools]]
name = "execute_sql"
source = "production"
readonly = true
max_rows = 1000

[[tools]]
name = "execute_sql"
source = "staging"
readonly = false

Add a custom tool

A custom tool is a fixed SQL statement with typed parameters. Agents call it like any other MCP tool, and the Workbench renders it as a form with a read-only preview of the generated SQL.

tomltoml
[[tools]]
name = "delete_employee_salaries"
description = "Delete salary records for a specific employee"
source = "local_pg"
readonly = false  # Explicitly allow DELETE operations
statement = "DELETE FROM salary WHERE emp_no = $1"

[[tools.parameters]]
name = "emp_no"
type = "integer"
description = "Employee number"
required = true
A DBHub custom tool, delete_employee_salaries, open in the Workbench as a form with an emp_no field, a preview of the generated DELETE statement and a Run button
A custom tool from dbhub.toml rendered in the Workbench: fill in the parameter, check the generated SQL, run it.DBHub docs ↗

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Exploring schemas, validating queries and debugging data from Claude Code, Cursor or VS Code during local development
  • Giving non-technical colleagues curated, read-only database access through Claude Desktop or another MCP client
  • Replacing a separate MCP server per database with a single DBHub process
  • Read-only production troubleshooting, with row limits and query timeouts guarding against runaway queries
The DBHub Workbench Recent Requests page, a table of tool calls with their time, tool name, SQL, duration and client, filterable by database source
Request Trace keeps the latest 100 tool executions per source in memory, with the SQL, timing and calling client.DBHub docs ↗

How DBHub compares

DBHub alongside other open-source workflow automation tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
n8n★ 213kA self-hostable workflow automation tool with a visual node editor that connects 400+ apps and APIs and adds native AI steps, letting technical teams build automations without writing most of the glue code.
Huginn★ 50.7kA self-hosted system of "agents" that watch websites, feeds, and events and take automated actions on your behalf, similar to a private IFTTT.
GitHub MCP Server★ 34.9kGitHub's official MCP server, hosted or self-run, that gives an agent scoped toolsets for repositories, issues, pull requests, Actions runs and code-security alerts.
gws (Google Workspace CLI)★ 32.6kA command-line tool for every Google Workspace API, built at runtime from Google’s Discovery Service, returning structured JSON and shipping 40+ agent skills. Not an officially supported Google product.
Kestra★ 30.4kAn event-driven orchestration platform that defines data, AI, and infrastructure pipelines as declarative YAML and runs them through a web UI.
Activepieces★ 25.8kAn open-source Zapier alternative where you build automations from reusable TypeScript "pieces", with support for AI agents and self-hosting.
n8n-MCP★ 23.3kAn MCP server that gives coding assistants structured access to n8n's node catalogue, schemas, docs and workflow templates so they can build and validate n8n workflows.
DBHub★ 4kA token-efficient MCP server that lets AI agents explore and query your SQL databases