dbhub
CLAUDE.md3.6k starsChanged 2 months agoMITView on GitHub
DBHub is a zero-dependency, token efficient database MCP server implementing the Model Context Protocol (MCP) server interface. This lightweight server bridges MCP-compatible clients (Claude Desktop, Claude Code, Cursor) with various database systems. The codebase follows a modular architecture centered around the MCP protocol: Key architectural patterns: - Connector Registry: Dynamic registration system for database connectors - Connector Manager: Manages database connections
- Reads credentials
Trending
More talk lately.about the whole repository
Who's talking about bytebase/dbhub
- modelcontextprotocol/servers“Claude Desktop invokes MCP server docker image twice on startup”GitHub · Mar 12, 2025 · 6 reactions
- @ottoke.bsky.social“If you are integrating LLMs with databases, check out github.com/bytebase/dbh... - a universal MCP server …”Bluesky · Jun 21, 2025 · 2 likes
- sudosubin/agents.nix“agent-skills.github.bytebase.dbhub: 1.3.1 → 1.4.0”GitHub · Oct 3, 2026
- PermanentOrg/roboterry“Bump @bytebase/dbhub from 1.2.1 to 1.3.1”GitHub · Oct 1, 2026
- kingsa2026/Neurova“build(deps): bump the npx-runtime-minor-patch group across 1 directory with 2 updates”GitHub · Sep 29, 2026
The biggest 5 of 22 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 22
Talked about on GitHub and Bluesky (22 times).
On GitHub · 21
- Mar 12, 2025Claude Desktop invokes MCP server docker image twice on startup — modelcontextprotocol/servers6 reactions · 11 comments
- Oct 3, 2026agent-skills.github.bytebase.dbhub: 1.3.1 → 1.4.0 — sudosubin/agents.nix0 reactions
- Oct 1, 2026Bump @bytebase/dbhub from 1.2.1 to 1.3.1 — PermanentOrg/roboterry0 reactions
- Sep 29, 2026build(deps): bump the npx-runtime-minor-patch group across 1 directory with 2 updates — kingsa2026/Neurova0 reactions · 1 comment
- Sep 26, 2026agent-skills.github.bytebase.dbhub: init at 1.3.1 — sudosubin/agents.nix0 reactions
16 more on GitHub
- Sep 1, 2026Bump @bytebase/dbhub from 0.24.0 to 1.2.1 — PermanentOrg/roboterry0 reactions · 1 comment
- Aug 1, 2026Bump @bytebase/dbhub from 0.22.4 to 0.24.0 — PermanentOrg/roboterry0 reactions · 1 comment
- Jul 31, 2026Add bytebase/dbhub to databases — tolkonepiu/best-of-mcp-servers0 reactions · 1 comment
- Jul 1, 2026Bump @bytebase/dbhub from 0.21.2 to 0.22.4 — PermanentOrg/roboterry0 reactions
- Jun 6, 2026content(mcp): add DBHub MCP Server — JSONbored/awesome-claude0 reactions · 3 comments
- Apr 8, 2026Add bytebase/dbhub to Databases section 🤖🤖🤖 — punkpeye/awesome-mcp-servers0 reactions · 2 comments
- Mar 9, 2026Add dbhub mcp — negi524/nestjs-starter0 reactions
- Feb 23, 2026feat: add SSH keepalive configuration options — takemi-ohama/dbhub0 reactions
- Jan 23, 2026Add MCP section — mgramin/awesome-db-tools0 reactions · 2 comments
- Jan 5, 2026Add DBHub SQLite MCP server shared workflow — github/gh-aw0 reactions · 2 comments
- Dec 21, 2025[MCP Catalog] New MCP server candidate: bytebase/dbhub — obot-platform/mcp-catalog0 reactions
- Dec 21, 2025[MCP Catalog] New MCP server candidate: io.github.bytebase/dbhub — obot-platform/mcp-catalog0 reactions
- Nov 26, 2025[Server Request]: DBHub — cursor/mcp-servers0 reactions · 1 comment
- Jul 9, 2025[docs] Add Install Buttons to Readme — googleapis/mcp-toolbox0 reactions · 3 comments
- Mar 25, 2025MCP: Update to `@bytebase/dbhub@0.2.2` — crate/cratedb-examples0 reactions · 1 comment
- Mar 13, 2025feat: add DBHub - Universal database MCP server — modelcontextprotocol/servers0 reactions
On Bluesky · 1
- Jun 21, 2025If you are integrating LLMs with databases, check out github.com/bytebase/dbh... - a universal MCP server connecting to MariaDB, TiDB,… — @ottoke.bsky.social2 likes and reposts · 1 reply
In this repository4 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- fix-bugSkill
- testingSkill
- dbhubSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
13 rules. About 0 are common, 7 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Start: pnpm run start - Runs the compiled server
- Very specific: line 14
Test: pnpm test - Run all tests
- Very specific: line 15
Test Watch: pnpm test:watch - Run tests in watch mode
- Very specific: line 167
Add new connectors in src/connectors/{db-type}/index.ts
- Distinctive: line 190
All connectors have comprehensive integration test coverage
- Very specific: line 192
Test specific databases: pnpm test src/connectors/__tests__/{db-type}.integration.test.ts
- Very specific: line 206
Default SSH key detection (tries ~/.ssh/id_rsa, ~/.ssh/id_ed25519, etc.)
- Distinctive: line 214
Use camelCase for variables/functions, PascalCase for classes/types
- Distinctive: line 216
Use try/finally blocks with DB connections (always release clients)
- Distinctive: line 217
Prefer async/await over callbacks and Promise chains
- Distinctive: line 219
Use parameterized queries for DB operations
- Distinctive: line 222
Use descriptive variable/function names
- Distinctive: line 223
Keep functions focused and single-purpose
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
DBHub Development Guidelines
DBHub is a zero-dependency, token efficient database MCP server implementing the Model Context Protocol (MCP) server interface. This lightweight server bridges MCP-compatible clients (Claude Desktop, Claude Code, Cursor) with various database systems.
Commands
- Build:
pnpm run build- Compiles TypeScript to JavaScript using tsup - Start:
pnpm run start- Runs the compiled server - Dev:
pnpm run dev- Runs server with tsx (no compilation needed) - Test:
pnpm test- Run all tests - Test Watch:
pnpm test:watch- Run tests in watch mode - Integration Tests:
pnpm test:integration- Run database integration tests (requires Docker) - Claude Code Plugin:
plugin/packages DBHub as a Claude Code plugin —.mcp.jsonlaunchesnpx @bytebase/dbhub(pinned to the plugin version) against the bundled read-onlyplugin/dbhub.toml(DSN prompted viauserConfiginplugin/.claude-plugin/plugin.json, passed asDBHUB_DSN), plus/dbhub:setupand/dbhub:exploreskills. Validate withclaude plugin validate ./plugin; test withclaude --plugin-dir ./plugin. - Versioning:
package.jsonis the single source of truth.pnpm version <bump>bumps it and auto-runsscripts/sync-version.mjs, which propagates the version intoplugin/.claude-plugin/plugin.json,plugin/.mcp.json, andserver.json(files that can't be stamped at build time — the plugin is read straight from git with no build step, andserver.json's own version is what the npm publish workflow (.github/workflows/npm-publish.yml) checks against the MCP Registry before republishing — the registry publish runs as a post-step of that same workflow, after the npm publish succeeds).mcpb/manifest.jsonneeds no sync —scripts/build-mcpb.mjsstamps it frompackage.jsonat build time.src/__tests__/plugin-consistency.test.tsfails CI if any of these drift frompackage.json, or ifplugin/dbhub.tomldiverges frommcpb/dbhub.toml. - MCP Bundle:
pnpm run build:mcpb- Package DBHub as an.mcpbbundle for MCPB-compatible clients (Claude Desktop, Claude Code, MCP for Windows; seemcpb/andscripts/build-mcpb.mjs);pnpm run test:mcpbsmoke-tests the packed bundle over stdio. Published to GitHub releases by.github/workflows/mcpb-release.yml. The bundle is read-only by design (mcpb/dbhub.toml), with the DSN supplied via theDBHUB_DSNenv var declared inmcpb/manifest.json(TOML${ENV_VAR}interpolation).
Architecture Overview
The codebase follows a modular architecture centered around the MCP protocol:
src/
├── connectors/ # Database-specific implementations
│ ├── postgres/ # PostgreSQL connector
│ ├── mysql/ # MySQL connector
│ ├── mariadb/ # MariaDB connector
│ ├── sqlserver/ # SQL Server connector
│ ├── oracle/ # Oracle connector (node-oracledb Thin mode, no Instant Client)
│ └── sqlite/ # SQLite connector
├── tools/ # MCP tool handlers
│ ├── execute-sql.ts # SQL execution handler
│ ├── search-objects.ts # Unified search/list with progressive disclosure
│ ├── explain-sql.ts # Opt-in EXPLAIN plan tool (never executes the target statement)
│ └── health-check.ts # Opt-in connection pool + buffer cache metrics tool (Postgres/MySQL/MariaDB/SQL Server/Oracle)
├── utils/ # Shared utilities
│ ├── dsn-obfuscator.ts# DSN security
│ ├── response-formatter.ts # Output formatting
│ ├── allowed-keywords.ts # Read-only SQL classification primitives
│ └── sql-access-policy.ts # Statement class → verdict pipeline (single source of readonly semantics)
└── index.ts # Entry point with transport handlingKey architectural patterns:
- Connector Registry: Dynamic registration system for database connectors
- Connector Manager: Manages database connections (single or multiple)
- Supports multi-database configuration via TOML
- Maintains
Map<id, Connector>for named connections getConnector(sourceId?)returns connector by ID or default (first)getCurrentConnector(sourceId?)static method for tool handlers- Backward compatible with single-connection mode
- Location:
src/connectors/manager.ts
- Transport Abstraction: Support for both stdio (desktop tools) and HTTP (network clients)
- HTTP transport endpoint:
/mcp(aligns with official MCP SDK standard) - Implemented in
src/server.tsusingcreateMcpHandler(MCP SDK v2), which serves both protocol eras from one factory: the stateless 2026-07-28 revision natively, and 2025-era clients via the defaultlegacy: 'stateless'fallback (fresh server per request, spec-standard SSE-framed responses; GET/DELETE on the legacy path return 405) - stdio uses
serveStdiofrom@modelcontextprotocol/server/stdio(era pinned per connection) - 2026-07-28 clients get cache hints on
tools/list(cacheHintsinServerOptions: 5-minute TTL,privatescope) and sendMcp-Method/Mcp-Nameheaders usable for gateway routing/rate-limiting - Tests in
src/__tests__/json-rpc-integration.test.ts
- HTTP transport endpoint:
- Tool Handlers: Clean separation of MCP protocol concerns
- Multi-database routing is by tool name, not by parameter: one tool instance is registered per source, named
execute_sql_{source_id}/search_objects_{source_id}(single-source configs keep the bareexecute_sql/search_objectsnames). Seesrc/tools/index.tsandsrc/utils/tool-metadata.ts.source_idappears in tool output metadata only.
- Multi-database routing is by tool name, not by parameter: one tool instance is registered per source, named
- Token-Efficient Schema Exploration: Unified search/list tool with progressive disclosure
search_objects: Single tool for both pattern-based search and listing all objects- Pattern parameter defaults to
%(match all) - optional for listing use cases - Detail levels:
names(minimal),summary(with metadata),full(complete structure) - Supports: schemas, tables, columns, procedures, indexes
- Inspired by Anthropic's MCP code execution patterns for reducing token usage
- Integration Test Base: Shared test utilities for consistent connector testing
Configuration
DBHub supports three configuration methods:
1. TOML Configuration File (Multi-Database)
Recommended for projects requiring multiple database connections
- Load with
--config=path/to/config.toml(seeresolveTomlConfigPathinsrc/config/toml-loader.ts) - Configuration structure:
[[sources]]- Database connection definitions with uniqueidfields[[tools]]- Tool configuration (execution settings, custom tools)
- Example:
[[sources]] id = "prod_pg" dsn = "postgres://user:pass@localhost:5432/production" connection_timeout = 60 query_timeout = 30 [[sources]] id = "staging_mysql" type = "mysql" host = "localhost" database = "staging" user = "root" password = "secret" # Tool configuration (readonly, max_rows are tool-level settings) [[tools]] name = "execute_sql" source = "prod_pg" readonly = true max_rows = 1000 - Key files:
src/types/config.ts: TypeScript interfaces for TOML structuresrc/config/toml-loader.ts: TOML parsing and validationsrc/config/__tests__/toml-loader.test.ts: Comprehensive test suite
- Features:
- Per-source settings: SSH tunnels, timeouts, SSL configuration
- Per-tool settings:
readonly,max_rows(configured in[[tools]]section, not[[sources]]) - Custom tools: Define reusable, parameterized SQL operations
- Path expansion for
~/in file paths - Automatic password redaction in logs
- First source is the default database
- Usage in MCP tools: each source gets its own tool, suffixed with the normalized source id (e.g.
execute_sql_prod_pg(sql),search_objects_staging_mysql(...)) - See
dbhub.toml.examplefor complete configuration reference - Documentation: https://dbhub.ai/config/toml
2. Environment Variables (Single Database)
- Copy
.env.exampleto.envand configure for your database connection - Two ways to configure:
- Set
DSNto a full connection string (recommended) - Set individual parameters:
DB_TYPE,DB_HOST,DB_PORT,DB_USER,DB_PASSWORD,DB_NAME
- Set
- SSH tunnel via environment:
SSH_HOST,SSH_PORT,SSH_USER,SSH_PASSWORD,SSH_KEY,SSH_PASSPHRASE
3. Command-Line Arguments
--dsn: Database connection string (single database; cannot be combined with TOML config)--transport:stdio(default) orhttpfor streamable HTTP transport (endpoint:/mcp)--port: HTTP server port (default: 8080)--host: HTTP bind host (default:0.0.0.0; envDBHUB_HOST)--allowed-hosts: Comma-separated extra hostnames accepted in the HTTPHost/Originheaders, for DNS-rebinding protection (envDBHUB_ALLOWED_HOSTS). Loopback is always allowed; on a wildcard bind (0.0.0.0/::) this machine's hostname and IPs are auto-allowed so local/by-IP access needs no config. Set the flag for other names (e.g. a reverse-proxy/public DNS name); use*to disable the check when fronted by your own auth/proxy. SeebuildAllowedHosts/getSelfHostsinsrc/utils/cross-origin.ts.--auth-token: Comma-separated bearer token(s) required on every HTTP request viaAuthorization: Bearer <token>(envDBHUB_AUTH_TOKEN). Unset by default (no auth); configuring a token is itself the opt-in — there is no separate enforcement flag. A comma-separated list supports zero-downtime rotation (add the new token, redeploy, drop the old one) and per-client tokens./healthzis exempt. Not OAuth — a flat shared-secret allow-list, not full identity-based authorization; seevalidateAuthTokeninsrc/utils/auth-token.ts.--config: Path to TOML configuration file--demo: Use bundled SQLite employee database--readonly: Restrict to read-only SQL operations (deprecated - use TOML configuration instead)--max-rows: Limit rows returned from SELECT queries (deprecated - use TOML configuration instead)- SSH tunnel options:
--ssh-host,--ssh-port,--ssh-user,--ssh-password,--ssh-key,--ssh-passphrase - Documentation: https://dbhub.ai/config/command-line
Configuration Priority Order
Database sources come from either a TOML file (--config) or a DSN. TOML defines
sources for one or more databases; a DSN configures exactly one, so --config and
--dsn together throw — see resolveSourceConfigs in src/config/env.ts.
The guard is deliberately limited to the --dsn flag. DSN and DB_* environment
variables (exported or from .env) are left alone because TOML ${VAR} interpolation
reads them: dsn = "${DSN}" is a supported way to keep credentials out of the file.
Without --config, the DSN is resolved in this order:
--dsncommand-line argumentDSNenvironment variable- Individual
DB_*environment variables .envfiles (.env.localin development,.envin production)
All other settings (--transport, --port, --host, --allowed-hosts, …) live
outside TOML and follow the same order:
- Command-line arguments
- Environment variables
.envfiles- Built-in defaults
Database Connectors
- Add new connectors in
src/connectors/{db-type}/index.ts - Implement the
ConnectorandDSNParserinterfaces fromsrc/connectors/interface.ts - Register connector with
ConnectorRegistry.register(connector) - DSN Examples:
- PostgreSQL:
postgres://user:password@localhost:5432/dbname?sslmode=disable - MySQL:
mysql://user:password@localhost:3306/dbname?sslmode=disable - MariaDB:
mariadb://user:password@localhost:3306/dbname?sslmode=disable - SQL Server:
sqlserver://user:password@localhost:1433/dbname?sslmode=disable - SQL Server (named instance):
sqlserver://user:password@localhost:1433/dbname?instanceName=ENV1 - SQL Server (NTLM):
sqlserver://user:password@localhost:1433/dbname?authentication=ntlm&domain=MYDOMAIN - Oracle:
oracle://user:password@localhost:1521/FREEPDB1(path is the service name;?sid=ORCLfor a SID;sslmode=require/verify-fullswitch to TCPS) - SQLite:
sqlite:///path/to/database.dborsqlite:///:memory:
- PostgreSQL:
- SSL modes:
sslmode=disable(no SSL),sslmode=require(SSL without cert verification),sslmode=verify-ca(PostgreSQL only, CA verification),sslmode=verify-full(PostgreSQL, SQL Server and Oracle, CA + hostname verification). On PostgreSQL, usesslrootcertto specify CA certificate path for verify modes. PostgreSQL client certificate auth:sslcert+sslkey(PEM, unencrypted, both required;sslmodemust berequire,verify-caorverify-full—disableor unset is rejected) in the DSN or TOML source.
Testing Approach
See TESTING.md for comprehensive testing documentation.
For detailed guidance on running and troubleshooting tests, refer to the testing skill. This skill is automatically activated when working with tests, test failures, or Docker/database container issues.
Key points:
- Unit tests for individual components and utilities
- Integration tests using Testcontainers for real database testing
- All connectors have comprehensive integration test coverage
- Pre-commit hooks run related tests automatically
- Test specific databases:
pnpm test src/connectors/__tests__/{db-type}.integration.test.ts - SSH tunnel tests:
pnpm test postgres-ssh-simple.integration.test.ts
SSH Tunnel Support
DBHub supports SSH tunnels for secure database connections through bastion hosts:
- Configuration via command-line options:
--ssh-host,--ssh-port,--ssh-user,--ssh-password,--ssh-key,--ssh-passphrase - Configuration via environment variables:
SSH_HOST,SSH_PORT,SSH_USER,SSH_PASSWORD,SSH_KEY,SSH_PASSPHRASE - SSH config file support: Automatically reads from
~/.ssh/configwhen using host aliases - Implementation in
src/utils/ssh-tunnel.tsusing thessh2library - SSH config parsing in
src/utils/ssh-config-parser.tsusing thessh-configlibrary - Automatic tunnel establishment when SSH config is detected
- Support for both password and key-based authentication
- Default SSH key detection (tries
~/.ssh/id_rsa,~/.ssh/id_ed25519, etc.) - Tunnel lifecycle managed by
ConnectorManager
Code Style
- TypeScript with strict mode enabled
- ES modules with
.jsextension in imports - Group imports: Node.js core modules → third-party → local modules
- Use camelCase for variables/functions, PascalCase for classes/types
- Include explicit type annotations for function parameters/returns
- Use try/finally blocks with DB connections (always release clients)
- Prefer async/await over callbacks and Promise chains
- Format error messages consistently
- Use parameterized queries for DB operations
- Validate inputs with zod schemas
- Include fallbacks for environment variables
- Use descriptive variable/function names
- Keep functions focused and single-purpose
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

