# @bytebase/dbhub 中文文档

规范地址：https://npmcn.com/package/%40bytebase/dbhub/

版本：1\.6\.0
npm 元数据更新时间：2026-11-07T08:04:00.085Z
中文译文更新时间：2026-11-08T21:43:28.219Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40bytebase/dbhub
原文对照：https://npmcn.com/package/%40bytebase/dbhub/?lang=original
项目主页：https://github.com/bytebase/dbhub#readme
源码仓库：https://github.com/bytebase/dbhub

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：2 MB，38 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：\>=22\.5\.0
- 运行依赖：8 个
- 首次发布：2025-03-12T09:28:40.100Z
- 最新版本发布：2026-11-07T08:03:59.757Z
- 近 30 天下载量：152317（2026-10-09 至 2026-11-07，npm 官方下载统计）
- 已发布版本数：87（近 12 个月 42 个）

## 中文简介

用于 PostgreSQL 、 MySQL 、 MariaDB 、 SQL 服务器、 Oracle 、 SQLite 的 Koken 高效数据库 MCP 服务器

## 安装

```sh
npm install @bytebase/dbhub
```

也可以使用：`pnpm add @bytebase/dbhub`、`yarn add @bytebase/dbhub`、`bun add @bytebase/dbhub`

## README

> \[注\]  
> 如果您需要企业级数据库 MCP 服务器, 并配备内置的护栏, 如批准流程、 访问控制、 数据掩码以及 DBHub 提供之外的审计记录, 请检查 [字节](https://www.bytebase.com/)。 。 。 .

[![GitHub Trending Repository of the Day](https://api.star-history.com/badge?repo=bytebase/dbhub&type=trending)](https://www.star-history.com/bytebase/dbhub)

[![DBHub Logo](https://raw.githubusercontent.com/bytebase/dbhub/main/docs/images/logo/full-light.svg)](https://dbhub.ai/)

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

DBHub是一个最小的MCP服务器:有令牌效率,零依赖性,默认只有两个工具带有选入外加. 这个轻量级网关允许MCP兼容客户端连接并探索不同的数据库:

-   **最小值**: 0 依赖性, 具有最小的 MCP 工具以最大化上下文窗口的符号效率
-   **多数据库**: PostgreSQL, MySQL, MariaDB, SQL 服务器, Oracle, 通过单一接口的 SQLite
-   **多连接**: 与 TOML 配置同时连接到多个数据库
-   **护栏**: 仅读模式、行限制和查询超时以防止运行失控
-   **安全访问**: SSH地道和SSL/TLS加密

> DBHub 是其中的正式实例 [克劳德代码文件](https://code.claude.com/docs/en/mcp#example-query-your-postgresql-database) 通过 MCP 连接到 PostgreSQL .

## 调试效率

DBHub 默认只装入 2 个工具 **1.4克令牌** ——13~14x比替代品少——为您实际工作保持上下文窗口畅通.

| MCP 服务器 | 默认配置 | 默认工具 |
| --- | --- | --- |
| **DBHub 函数** | **1.4克级** | 页:1`execute_sql`, (中文(简体) ), `search_objects`(中文(简体) ) |
| MCP 工具箱 | 19.0k (韩语) | 第28条 |
| Supabase MCP 软件 | 19.3k (韩语) | 全部 |

## 使用大小写

-   **地方发展**: Schema 探索,查询验证,并用克洛德代码,VS代码,光标等调试数据.
-   **非技术准入**:通过克洛德桌面,VS代码,光标等向非技术人员展示被整理,只读取的视图.
-   **多数据库合并**: 将每个数据库的单独的MCP服务器替换为单个 DBHub 进程
-   **解决生产问题**: 仅读诊断,有防跑道

## 支持的数据库

PostgreSQL, MySQL, SQL 服务器, MariaDB, Oracle, 和 SQLite.

## MCP 工具

DBHub 为数据库操作执行 MCP 工具 :

-   **[执行( s)](https://dbhub.ai/tools/execute-sql)**: 执行带有交易支持和安全控制的 SQL 查询
-   **[搜索对象( o)](https://dbhub.ai/tools/search-objects)**: 搜索和探索数据库计划、表格、栏目、索引和逐步披露的程序
-   **[解释( s)](https://dbhub.ai/tools/explain-sql)** (选入): 不运行就显示查询的执行计划
-   **[健康检查](https://dbhub.ai/tools/health-check)** (opt- in):报告连接池状态和缓冲缓存命中比率
-   **[自定义工具](https://dbhub.ai/tools/custom-tools)**: 定义可重复使用的 SQL 操作 `dbhub.toml` 配置文件

## 工作区

DBHub 包含 a [内建网络界面](https://dbhub.ai/workbench/overview) 用于与您的数据库工具交互。 它提供了一种可视化的方法,可以执行查询,运行自定义工具,并查看请求的痕迹而不需要MCP客户端.

![workbench](https://raw.githubusercontent.com/bytebase/dbhub/main/docs/images/workbench/workbench.webp)

## 安装

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

也可提供如下资料:

-   [Docker 图像](https://dbhub.ai/installation#docker)
-   [MCP 套装](https://dbhub.ai/mcpb) (一击安装,只读)
-   [Claude 代码插件](https://dbhub.ai/claude-code-plugin)

见 [安装指南](https://dbhub.ai/installation) 对所有选项, [命令行选项](https://dbhub.ai/config/command-line) 用于参数,以及 [多数据库配置](https://dbhub.ai/config/toml) 用于同时连接多个数据库.

## 发展

需要节点.js QQ 22. 5.0( DBHub 使用内置 `node:sqlite` 页:1.

```bash
# 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"
```

见 [测试](https://npmcn.com/package/%40bytebase/dbhub/.claude/skills/testing/SKILL.md) 财务报告和审定财务报表 [调试](https://dbhub.ai/config/debug)。 。 。 .

## 贡献者

[![](https://contrib.rocks/image?repo=bytebase/dbhub)](https://github.com/bytebase/dbhub/graphs/contributors)

## 恒星历史

[![Star History Chart](https://api.star-history.com/chart?repos=bytebase/dbhub&type=date&legend=top-left)](https://www.star-history.com/?repos=bytebase%2Fdbhub&type=date&legend=top-left)

## 常见问题

### @bytebase/dbhub 是什么？

用于 PostgreSQL 、 MySQL 、 MariaDB 、 SQL 服务器、 Oracle 、 SQLite 的 Koken 高效数据库 MCP 服务器

### 如何安装 @bytebase/dbhub？

在项目目录运行 npm install @bytebase/dbhub，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 dbhub，可以用 npx dbhub 直接运行。

### @bytebase/dbhub 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @bytebase/dbhub 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @bytebase/dbhub 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=22\.5\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @bytebase/dbhub 可以商用吗？

@bytebase/dbhub 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @bytebase/dbhub 的下载量有多少？

根据 npm 官方下载统计，@bytebase/dbhub 在 2026/10/09 – 2026/11/07 这 30 天内被下载 152,317 次，日均约 5,077 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @bytebase/dbhub 还在维护吗？

最新版本 1\.6\.0 发布于 2026/11/07（1 天前）；至今共发布 87 个版本，其中过去 12 个月发布了 42 个；首次发布于 2025/03/12。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

