How bytebase/dbhub works
DBHub is a database gateway exposing MCP tools over stdio or HTTP, with a built-in web workbench. The main workflow is client request → registered tool handler → source-specific connector → database, with SQL guardrails and request tracing along the way. The README also documents optional explain, health-check, and custom tools, plus multi-source configuration and six database families. The excerpts confirm server setup, tool registration, connector management, and custom-tool execution; other handler and route wiring is included only where supported by the README and tree.
Main entry points: server.ts Transport Server · manager.ts Connector Manager · connectors Database Connectors · index.ts Tool Registration
Components 20
MCP Server
- Transport Server
src/server.ts - Source Configuration
src/config/toml-loader.ts
Database Tools
- SQL Guardrails
src/utils/sql-access-policy.ts - Tool Registration
src/tools/index.ts - Execute SQL
src/tools/execute-sql.ts - Search Objects
src/tools/search-objects.ts - Explain SQL
src/tools/explain-sql.ts - Health Check
src/tools/health-check.ts - Custom Tools
src/tools/custom-tool-handler.ts - Request Tracing
src/requests/index.ts
Sources And Connectors
- Connector Manager
src/connectors/manager.ts - Database Connectors
src/connectors
Web Workbench
- Workbench UI
frontend/src/App.tsx - Sources API
src/api/sources.ts - Requests API
src/api/requests.ts - Tools API
- Workbench Views
frontend/src/components/views
Other components
- MCP Clients
- Databases
- Workbench User
Connections 32
- MCP Clients → Transport Server: send MCP requests
- Transport Server → Source Configuration: resolve sources
- Transport Server → Connector Manager: connect sources
- Transport Server → Tool Registration: register tools
- Tool Registration → Execute SQL: register handler
- Tool Registration → Search Objects: register handler
- Tool Registration → Explain SQL: register handler
- Tool Registration → Health Check: register handler
- Tool Registration → Custom Tools: register handler
- Execute SQL → Connector Manager: get connector
- Search Objects → Connector Manager: get connector
- Explain SQL → Connector Manager: get connector
- Health Check → Connector Manager: get connector
- Custom Tools → Connector Manager: ensure connection
- Execute SQL → SQL Guardrails: check SQL
- Custom Tools → SQL Guardrails: check SQL
- Execute SQL → Database Connectors: execute SQL
- Search Objects → Database Connectors: inspect schema
- Explain SQL → Database Connectors: explain query
- Health Check → Database Connectors: check health
- Custom Tools → Database Connectors: execute SQL
- Connector Manager → Database Connectors: select connector
- Database Connectors → Databases: query database
- Custom Tools → Request Tracing: record request
- Workbench User → Workbench UI: use workbench
- Workbench UI → Sources API: fetch sources
- Workbench UI → Workbench Views: render routes
- Workbench Views → Requests API: fetch request traces
- Workbench Views → Tools API: invoke tools
- Sources API → Transport Server: request sources
- Requests API → Transport Server: request traces
- Tools API → Transport Server: invoke tools