
让AI助手访问DBHawk:列出用户分配的数据源,浏览模式/表/列,运行查询(应用用户访问控制和列遮罩),并使用......
概览
赋予 AI 助手访问 DBHawk:列出用户分配的数据源,浏览模式/表/列,运行查询(应用用户访问控制和列遮蔽),并使用文本转 SQL / 优化 / 格式化。数据或模式的更改仅在用户允许时实现——默认层级为只读(参见读取、写入和 MCP 层级)。 它是现有 DBHawk REST 表面上的一个薄桥,位于 /api/v2/mcp/。DBHawk 决定运行什么:每个语句都被分类并与用户组的层级对比,无论令牌拥有者的角色如何。 DBHAWK_TOKEN 是一个个人令牌(dbh_ . ),一个 JWT——MCP 端点不会直接接受它。在第一次调用时,服务器会在 POST /api/v2/auth/token/exchange 交换它与一个短寿命的 JWT(在 X-API-Token 头部发送个人令牌),缓存该 JWT,并作为每次 /api/v2/mcp/ 调用的承载发送。
概述(AI 翻译)
允许AI助手访问DBHawk:列出用户分配的数据源,浏览 schema/tables/columns,运行查询(应用用户访问控制和列遮罩),并使用 DBHawk AI 文本转 SQL / 优化 / 格式化。数据或模式的更改仅在用户 MCP 层允许它们——默认层是只读(参见读、写和 MCP 层)。
它是在现有DBHawk的REST surface上方的一条薄桥,位于/api/v2/mcp/**。DBHawk决定运行:
每个语句都会被分类并与用户组的层级对照,无论令牌角色为何
老板有。
登录,或使用个人令牌。 保持DBHAWK_TOKEN空,服务器通过
浏览器在第一个工具调用时打开:DBHawk登录页面打开(密码、LDAP、2FA或SSO——随你DBHawk使用哪种方式)
你批准一次访问,服务器会在你的用户档案中保留一个刷新令牌,准备下一次
在Windows上开始(%APPDATA%\dbhawk-mcp,macOS上~/Library/Application Support/dbhawk-mcp,~/.config/dbhawk-mcp
在 Linux 上)。这需要 DBHawk 7.0.1 和 MCP 连接器;你可以做什么取决于你的 MCP 层级,正如
带有令牌。参见 UPGRADE-7.1。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
DBHawk MCP — Claude Code plugin + demo connector
Gives an AI assistant access to DBHawk: list the datasources a user is assigned, browse schema/tables/columns, run queries (with the user’s access control and column masking applied), and use DBHawk AI text-to-SQL / optimize / format. Data or schema changes are possible only when the user’s MCP tier allows them — the default tier is read-only (see Reads, writes and MCP tiers).
It’s a thin bridge over the existing DBHawk REST surface at /api/v2/mcp/**. DBHawk decides what runs:
every statement is classified and checked against the tier of the user’s groups, whatever role the token
owner has.
Sign in, or a personal token. Leave DBHAWK_TOKEN empty and the server signs in to DBHawk through the
browser on the first tool call: the DBHawk login page opens (password, LDAP, 2FA or SSO - whatever your DBHawk
offers), you approve the access once, and the server keeps a refresh token in your user profile for the next
start (%APPDATA%\dbhawk-mcp on Windows, ~/Library/Application Support/dbhawk-mcp on macOS, ~/.config/dbhawk-mcp
on Linux). This needs DBHawk 7.0.1 with the MCP connector; what you may do is decided by your MCP tier, exactly as
with a token. See UPGRADE-7.1.0.md.
With a personal token, auth is two steps. DBHAWK_TOKEN is a personal token (dbh_.), not a JWT — the
MCP endpoints won’t accept it directly. On its first call the server exchanges it for a short-lived JWT
at POST /api/v2/auth/token/exchange (sending the personal token in the X-API-Token header), caches
that JWT, and sends it as the Bearer for every /api/v2/mcp/** call. Shortly before the JWT’s exp the
server exchanges a fresh one up front; if a call still gets a 401 it re-exchanges and retries once —
transparent to you.
dbhawk-mcp-plugin/ <- this folder = a Claude Code "marketplace" (push it to git)
├── .claude-plugin/marketplace.json
└── dbhawk/ <- the actual plugin (installed by users)
├── .claude-plugin/plugin.json
├── .mcp.json <- declares the "dbhawk" stdio MCP server
└── mcp-server/
├── index.js <- source
├── package.json <- build tooling (maintainers only)
└── dist/dbhawk-mcp.mjs <- COMMITTED self-contained bundle (what users run; no npm install)
The bundle in dist/ inlines every dependency, so a bare git clone runs with zero install —
that’s what makes /plugin install work.
For users — install
Claude Code (from the marketplace)
Once this repo is on GitHub (see Publish below), point Claude Code at it and install:
/plugin marketplace add datasparc/dbhawk-mcp-plugin
/plugin install dbhawk@dbhawk-marketplace
dbhawk is the plugin name, dbhawk-marketplace is the marketplace name (from marketplace.json).
安装
npx @anthropic-ai/mcpb validate mcpb/manifest.json # optional sanity check配置
{
"mcpServers": {
"dbhawk": {
"command": "C:\\Program Files\\nodejs\\node.exe",
"args": ["C:\\...\\dbhawk-mcp-plugin\\dbhawk\\mcp-server\\dist\\dbhawk-mcp.mjs"],
"env": {
"DBHAWK_BASE_URL": "https://demo.dbhawk.example.com",
"DBHAWK_TOKEN": "PASTE_MCP_TOKEN_HERE",
"DBHAWK_DEFAULT_DATASOURCE": ""
}
}
}
}