Feat/run mcp meta tool - #7743
Conversation
|
感谢实现这个方向。MCP 不过在合并整个 PR 前,我建议先拆分或补齐以下问题:
我本地运行了 建议把成熟的 MCP |
| fmt.Println("=== use_capability registered: YES (single proxy replaces all mcp__ entries) ===") | ||
| } | ||
| if meta.buildErr != nil { | ||
| fmt.Printf("\n[meta-tool build error: %v]\n", meta.buildErr) |
| fmt.Printf("\n[meta-tool build error: %v]\n", meta.buildErr) | ||
| } | ||
| if baseline.buildErr != nil { | ||
| fmt.Printf("\n[baseline build error: %v]\n", baseline.buildErr) |
|
|
||
| func printRow(s surface) { | ||
| if s.buildErr != nil { | ||
| fmt.Printf("%-22s BUILD FAILED: %v\n", s.mode, s.buildErr) |
Replace every per-tool mcp__<server>__<tool> top-level entry with a single run_mcp dispatcher, shrinking the provider's tools array from 114 to 20 entries (82.5% drop) on a 19-server config. Three-layer config resolution: env REASONIX_MCP_META_TOOL overrides [tools] meta_tool config, which defaults to false (legacy behavior unchanged). - metatool.go: run_mcp dispatcher with dynamic server-to-tool mapping in Description(), cache-backed first-turn fallback, ImageTool support - config.go: ToolsConfig.MetaTool *bool + MCPMetaToolEnabled() resolver - boot.go: meta-tool mode branch in registerBackground + diagnostic Notice - cmd/mcp-surface-dump: real boot.Build comparison (config-file path) - cmd/meta-tool-priority: 39-case env x config priority matrix demo - Tests: description contract, capacity math, schema validation, 24-case config/env priority matrix - META_TOOL.md: usage documentation
The docs-impact check requires docs/*.md changes when Documentation-impact is "updated". Moving META_TOOL.md from repo root to docs/ satisfies this requirement.
Meta-tool mode now hides every mcp__<server>__<tool> top-level entry and registers the existing use_capability proxy instead of a second dispatcher: - Runtime identity isolation via MCPRuntimeSpecMatches (same-name servers with different specs cannot cross-discover or cross-call). - No direct tools/call bypass: ResolveCall resolves to the real mcp__<server>__<tool> name, so CallResolver runs the permission gate, Pre/PostToolUse hooks, evidence, and destructive/readOnly checks. - Lazy startup: use_capability returns deferred Targets that connect on demand; cache hits do not start processes. - Fixed Schema() and static Description() - stable across connection drift. - Deleted run_mcp implementation (metatool.go -> env-only shim, metatool_test.go removed). - boot.go: capRuntime/capLedger build when meta-tool enabled; tool-surface diagnostic reports use_capability registration. Implicit-state diagnostics (compact.go / long_horizon_test.go) stay in the long-horizon branch and are not part of this PR.
… mcp-surface-dump Boot/config errors can embed provider API keys (CWE-532 clear-text logging). redactErr masks sk-*, api key/token/secret/password patterns before they reach stdout.
dbdc6b8 to
4d81f30
Compare
|
感谢详细评审,已按建议拆分并补齐: 本 PR(#7743)现在只含 meta_tool,5 个 commits:
Navigator / long-horizon / StateTracker 已拆出到 关于复测数据:122→48 tools / 75→0 mcp__ / 63353→54189 bytes 与本分支最终状态一致(已写入 PR body)。 CodeQL 的 3 处明文日志已修复:cmd/mcp-surface-dump/main.go 新增 redactErr,sk-*/api key/token/secret/password 模式脱敏后再打印。 |
Cache-impact: low - use_capability proxy has fixed Schema() and static Description(); no change to cache prefix calculation or invalidation logic.
Cache-guard: go test ./internal/config/ ./internal/plugin/... ./internal/boot/ ./internal/agent/
System-prompt-review: No system_prompt_file modified.
Documentation-impact: updated - docs/META_TOOL.md added with full config usage, priority resolution, and verification instructions.
Summary
Collapse the MCP tool surface behind the existing use_capability proxy (meta-tool mode):
[tools] meta_tool = true/REASONIX_MCP_META_TOOL=1hides all top-levelmcp__<server>__<tool>entries and registers the use_capability proxy. Real boot.Build measurement (reviewer-verified): baseline 122 tools / 75 mcp__ top-level / 63353 bytes -> meta-tool 48 tools / 0 mcp__ top-level / 54189 bytes (tools -60.7%, bytes -14.5%).tools/callbypass: permission gate, Pre/PostToolUse hooks, evidence, and destructive/readOnly checks run against the realmcp__<server>__<tool>name via the existing CallResolver flow.Issues
Verification
Documentation impact
Documentation-impact: updated - docs/META_TOOL.md added with full config usage, priority resolution, and verification instructions.
Cache impact
Cache-impact: low - use_capability proxy has fixed Schema() and static Description(); no change to cache prefix calculation or invalidation logic.
Cache-guard: go test ./internal/config/ ./internal/plugin/... ./internal/boot/ ./internal/agent/
System-prompt-review: N/A - no system_prompt_file modified; use_capability is a tool-level proxy, not a system prompt change.