npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ntruth/dbhub

v0.22.3

Published

Minimal, token-efficient Database MCP Server for PostgreSQL, MySQL, SQL Server, SQLite, MariaDB, Oracle, Dameng (DM8)

Readme

[!NOTE]
由开源数据库 DevSecOps 平台 Bytebase 提供支持。

            +------------------+    +--------------+    +------------------+
            |                  |    |              |    |                  |
            |                  |    |              |    |                  |
            |  Claude Desktop  +--->+              +--->+    PostgreSQL    |
            |                  |    |              |    |                  |
            |  Claude Code     +--->+              +--->+    SQL Server    |
            |                  |    |              |    |                  |
            |  Cursor          +--->+    DBHub     +--->+    SQLite        |
            |                  |    |              |    |                  |
            |  VS Code         +--->+              +--->+    MySQL         |
            |                  |    |              |    |                  |
            |  Copilot CLI     +--->+              +--->+    MariaDB       |
            |                  |    |              |    |                  |
            |                  |    |              |    |    Oracle        |
            |                  |    |              |    |                  |
            |                  |    |              |    |    Dameng (DM8)  |
            |                  |    |              |    |                  |
            +------------------+    +--------------+    +------------------+
                 MCP 客户端            MCP 服务器                数据库

DBHub 是一个零依赖、Token 高效的 MCP 服务器,实现了模型上下文协议 (Model Context Protocol, MCP) 的服务器接口。这个轻量级网关允许兼容 MCP 的客户端连接并探索不同的数据库:

  • 本地开发优先:零依赖,仅使用两个 MCP 工具即可实现高 Token 效率,从而最大化上下文窗口
  • 多数据库支持:通过单一接口支持 PostgreSQL、MySQL、MariaDB、SQL Server、SQLite、Oracle达梦 (DM8)
  • 多重连接:使用 TOML 配置同时连接到多个数据库
  • 安全护栏:只读模式、行限制和查询超时功能,防止失控操作
  • 安全访问:SSH 隧道和 SSL/TLS 加密

支持的数据库

PostgreSQL、MySQL、SQL Server、MariaDB、SQLite、Oracle 11g+达梦 (DM8)

MCP 工具

DBHub 实现了用于数据库操作的 MCP 工具:

工作台 (Workbench)

DBHub 包含一个 内置的 Web 界面 来与您的数据库工具进行交互。它提供了一种可视化的方式来执行查询、运行自定义工具以及查看请求跟踪图,而无需 MCP 客户端。

workbench

安装

快速开始 (npx / pnpm dlx)

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

# MySQL
npx @ntruth/dbhub@latest --transport http --port 8080 --dsn "mysql://user:password@localhost:3306/dbname"

# Oracle
npx @ntruth/dbhub@latest --transport http --port 8080 --dsn "oracle://user:password@localhost:1521/orcl"

# 达梦 (DM8)
npx @ntruth/dbhub@latest --transport http --port 8080 --dsn "dm://user:password@localhost:5236/dbname"

# 演示模式 (SQLite 示例数据 employee)
npx @ntruth/dbhub@latest --transport http --port 8080 --demo

MCP 客户端配置

添加到您的 MCP 客户端配置中 (Claude Desktop, Cursor, VS Code Copilot 等):

PostgreSQL 示例 (stdio 传输方式,推荐本地使用):

{
  "mcpServers": {
    "dbhub": {
      "command": "npx",
      "args": [
        "-y",
        "@ntruth/dbhub@latest",
        "--transport",
        "stdio",
        "--dsn",
        "postgres://user:password@localhost:5432/dbname?sslmode=disable"
      ]
    }
  }
}

MySQL 示例:

{
  "mcpServers": {
    "dbhub": {
      "command": "npx",
      "args": [
        "-y",
        "@ntruth/dbhub@latest",
        "--transport",
        "stdio",
        "--dsn",
        "mysql://user:password@localhost:3306/dbname"
      ]
    }
  }
}

Oracle 示例:

{
  "mcpServers": {
    "dbhub": {
      "command": "npx",
      "args": [
        "-y",
        "@ntruth/dbhub@latest",
        "--transport",
        "stdio",
        "--dsn",
        "oracle://user:password@localhost:1521/orcl?thickMode=true"
      ]
    }
  }
}

Oracle 11g 注意事项: Oracle 11g 及更早版本需要将 node-oracledb 运行在 Thick 模式,这可以通过在您的 DSN 后追加 ?thickMode=true 来启用。Thick 模式还需要在您的系统上安装 Oracle Instant Client。如果未配置标准路径,可以通过 ?libDir=/path/to/instantclient 指定其本地目录。如果您使用的是 Oracle 12c+,则可以省略此参数。

达梦 (DM8) 示例:

{
  "mcpServers": {
    "dbhub": {
      "command": "npx",
      "args": [
        "-y",
        "@ntruth/dbhub@latest",
        "--transport",
        "stdio",
        "--dsn",
        "dm://user:password@localhost:5236/dbname"
      ],
      "env": {
        "NODE_OPTIONS": "--openssl-legacy-provider"
      }
    }
  }
}

达梦 (DM8) 注意事项: 由于使用了旧版的 OpenSSL 算法,dmdb 驱动需要设置 NODE_OPTIONS=--openssl-legacy-provider 环境变量。

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"

有关所有可用参数,请参阅 命令行选项 (Command-Line Options)

多数据库设置

使用 TOML 配置文件同时连接多个数据库。非常适合从单个 DBHub 实例统筹管理生产、预发和开发数据库。

完整的设置说明请参阅 多数据库配置 (Multi-Database Configuration)

开发

# 安装依赖
pnpm install

# 运行开发环境
pnpm dev

# 构建并运行生产环境
pnpm build && pnpm start --transport stdio --dsn "postgres://user:password@localhost:5432/dbname"

请参阅 测试 (Testing)调试 (Debug)