Feature(Go): verify_tools --subset and MCP deployment docs
Add a third mode to verify_tools.py that validates the Go server end to end: it fetches /mcp tools/list and requires the name set to equal the nine implemented tools exactly (seven in readonly mode), compares description / inputSchema / outputSchema field by field against mcp/tools.json, and also checks the published order. Unlike --live, extra or missing tools are failures, not notes. The field-comparison loop is factored into report_field_diffs so --offline / --live and --subset share one comparison, diff printer and FIELDS tuple. Document and deploy the endpoint: the systemd env example gains YAMA_MCP_TOKEN / READONLY / TERM_IDLE / MAX_CONCURRENCY / READ_MAX, the design doc moves to implemented and its section 10 now matches the code (embedded tools_minimal.json, the three packet dispatch groups). The tools README explains gen_go_tools.py --check and --subset. Verified against a freshly built debug Go server on 16543/18090: read-write mode passes with 9 tools, YAMA_MCP_READONLY=1 passes with 7, and both mismatch directions (extra tools, missing tools) fail with exit 1. gen_go_tools.py --check stays clean; no Go code changed. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
9ce1a58bc3
commit
d4f10db1f2
4 files changed
+192
-39
No files matched your search
@@ -14,7 +14,8 @@ inputSchema、outputSchema,以及运行时不可见的开关元信息(`gate`
|
||||
| `mcp/tools.json` | 工具清单本体(生成产物,勿手工编辑) |
|
||||
| `tools/mcp_tools/dump_tools.py` | 从运行中的服务端抓 `tools/list` |
|
||||
| `tools/mcp_tools/make_tools_json.py` | 把抓取结果转成 `tools.json`(含 gate / platforms 表) |
|
||||
| `tools/mcp_tools/verify_tools.py` | 校验 `tools.json` 与服务端是否一致 |
|
||||
| `tools/mcp_tools/verify_tools.py` | 校验 `tools.json` 与服务端是否一致(含 Go 端 `--subset`) |
|
||||
| `tools/mcp_tools/gen_go_tools.py` | 从 `tools.json` 抽取 Go 端 9 个工具,生成 `server/go/mcp/tools_minimal.json` |
|
||||
| `tools/mcp_tools/check_platform_table.py` | 校验 `tools.json` 的 `platforms` 与 C++ `kToolPlatforms` 一致 |
|
||||
|
||||
## 更新流程
|
||||
@@ -191,11 +192,26 @@ python tools/mcp_tools/check_platform_table.py
|
||||
|
||||
## 与 Go 服务端的关系
|
||||
|
||||
`impl` 字段就是给 Go 端裁剪用的:标 `mfc` 的工具表示 Go 端还没有对应能力。
|
||||
Go 端补齐某个工具的底层命令后,把它改成 `both`。
|
||||
Go 最小服务端(`server/go`,设计见 `docs/Mcp_Go_Minimal_Design.md`)实现 9 个工具。
|
||||
它的 `tools/list` **不是手写的**:`gen_go_tools.py` 从 `tools.json` 原样抽取这 9 个工具
|
||||
生成 `server/go/mcp/tools_minimal.json`,再由 `//go:embed` 编进二进制。
|
||||
|
||||
注意 Go 端目前只有 5 类客户端命令(`SCREEN_SPY` / `NEXT` / `SCREEN_CONTROL` /
|
||||
`BYE` / `SHELL`),所以短期内 `impl: both` 的工具不会多。
|
||||
改完 `tools.json` 之后:
|
||||
|
||||
```bash
|
||||
# 重新生成嵌入副本(--check 只检查是否为最新,CI 友好)
|
||||
python tools/mcp_tools/gen_go_tools.py
|
||||
python tools/mcp_tools/gen_go_tools.py --check
|
||||
|
||||
# 抓 Go 端线上 tools/list,与 tools.json 逐字段比对
|
||||
# 读写模式恰好 9 个;YAMA_MCP_READONLY=1 时恰好 7 个(隐藏 terminal_*)
|
||||
python tools/mcp_tools/verify_tools.py --subset mcp/tools.json <token> <port>
|
||||
python tools/mcp_tools/verify_tools.py --subset mcp/tools.json <token> <port> --readonly
|
||||
```
|
||||
|
||||
`--subset` 与 `--live` 的差别:前者**名字集合必须恰好等于** 9(或 7),多一个少一个
|
||||
都失败;后者只报双方差异。`impl` 字段的 `mfc` / `go` / `both` 目前仍是人工维护的
|
||||
元信息,脚本不据此推断。
|
||||
|
||||
## 前置条件
|
||||
|
||||
|
||||
Reference in new issue
Block a user