dbhub

bytebaseMIT活跃维护

面向 Postgres、MySQL、SQL Server、Oracle 等数据库的 MCP 服务器,让 Claude、Cursor 等 AI 编程助手能直接查询数据库,并控制上下文 token 消耗。

Token conscious database MCP server for Postgres, MySQL, SQL Server, Oracle, MariaDB, SQLite.

v1.6.0发布于 2026-11-07 08:02 UTC3,820star +17 / 7 天337fork同步于 2026-11-10 05:39 UTC

怎么上手

由 README 提炼,执行前请确认
npx @bytebase/dbhub@latest --transport http --port 8080 --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
硬件要求按 README 说明

README 未说明硬件要求;开发需 Node.js >= 22.5.0(依赖内置 node:sqlite 模块)

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

轻量级数据库 MCP 服务器,让 Claude 等客户端用极省 token 的方式连多种数据库

面向 Postgres、MySQL、SQL Server、Oracle 等数据库的 MCP 服务器,让 Claude、Cursor 等 AI 编程助手能直接查询数据库,并控制上下文 token 消耗。

核心能力

  • 默认只加载 execute_sql 和 search_objects 两个工具,约 1.4k token
  • 用单一接口连接 PostgreSQL、MySQL、MariaDB、SQL Server、Oracle、SQLite
  • 通过 TOML 配置同时连接多个数据库
  • 提供只读模式、行数限制和查询超时等保护措施
  • 支持 SSH 隧道与 SSL/TLS 加密访问

容易踩的坑

开发或本地构建需 Node.js >= 22.5.0,低版本会因缺少 node:sqlite 失败;explain_sql 和 health_check 是可选工具,默认不加载;多数据库需另写 dbhub.toml 配置,不能只靠单条 --dsn

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.6.0
  1. v1.6.0最新正式版2026-11-07 · 2026-11-07 08:02 UTC

    What's Changed

    New Contributors

    Full Changelog: https://github.com/bytebase/dbhub/compare/v1.5.1...v1.6.0

  2. v1.5.12026-11-03 · 2026-11-03 06:59 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/bytebase/dbhub/compare/v1.5.0...v1.5.1

  3. v1.5.02026-10-09 · 2026-10-09 09:30 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/bytebase/dbhub/compare/v1.4.0...v1.5.0

  4. v1.4.02026-09-28 · 2026-09-28 16:24 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/bytebase/dbhub/compare/v1.3.1...v1.4.0

  5. v1.3.12026-09-21 · 2026-09-21 08:08 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/bytebase/dbhub/compare/v1.3.0...v1.3.1

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    [!NOTE]
    If you need an enterprise-level database MCP server with built-in guardrails like approval flow, access control, data masking, and audit logging beyond what DBHub offers, check out Bytebase.

                +------------------+    +--------------+    +------------------+
                |                  |    |              |    |                  |
                |  Claude Desktop  +--->+              +--->+    PostgreSQL    |
                |                  |    |              |    |                  |
                |  Claude Code     +--->+              +--->+    SQL Server    |
                |                  |    |              |    |                  |
                |  Cursor          +--->+    DBHub     +--->+    Oracle        |
                |                  |    |              |    |                  |
                |  VS Code         +--->+              +--->+    SQLite        |
                |                  |    |              |    |                  |
                |  Copilot CLI     +--->+              +--->+    MySQL         |
                |                  |    |              |    |                  |
                |                  |    |              +--->+    MariaDB       |
                |                  |    |              |    |                  |
                +------------------+    +--------------+    +------------------+
                     MCP Clients           MCP Server             Databases
    

    DBHub is a minimal MCP server: token-efficient, zero-dependency, and just two tools by default with opt-in extras. This lightweight gateway allows MCP-compatible clients to connect to and explore different databases:

    • Minimal: Zero dependency, token efficient with a minimal set of MCP tools to maximize context window
    • Multi-Database: PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, and SQLite through a single interface
    • Multi-Connection: Connect to multiple databases simultaneously with TOML configuration
    • Guardrails: Read-only mode, row limiting, and query timeout to prevent runaway operations
    • Secure Access: SSH tunneling and SSL/TLS encryption

    DBHub is the official example in the Claude Code docs for connecting to PostgreSQL via MCP.

    Token Efficiency

    DBHub loads just 2 tools by default at 1.4k tokens — 13-14x fewer than alternatives — keeping the context window open for your actual work.

    MCP ServerDefault ConfigDefault Tools
    DBHub1.4k2 (execute_sql, search_objects)
    MCP Toolbox19.0k28
    Supabase MCP19.3kall

    Use Cases

    • Local Development: Schema exploration, query validation, and data debugging with Claude Code, VS Code, Cursor, etc.
    • Non-Technical Access: Expose curated, read-only views to non-technical staff via Claude Desktop, VS Code, Cursor, etc.
    • Multi-Database Consolidation: Replace separate MCP servers for each database with a single DBHub process
    • Production Troubleshooting: Read-only diagnostics with guardrails against runaway queries

    Supported Databases

    PostgreSQL, MySQL, SQL Server, MariaDB, Oracle, and SQLite.

    MCP Tools

    DBHub implements MCP tools for database operations:

    • execute_sql: Execute SQL queries with transaction support and safety controls
    • search_objects: Search and explore database schemas, tables, columns, indexes, and procedures with progressive disclosure
    • explain_sql (opt-in): Show a query's execution plan without running it
    • health_check (opt-in): Report connection pool state and buffer cache hit ratio
    • Custom Tools: Define reusable, parameterized SQL operations in your dbhub.toml configuration file

    Workbench

    DBHub includes a built-in web interface for interacting with your database tools. It provides a visual way to execute queries, run custom tools, and view request traces without requiring an MCP client.

    workbench

    Installation

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

    Also available as:

    See the Installation Guide for all options, Command-Line Options for parameters, and Multi-Database Configuration for connecting several databases at once.

    Development

    Requires Node.js >= 22.5.0 (DBHub uses the built-in node:sqlite module).

    # Install dependencies
    pnpm install
    
    # Run in development mode
    pnpm dev
    
    # Build and run for production
    pnpm build && pnpm start --transport stdio --dsn "postgres://user:password@localhost:5432/dbname"
    

    See Testing and Debug.

    Contributors

    Star History