MCP 工具协议
@hover-dev/mcp 是一个标准的 Model Context Protocol server。你的编码 agent 通过 stdio 连接到它;该 server 暴露一小组 tools 和一个 prompt。添加一次,你的 agent 就同时拥有两者:
npm i -g @hover-dev/mcp
claude mcp add hover -- hover-mcp
配置(环境变量)
server 从其宿主设置的环境中读取目标:
| 变量 | 默认值 | 用途 |
|---|---|---|
HOVER_TARGET | http://localhost:5173 | 被测应用 —— 引擎用来匹配 CDP 标签页的 origin。 |
HOVER_CDP_PORT | 9222 | debug Chrome 的远程调试端口。 |
HOVER_PROJECT_ROOT | process.cwd() | __vibe_tests__/ 和 .hover/ 的写入位置。 |
Tools
每个工具都返回一段简短的文本结果(✓ / ✗),且从不抛出异常 —— 一次失败的定位或操作会变成一条 ✗ 消息,供调用方 agent 作出反应,而不是变成一个传输错误。
| Tool | 输入 | 用途 |
|---|---|---|
browser_navigate | { url } | 在被测应用中打开一个 URL。 |
browser_snapshot | {} | 以 ARIA 快照(role + accessible-name 树)形式返回页面。在操作前调用。 |
click_control | grounded target | 按 role+name → testId → text 点击一个控件。 |
fill_control | grounded target + { value } | 向一个 textbox / 字段输入一个值。 |
select_control | grounded target + { value } | 在 <select> 中选择一个选项。 |
check_control | grounded target + { checked? } | 勾选 / 取消勾选一个 checkbox 或 radio。 |
assert_visible | grounded target | 断言当前可见 —— 捕获 expect(...).toBeVisible()。 |
recall_business_knowledge | {} | 回忆早前运行对这个应用所学到的内容。 |
record_fact | { title, rule, type? } | 持久化一条持久的业务规则(仅限规则 —— 不含 secret / PII)。 |
crystallize_spec | { name, description? } | 把录制下来的 grounded flow 保存为 __vibe_tests__/ 下的一个 plain Playwright spec。 |
grounded target 的结构
{
role?: string; // ARIA role from the snapshot — pair with name
name?: string; // accessible name, exactly as shown — pair with role
testId?: string; // a data-testid, if no clean role+name exists
text?: string; // real visible text — last resort
within?: { role: string; name: string }; // scope to a container first
}
record_fact 的类型
type 是 business-rule(默认)、expected-behavior、validation 或 access-policy 之一。该 fact 会写入 .hover/memory/ 下 —— 参见 你的应用的测试知识。
Prompt
| Prompt | 参数 | 用途 |
|---|---|---|
test_app | { scope? } | 分阶段、随规模自适应的授权工作流。Claude Code 将其呈现为 /mcp__hover__test_app。省略 scope 以覆盖整个应用,或传入一个区域 / flow 以聚焦。 |
权威定义请参见 packages/mcp/src/mcp/server.ts 及它所封装的 controller。