# Codex Dbhub Plugin

> Native Codex plugin bridging a local DBHub MCP server: execute_sql / search_objects with per-directory environment passthrough.

- **Type:** MCP server
- **Install:** `agentstack add mcp-mr-mihu-codex-dbhub-plugin`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [mr-mihu](https://agentstack.voostack.com/s/mr-mihu)
- **Installs:** 0
- **Category:** [Databases](https://agentstack.voostack.com/c/databases)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [mr-mihu](https://github.com/mr-mihu)
- **Source:** https://github.com/mr-mihu/codex-dbhub-plugin

## Install

```sh
agentstack add mcp-mr-mihu-codex-dbhub-plugin
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Codex DBHub Plugin

[](LICENSE)

[English](README.en.md) | **中文**

**Codex DBHub Plugin** 是一个 Codex 原生插件，把本机 [DBHub](https://dbhub.ai/) MCP 服务桥接给
Codex，提供 `execute_sql` / `search_objects` 能力。适用于 Codex 无法暴露 `mcp__*` 工具的场景
（如 DeepSeek 等自定义模型，见 [openai/codex#36382](https://github.com/openai/codex/issues/36382)）。

> DBHub 本身是 MCP 工具；本项目是**基于 DBHub 开发的 Codex 插件**（插件形式，不是另一个 MCP 服务）。

## 特点

- 兼容不暴露 `mcp__*` 工具的模型（如 DeepSeek）。
- 零第三方依赖：纯 Node.js MCP 客户端，默认 stdio 直连，不占端口、不卡顿。
- 本地优先：自动找 mise / nvm / volta / npm 全局 / 项目 `node_modules` 里的 dbhub；
  找不到再用 `npx --yes @bytebase/dbhub@latest` 兜底，保持 dbhub 最新版，升级无需改插件。
- 环境透传：把当前工作目录的环境变量（`DSN` / `DB_*` / `dbhub.toml`）原样传给 DBHub，
  每个工作目录自动切换数据源。
- 确定性退出：调用结束自动清理子进程，绝不挂起。
- 安全优先：不扫描项目找配置/凭据；没配置时只询问用户。
- 跨平台：Windows / macOS / Linux 均可运行（自带 `.cmd` 与 POSIX 两种启动器）。

## 环境要求

- Node.js >= 18（DBHub 内置 SQLite 需要 >= 22.5）。
- 本机装有 dbhub，或允许 `npx` 联网兜底。

## 仓库结构

```text
.
├── .agents/plugins/marketplace.json            # marketplace 清单（仓库/团队源）
├── plugins/codex-dbhub-plugin/                 # 插件本体
│   ├── .codex-plugin/plugin.json               # 插件清单
│   ├── skills/dbhub/SKILL.md                   # 给 AI 的使用说明（含安全红线）
│   └── scripts/                                # MCP 客户端 + 启动器
├── CHANGELOG.md
└── LICENSE
```

## 安装（Codex）

1. 克隆仓库：

   ```bash
   git clone https://github.com/mr-mihu/codex-dbhub-plugin.git codex-dbhub-plugin
   ```

2. 添加 marketplace：

   ```bash
   codex plugin marketplace add ./codex-dbhub-plugin
   ```

   或在 ChatGPT/Codex 桌面版：**Plugins → Add Marketplace**，选择克隆下来的 `codex-dbhub-plugin`
   目录。

3. 在 Plugins 目录切到 **Codex DBHub Plugin** 源，安装 **codex-dbhub-plugin**。

4. **开一个新会话**再使用。

## 每用户数据库配置

插件把当前工作目录的环境透传给 DBHub，所以每个用户/工作目录连哪个库由自己配置：

- 在工作目录设置 `DSN` 或 `DB_*`（`DB_TYPE` / `DB_HOST` / `DB_PORT` / `DB_USER` / `DB_PASSWORD` /
  `DB_NAME`）；
- 或在项目根目录放 `dbhub.toml` / `.env`；
- 或临时用 `--dsn` / `--demo` 指定。

没配置时，插件只询问用户（或加 `--demo` 自测），不会自动去项目里搜索配置文件或凭据。

## 用法示例（AI 调用）

已安装（个人 marketplace）时，在项目根目录直接调用：

```powershell
& "$env:USERPROFILE\plugins\codex-dbhub-plugin\scripts\codex-dbhub-plugin.cmd" query 'SELECT id, name FROM users LIMIT 10'
& "$env:USERPROFILE\plugins\codex-dbhub-plugin\scripts\codex-dbhub-plugin.cmd" tables
```

Linux / macOS 使用同目录的 POSIX 启动器（参数完全一样；个人插件默认装在
`~/plugins`，Windows 为 `%USERPROFILE%\plugins`）：

```bash
"$HOME/plugins/codex-dbhub-plugin/scripts/codex-dbhub-plugin" query 'SELECT id, name FROM users LIMIT 10'
"$HOME/plugins/codex-dbhub-plugin/scripts/codex-dbhub-plugin" tables
```

或从仓库根直接跑：

```powershell
node plugins/codex-dbhub-plugin/scripts/codex-dbhub-plugin-client.mjs query 'SELECT id, name FROM users LIMIT 10'
```

（`codex-dbhub-plugin-client.mjs` 是纯 Node 脚本，三种平台通用。）

完整环境变量说明见 [插件 README](plugins/codex-dbhub-plugin/README.md)。

## 安全说明

- 凭据只存在于环境变量 / 本地配置；`info` 输出已打码。
- 技能内置安全红线：禁止扫描项目寻找数据库配置或凭据（`.env`、nacos、SSH 等），
  无配置时只询问用户。
- 不要把 `.env` / `dbhub.toml` 提交到仓库（见 `.gitignore`）。

## 许可证

[MIT](LICENSE) © 2026 米胡先生 (mr-mihu)

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [mr-mihu](https://github.com/mr-mihu)
- **Source:** [mr-mihu/codex-dbhub-plugin](https://github.com/mr-mihu/codex-dbhub-plugin)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** yes
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-mr-mihu-codex-dbhub-plugin
- Seller: https://agentstack.voostack.com/s/mr-mihu
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
