h3yun-sql-troubleshooter
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
h3yun-sql-troubleshooter
一个给 AI 使用的氚云 SQL 查询 MCP 工具。AI 可以调用 query_sql,把只读 SQL 发送到氚云平台接口执行,并拿到真实数据结果;辅助排查氚云业务问题是它的典型使用场景之一。
下载编译版(推荐,无需安装 Node)
推送 tag 后,GitHub Actions 会自动编译并附加到 Releases 页面。依赖已全部打包进单个文件,用户不需要安装 Node,也不需要执行 npm install。
可下载的产物:
文件 | 适用平台 | 是否需要 Node |
| Windows x64 | 不需要 |
| Linux x64 | 不需要 |
| macOS Intel | 不需要 |
| macOS Apple 芯片 | 不需要 |
| 任意平台 | 需要 Node >= 18,但无需安装依赖 |
下载后把可执行文件放到固定目录(路径不要带空格),MCP 配置改为直接指向它:
{
"mcpServers": {
"h3yun-sql-troubleshooter": {
"command": "D:/tools/h3yun-sql-troubleshooter-win32-x64.exe"
}
}
}macOS / Linux 需要先赋予执行权限:
chmod +x ./h3yun-sql-troubleshooter-linux-x64macOS 可能还需要解除隔离:xattr -d com.apple.quarantine ./h3yun-sql-troubleshooter-darwin-arm64。
Related MCP server: DBMCP
MCP 配置
已发布到 npm 时,推荐这样配置:
{
"mcpServers": {
"h3yun-sql-troubleshooter": {
"command": "npx",
"args": ["h3yun-sql-troubleshooter"]
}
}
}如果使用本机开发目录,可以直接指向入口文件:
{
"mcpServers": {
"h3yun-sql-troubleshooter": {
"command": "node",
"args": ["D:/ai/mcps/h3yun-sql-troubleshooter/src/index.js"]
}
}
}凭据准备
工具需要两个氚云参数:
.h3token:保存从浏览器 Cookie 中取得的h3_token值。cmax.json:位于“氚云代码”目录根部,使用version: 2和apps结构;根对象记录所有应用共用的engineCode、h3yunApiVersion和systemUserId,apps记录各应用信息。
新版 h3yun-cmax 将 .h3token 和 cmax.json 统一保存到“氚云代码”目录;应用目录下不再保存 cmax.json。AI 调用 query_sql 时必须通过 projectDir 传入当前 Agent 所在工作区目录或“氚云代码”目录的绝对路径。
如果 projectDir 本身就是“氚云代码”目录,MCP 只检查当前目录;否则只检查 projectDir 的直接子目录中是否有“氚云代码”目录。找到后必须同时存在 .h3token 和根 cmax.json,否则立即停止查询。MCP 不会搜索更上级、更下级或其他名称目录,也不会使用当前进程目录或环境变量中的项目路径、token、engineCode。根配置包含多个应用时,应确保传入的当前目录能够唯一确定目标应用。
如果没有找到“氚云代码”目录或凭据文件,错误信息会显示已检查的 projectDir 和当前 MCP 执行目录。当前 MCP 执行目录仅用于帮助用户判断目录是否传错,不会被用于搜索。AI 应让用户提供工作区目录或“氚云代码”目录,并将该目录作为新的 projectDir 重新调用。
示例目录:
C:\workspace\h3yun-projects
└── 氚云代码
├── .h3token
├── cmax.json
└── 示例应用(a1a2b3c)如果当前氚云代码目录下有多个应用,执行 SQL 时可直接将 projectDir 设为“氚云代码”目录,因为认证参数统一读取根 cmax.json。如果需要根据应用配置定位具体表单或字段,再将 projectDir 设为目标应用目录。
工具
query_sql
执行氚云只读 SQL 查询。
入参示例:
{
"sql": "select ObjectId, Name from h_user limit 5",
"projectDir": "D:/workspace/h3yun-app",
"reason": "查询用户基础信息"
}行为规则:
projectDir必填,值为当前工作区目录或“氚云代码”目录的绝对路径。如果
projectDir是“氚云代码”目录,只检查当前目录;否则只检查直接下一层的“氚云代码”目录。该目录必须同时存在根cmax.json和.h3token。只允许以
select或with开头的查询。实测show、describe、desc、explain会因氚云接口在 SQL 外层包装查询而执行失败。SQL 末尾的分号会自动移除。
用户未指定查询条数时,
select/with查询会默认追加LIMIT 20。氚云业务表通常是
i_表单编码,系统表通常以h_开头。
get_h3yun_sql_troubleshooting_guide
返回给 AI 使用的氚云 SQL 查询指南,说明如何根据 cmax.json、fields.md、业务表和系统表规则定位表单、字段和数据库表名。
实现约定
工具默认调用氚云平台内置接口:
SQL 预览接口:
/rx-report/integrate/data-source/v1/customsql/previewSql正式执行用户 SQL 前,工具优先读取根cmax.json中共享的systemUserId;如果缺少该字段,会先通过报表接口查询System用户的ObjectId,再用该用户上下文调用 SQL 预览接口。
请求头使用:
Authorization: Bearer <h3_token>EngineCode: <engineCode>Origin: https://www.h3yun.com
AI 使用建议
AI 在查询前应优先读取项目中的:
cmax.json:确认表单名称和表单编码,并读取根级共享的engineCode、systemUserId。fields.md:确认字段名称和控件编码。
涉及系统表时,应参考氚云系统表说明文档:
https://h3yunpro.github.io/docs/database/
开发者:本地编译与发布
npm ci
npm run build # 生成 dist/h3yun-sql-troubleshooter-<平台>-<架构>[.exe]
npm run test:smoke # 启动可执行程序做一次 MCP 握手,确认可用编译使用 Node 官方的 SEA(Single Executable Application)方案:先用 esbuild 把 src/index.js 与全部依赖打包成单个 dist/index.cjs,再把它注入当前平台的 Node 运行时,产出免安装的可执行文件。构建脚本见 build/build-sea.mjs。
发布流程见 .github/workflows/release.yml:推送 v* 或数字开头的 tag(如 v1.3.0、1.3.0)会触发 Windows / Linux / macOS(x64 与 arm64)四个平台的编译,冒烟测试通过后自动创建 GitHub Release 并附加编译产物。GitHub 自动生成的源码压缩包仍会保留,但用户只需下载编译版即可使用。
许可证
本项目采用 GNU General Public License v3.0(仅限第 3 版)许可。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Draxlr's remote MCP server connects AI assistants to your SQL databases and dashboards. Explore schemas, run read-only queries, manage saved queries and dashboards, and export results, all with row-level security so each user sees only their own data.
Related MCP Servers
- AlicenseAqualityDmaintenanceMCP server to connect MySQL DB for read-only queries. It offers accurate query execution.413 npm1MIT
- AlicenseAqualityDmaintenanceMCP server providing read-only access to SQL Server databases for AI assistants, enabling schema exploration, query execution, and foreign key inference with token-efficient TOON responses.91MIT
- AlicenseAqualityCmaintenanceA read-only MCP server for Archery that enables secure instance query, ticket management, and restricted SQL execution through AI clients.101MIT
- AlicenseAqualityBmaintenanceMCP server for Yearning SQL audit platform that enables AI assistants to query and manage orders, browse data sources and table structures, submit and review SQL orders, and execute read-only queries.1415 PyPIMIT