fix(reporter): scope MCP inventory to the current tool (#427) - #433
Merged
jeff-r2026 merged 1 commit intoSep 8, 2026
Merged
Conversation
scanMcpFromManifest merged every tool's managed MCPs via
Object.values(manifest), so a report leaked other tools' MCP servers.
In a multi-agent host (e.g. CodeBuddy + WorkBuddy on one machine),
WorkBuddy's report listed CodeBuddy's MCPs, causing downstream to treat
them as already installed and stop dispatching install commands.
Read only the current tool's manifest key (`tool` at user scope,
`${tool}:project` at project scope) — the same key installMcpServer
writes under — so MCP inventory follows the same per-tool semantics as
skills and rules.
Fixes Tencent#427
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
Fixes #427
同机多 Agent 环境下,TeamAI Reporter 为某个 Agent 上报的
user_level.mcps/workspaces[].mcps会包含其他 Agent 的 MCP。例如 CodeBuddy 装了 3 个 MCP、WorkBuddy 一个都没装时,WorkBuddy 的 report 却带上了 CodeBuddy 的 3 个 MCP。下游据此误判 WorkBuddy 已安装,不再向其下发安装命令;同时也造成 MCP 名跨 Agent 泄露。根因
scanMcpFromManifest()用for (const records of Object.values(manifest))遍历managed-mcp.json里所有工具 key 并合并,且未接收当前tool。这与 skill/rule 走toolPaths[tool]按工具隔离的语义不一致。修改
src/local-agent.ts:scanMcpFromManifest新增tool参数,只读当前工具对应的 manifest key —— user 级用tool、project 级用${tool}:project。该 key 规则与写入侧installMcpServer完全对齐(用原始 hook-context tool,不经normalizeAgentType,与写入侧一致),保证读写同源。buildReportPayload的 user 级与 project 级两处调用均传入当前tool。Test Plan
npx tsc --noEmitnpx vitest run src/__tests__/local-agent-mcp.test.tsnpx vitest run src/__tests__/local-agent.test.tsnode dist/index.js hook-dispatch session-start --tool ...发出的 report payloaduser_level.mcps=undefined端到端脚本按 issue 原文场景构造(codebuddy 拥有 mcp-a/b/c、workbuddy 零),验证后已清理,不入库;稳定回归由新增单测承载。
新增单测
src/__tests__/local-agent-mcp.test.ts:buildReportPayload does not leak another tool's MCPs (issue #427)—— 仅为 codebuddy 安装 MCP,断言 workbuddy report 的user_level.mcps为 undefined,而 codebuddy 自身 report 仍含该 MCP。