Feat/run mcp meta tool
Cache-impact: low - run_mcp changes tool registration but preserves cache-backed schema fallback for first-turn correctness; no change to cache prefix calculation or invalidation logic. Cache-guard: go test ./internal/plugin/ -run TestMetaTool; go run ./cmd/mcp-surface-dump/ confirms 20-tool registry. System-prompt-review: No system_prompt_file modified. run_mcp Description() is a tool-level dynamic description, not a system prompt change. Documentation-impact: updated - META_TOOL.md added with full config usage, priority resolution, and verification instructions.## Summary
-
Issues
Verification
-
Documentation impact
Documentation-impact: TODO
For changes to user-visible CLI, Desktop, configuration, provider, permission, or tool behavior, use one of:
Documentation-impact: updated - <what changed>and updatedocs/*.md.Documentation-impact: none - <why the embedded documentation remains correct>.
Cache impact
Cache-impact: TODO Cache-guard: TODO System-prompt-review: N/A
For cache-sensitive changes, fill these lines before requesting review:
Cache-impact:none,low,medium, orhigh, plus the reason.Cache-guard: the focused guard test/command added or run, or why an existing guard covers the change.System-prompt-review: required reviewer/approval note when provider-visible system prompt, memory prefix, output style, or skill index behavior changes.
Cache-impact: low - run_mcp changes tool registration but preserves cache-backed schema fallback for first-turn correctness; no change to cache prefix calculation or invalidation logic. Cache-guard: go test ./internal/plugin/ -run TestMetaTool; go run ./cmd/mcp-surface-dump/ confirms 20-tool registry. System-prompt-review: No system_prompt_file modified. run_mcp Description() is a tool-level dynamic description, not a system prompt change. Documentation-impact: updated - META_TOOL.md added with full config usage, priority resolution, and verification instructions.
感谢贡献。减少大量顶层 MCP schema、降低上下文占用这个方向是有价值的;不过当前 run_mcp 实现绕开了 Reasonix 已有的 MCP 安全与生命周期边界,目前还不适合合并。请优先处理以下阻塞项:
-
共享 Host 的运行时身份隔离。
snapshotServerTools()枚举Host.ServerNames()中的全部客户端,ExecuteWithImages()和KickSpawns()又分别通过host.client(name)/HasClient(name)仅按名称查找。Reasonix 会在多个 controller/项目间共享 Host,同名 server 并不代表相同 endpoint、凭证或项目配置。这会让当前会话暴露或调用另一个项目的 MCP。这里必须限定为当前 specs,并使用HasClientForSpec/ToolsForSpec或等价的完整 runtime identity 校验。 -
不要直接绕过真实 MCP tool 的执行边界。 当前代码直接调用
c.call("tools/call", ...),因此remoteTool.Execute中对 server authorization、readOnlyHint、destructiveHint的最终复核没有执行;permission、Pre/PostToolUse hooks、evidence 和 mutation tracking 也只看到统一的run_mcp,原有针对mcp__<server>__<tool>的精确 allow/ask/deny 规则会失效。分发器应解析到真实 tool,让现有CallResolver流程针对真实名称、参数和安全属性执行,而不是直接调用 client。 -
保留 lazy startup 和 generation 语义。
KickSpawns()会在启用后立即启动全部 MCP,包括原本 cache hit 时保持休眠的 server;同时它调用registerDeferredCancel()却丢弃返回的 generation,使 remove 与后台握手完成竞态时,旧 generation 可能在移除后重新发布 client。应继续按需连接,并在线性化发布前复核 generation。 -
当前工具发现不足以可靠调用,也不能保持缓存稳定。
run_mcp的 Description 只列工具名,没有用途和参数 schema,模型无法可靠构造args;冷缓存首轮还会得到 “No MCP servers”。另一方面Registry.Schemas()每轮都会重新读取动态 Description,连接完成、热添加或工具漂移都会改变 provider-visible prefix,因此这里的 Cache-impact 不能简单归类为 low。
仓库现有的 use_capability 已经提供稳定的 provider schema,以及 list / inspect / call、按需连接、真实 tool 级 permission/hook/evidence、运行时身份和 destructive/readOnly 复核。建议把 meta_tool 模式改为:隐藏直接 mcp__* surface,并复用/扩展 use_capability,而不是维护第二套简化 dispatcher。
建议补充以下回归测试:
- 共享 Host 中两个 controller 配置同名但不同 identity 的 server,不能互相发现或调用;
- 精确 MCP deny/hook 仍匹配真实 tool,authorization/destructive drift 在
tools/call前 fail closed; - cache hit 不启动进程,冷缓存可显式发现,remove 后旧 generation 不会复活;
- MCP 连接、热添加和 tool-list drift 不改变稳定 proxy 的 schema/description 字节。
另外,当前新增的 8 个 Go 文件仍未通过 gofmt,git diff --check 也报告 internal/plugin/metatool_test.go 文件末尾多余空行;最新 head 目前只有 cache/docs/label guard 通过,尚无完整 CI 结果。
完成上述架构调整和验证后,这个方向值得继续评审。