fix(agent-mcp): use the configured server name for sdk tool names #21322
This comment was translated automatically.
Conflict resolution landed: rebased to latest main, head dc39005176.
Upstream #17610 (MCP SDK v2) conflicted with this PR in the same two files, handled as follows:
Semantic Decision (both orthogonal, both preserved)
AgentMcpServer.instance → connect(transport), snapshot missing throws error, bridge factory lazified. This PR changed record key semantics (register with config name). Both don't conflict: buildMcpServers in mcpCatalog.ts still uses record key as SDK config key (source of mcp__<key>__<tool> tool name prefix), the fix in this PR remains necessary under the new sleeve structure.piMcpExtension.ts uses server.id ?? server.name, doesn't read record key) and DSH (buildDshCherryToolBridge tool naming uses server.name field) are both unaffected by the key name change.Upstream New Test Adaptation (disclosure)
mcp-1 (old key name behavior); per this PR's semantics the key should now be the snapshot server's config name Old server, updated that assertion (bridge still binds to id, toHaveBeenCalledWith('mcp-1', ...) assertion kept as-is).{ type: 'sdk', name, instance: { connect } }; after bridge factory lazification, uses passthrough capture serveStdio to drive factory, proving bridge still binds to server id not record key.Verification: 167/167 tests green in both affected test files; tsc --noEmit zero errors across four projects; oxlint/eslint/oxfmt all clean on changed files.
---
<details>
<summary>Original Content</summary>
冲突解决落地:已 rebase 到最新 main,head dc39005176。
上游 #17610(MCP SDK v2)与本单在同两个文件相撞,处理如下:
语义裁决(双方正交,均保留)
AgentMcpServer.instance → connect(transport)、快照缺失抛错、bridge 工厂惰性化。本单改的是 record key 语义(用配置名注册)。两者不冲突:mcpCatalog.ts 的 buildMcpServers 仍以 record key 作为 SDK config key(mcp__<key>__<tool> 工具名前缀来源),本单修复在 sleeve 新结构下依然必要。piMcpExtension.ts 用 server.id ?? server.name,不读 record key)与 DSH(buildDshCherryToolBridge 工具命名用 server.name 字段)均不受键名变更影响。上游新测试适配(披露)
mcp-1(旧键名行为);按本单语义该键现应为快照 server 的配置名 Old server,已更新该断言(bridge 仍绑定 id 的 toHaveBeenCalledWith('mcp-1', ...) 断言原样保留)。{ type: 'sdk', name, instance: { connect } };bridge 工厂惰性化后改用透传 capture serveStdio 驱动工厂,证明 bridge 仍绑定 server id 而非 record key。验证:两个受影响测试文件 167/167 绿;tsc --noEmit 四项目零错误;oxlint/eslint/oxfmt 改动文件全净。
</details>
Must fix: A mounted server named __proto__ passes schema and service validation, but assigning it to this ordinary {} changes its prototype instead of adding an enumerable entry. Claude and DSH use Object.entries, and Pi uses Object.values, so all three silently omit this server and its tools. The previous UUID key preserved it. Use a null-prototype record or safe own-property insertion, and add a regression test for this accepted name.
inv_44d81942c8936c54#f1
Must fix: The fallback mcpId is not guaranteed to be free. Mount A before B, give A a configured name equal to B’s UUID, and name B skills. A occupies B’s UUID key; B then falls back to that same key because skills is reserved, silently overwriting A and removing its tools from every runtime. Both names are accepted, and the baseline retained both servers. Reserve mounted-server IDs before allocating configured names, or otherwise guarantee fallback uniqueness, and test that both entries survive.
inv_0d0c589c6c622eb9#f1
Two narrow but confirmed regressions silently drop mounted MCP servers: the accepted name __proto__ creates no enumerable entry, and an unchecked UUID fallback can overwrite another server. Both affect the shared map consumed by Claude, DSH, and Pi. Please fix both allocation cases and add regression coverage.
Frozen-head CI records 13 successful and 5 skipped Check Runs. Legacy status has zero contexts; frozen-pair merge CI is unavailable. Review used static analysis; no local project tests ran, and CI logs were unavailable. Maintainer confirmation of the configured-name tool-identity behavior also remains outstanding under the review’s product-decision gate.
Cherry Review · Blocked
2 blocking
See inline comments for individual findings.
<!-- cherry-review:run=093e9d6ddbcd1785 -->
Fixed in 8c5b0619b2: the record is now built with a null prototype, so a server configured as __proto__ registers as its own enumerable key instead of mutating the prototype. The regression test (keeps a server named __proto__ as an own enumerable key..., src/main/ai/runtime/agentMcpServers.test.ts) fails on the parent commit - Object.keys loses the entry - and passes here.
Fixed in 8c5b0619b2: every mounted server's id is reserved before configured names are allocated, so the id fallback can no longer collide - the exact A/B scenario from this thread now keeps both entries. Regression test (keeps every mounted server when a fallback id collides with another server key) is red on the parent commit (A is silently overwritten) and green here.
Must fix: Changing this namespace invalidates existing agent-level denials such as mcp__<server UUID>__run: a server named github now exposes mcp__github__run, while resolveDisallowedTools() preserves the saved rule and Cherry's isDisabled() guard checks exact names. This configuration is accepted and persisted through the agent DataApi. An explicitly disabled tool can consequently execute in Full Access without the intended denial. Preserve or translate saved denials using stable server identity, and add regression coverage for an existing UUID-based rule across this change.
inv_65c7909519ba8aba#f1
Must fix: Two valid mounted servers can now generate the same DSH tool identity: server docs exposing search__all and server docs__search exposing all both become mcp__docs__search__all. These names pass validation, and the bridge preserves this provider-safe identifier. DshCherryToolBridge then throws on the duplicate, closes connections and fails the entire turn before prompt admission. The former distinct UUID namespaces kept these tools separate. Guarantee uniqueness of final tool identities, for example with stable identity suffixes on collisions, while retaining readable prefixes and consistent policy mappings.
inv_4a52b28e1d0c44c6#f1
Two regressions require changes: saved agent-level MCP denials can stop matching after the namespace change, and valid server/tool pairs can collide and prevent DSH turns from starting. The earlier prototype and fallback-ID defects are fixed. Maintainer confirmation of the public tool-identity contract remains unrecorded.
Frozen-head CI: 13 successful and 17 skipped Check Runs; legacy status has zero contexts. Frozen-pair merge CI is unavailable. Review used static source inspection and independent verification; no project tests ran locally, SDK execution was not reproduced, and CI logs were unavailable.
Cherry Review · Blocked
2 blocking
See inline comments for individual findings.
<!-- cherry-review:run=ea8c882fb0577316 -->
Fixed in 4cadf1abf4. Mounted-server keys now come from a shared allocator (resolveAgentMcpServerKeys in agentMcpServers.ts) that mirrors the record build's allocation exactly, and every consumer rewrites legacy id-keyed rules before exact-name matching: the SDK disallowedTools hard-block list (settingsBuilder), the live policy snapshot's isDisabled (agentTools), and the dsh pushed policy on both connect and reconcile. Pi already matched mcp__<serverId>__<tool> directly and needs no change. Regression test: a legacy mcp__<uuid>__run rule now disables mcp__github__run (agentTools.test.ts, red on the parent commit), and the key map is pinned to the record allocation in agentMcpServers.test.ts.
Fixed in 4cadf1abf4. buildDshCherryToolBridge no longer throws on a flattened collision: the first pair keeps the readable wire name (mcp__docs__search__all) and a later one gets a deterministic 12-hex sha256 suffix of the raw server/tool pair, still within the 63-char provider-safe cap, so both tools stay registered and routable to their own server. Regression tests cover the exact docs/docs__search case, two same-named servers, and lossy-normalized tools within one server (DshCherryToolBridge.test.ts; the first two are red on the parent commit).
Must fix: Translate denials through the bridge’s final allocated tool identities. For a UUID-mounted server named Old server exposing run, the saved mcp__<UUID>__run denial becomes mcp__Old server__run, but the executable tool is mcp__oldServer__run_4f7413c24ae4. The plugin’s exact match misses the denial and Full Access permits execution; the baseline UUID name matched. Reconciliation at line 603 repeats the mismatch. Share a stable-server/raw-tool-to-runtime-name mapping with startup and reconciliation, including normalization and collision suffixes.
inv_740771ad070431b8#f1
Must fix: The counter never changes the candidate: SHA-256 already supplies 64 hex characters, so (hash + String(counter)).slice(0, 12) always returns the same prefix. Mounting docs with tools search__all and search__all_353988fff1e9, followed by docs__search with tool all, occupies both the plain name and its hash fallback. This loops forever synchronously in Electron main, freezing startup and main-process responsiveness. Make the counter affect the retained suffix and ensure allocation terminates.
inv_247e01908a8ceb9f#f1
Must fix: Refresh the captured server mapping when reusing the policy snapshot for a new connection. Prewarm under server name old, rename it to new, connect without a denial, then add mcp__<UUID>__run during an active turn: ensureToolPolicySnapshot() retains the old options, and warm-signature mismatch disposal does not clear that snapshot. The live guard blocks mcp__old__run instead of executable mcp__new__run. Startup SDK restrictions cannot cover the later-added rule, so Full Access can execute it while rebuilding is deferred. Update mapping state while preserving the shared snapshot used by live hooks.
inv_c8ce0a9103d90bf5#f1
Changes requested at 4cadf1abf479633569c012f216c25456cb40f157: DSH denial translation can allow explicitly disabled tools, DSH collision retries can freeze Electron main, and a stale Claude policy mapping can miss a denial added during an active turn after prewarm and rename.
Frozen-head CI: 8 successful, 8 in progress, 14 skipped Check Runs. Legacy status has zero contexts; frozen-pair merge CI is unavailable due to mismatched parents. Review used source analysis and reported isolated naming experiments; no project tests or application reproduction ran, and CI logs were unavailable. Maintainer approval of the public naming change is not established in the supplied context.
Cherry Review · Blocked
3 blocking
See inline comments for individual findings.
<!-- cherry-review:run=4cea8a2c1901cdbe -->
Fixed in 8d9be7de8f: the bridge now exposes its mcp__<server name>__<raw tool> -> runtime-name mapping (ruleNames), and DshRuntimeConnection translates denial rules through it on both startup and reconcile. A legacy mcp__<UUID>__run rule now lands on the identity the bridge actually registered (mcp__oldServer__run_4f7413c24ae4 in your example); rules with no registered identity pass through unchanged.
Fixed in 8d9be7de8f: the counter now reaches the retained suffix by rehashing server\0tool\0<counter> (the old (hash + counter).slice(0, 12) always read the same 12 head chars of the 64-hex digest), and allocation is bounded - after 1000 candidates it throws instead of freezing the main process. Your taken-fallback scenario is a regression test now; on the pre-fix code the suite hangs indefinitely (the sync loop starves the worker's event loop, so even the test timeout cannot fire).
Fixed in 8d9be7de8f: ClaudeAgentToolPolicySnapshot.update() now accepts a fresh serverNameById, and ensureToolPolicySnapshot passes the caller's current mapping on the warm-hit path - the rebuild after a mid-session rename translates id-keyed rules under the new key, so a later-added mcp__<UUID>__run blocks the executable mcp__new__run instead of the stale mcp__old__run. The shared snapshot instance is preserved (live hooks still resolve it by session id).
Must fix: Mount distinct UUID-backed servers named docs and docs__search, exposing search__all and all. Both write the rule key mcp__docs__search__all, although their executable names are distinct. The second mapping overwrites the first, so a saved UUID-based denial for the first tool translates to the second executable instead. Startup and reconciliation propagate this incorrect denial to exact-match enforcement, leaving the intended tool executable under Full Access. Preserve stable server-ID/raw-tool identity through translation and map it directly to the allocated runtime name.
inv_e4c4d7ef9ac60821#f1
Must fix: Existing DSH runtime denials can use normalized and hashed names. For UUID aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa and tool this_is_a_long_tool_name_for_search, the baseline name was mcp__aaaaaaaaAaaa4aaa8aaaAaaaaaaaaaaa__thisIsALong_90a915510650. The agent PATCH API accepts and persists this denial, and baseline exact matching enforced it. Mounting the server as docs now changes its executable name, but this raw-ID lookup and the bridge map both leave the old denial unchanged. The formerly disabled tool can therefore execute under Full Access. Reconstruct previous DSH runtime aliases from server IDs and raw catalogs and map them to current allocated identities.
inv_c8026c7dd363caa1#f1
Two blocking DSH permission regressions: ambiguous server/tool names can redirect an existing denial to the wrong tool, and previously saved hashed runtime denials stop matching after configured-name mounting. Both can permit explicitly disabled tools under Full Access.
Captured head CI: 1 successful check, 20 skipped, 8 running, 7 queued; legacy status has zero contexts. Frozen-pair merge CI is unavailable. Review used source tracing and isolated reviewer experiments; no project tests or application reproduction ran.
Cherry Review · Blocked
2 blocking
See inline comments for individual findings.
<!-- cherry-review:run=2341754f0b96df7b -->
Fixed in 07a6a14427. The bridge rule map no longer keys denials by the ambiguous flattened string alone: it now also registers an exact <serverKey>\u0000<rawTool> pair identity, and translateMcpToolRulesToRuntimeNames preserves the split point of an id-keyed rule so a uuid-keyed denial resolves onto its own pair's allocated name even when a second pair flattens to the same rule string. For already-flattened name-form denials (which genuinely cannot say which pair they meant) the lookup now maps the string to every candidate — over-blocking instead of letting an explicitly disabled tool execute. Verified: new bridge test keeps both colliding identities resolvable (pair-exact + merged fail-closed), new translator test pins the id-keyed denial to its own pair, full dsh + claudeCode-adjacent suites 441 passed, tsc clean, oxlint/oxfmt clean on the touched files.
Fixed in 07a6a14427. The bridge now reconstructs the pre-name DSH runtime aliases from every known mounted-server id (the same buildDshCherryToolName(id, rawTool) construction the runtime used before configured-name registration, covering both the wire-safe mcp__<id>__<tool> form and the hashed lossy mcp__<camelized>__<camelized>_<sha256-12> form in your example) and maps each onto the currently allocated name, so a persisted hashed denial follows its server after it starts registering under the configured name. Verified: new bridge test asserts the hashed alias key resolves to the current identity for a uuid-mounted long tool name, full dsh + claudeCode-adjacent suites 441 passed, tsc clean, oxlint/oxfmt clean on the touched files.
Must fix: Preserve allocated runtime identities in this lookup as well as raw aliases. Mount UUID-backed A (Old server / run) before B (oldServer / run_4f7413c24ae4): A receives mcp__oldServer__run_4f7413c24ae4, while B receives a collision suffix. A's runtime string is indexed only as B's raw alias, so saving it in disabledTools replaces A's denial with B's allocated name. Startup and reconciliation propagate this replacement, and the exact-match DSH policy allows A under Full Access. Merge each allocated runtime identity into the fail-closed candidate map and add a regression test for this collision.
inv_812e93ec164f5f6b#f1
Must fix: Update the metadata catalog alongside this key allocation. Mount UUID-backed A and B, both named docs and exposing run: A registers under docs, B under its UUID, but claudeCode/mcpCatalog.ts:87–88 lets B overwrite metadata for mcp__docs__run. streamAdapter.ts:1789,1808–1811 consequently assigns B's server ID and description to A's calls and results, including persisted provenance. Execution still routes to A. Build authoritative metadata entries from the same allocated runtime keys and prevent compatibility aliases from overwriting them.
inv_4bbaa63043d6c8a2#f1
Two confirmed regressions require changes: DSH collision translation can remove an explicit tool denial, and Claude name collisions can assign another server’s identity to calls and persisted results. Head CI snapshot: 12 successful, 14 skipped, 5 in progress, no failures; legacy status had zero contexts. Frozen-pair merge CI was unavailable. Verification used source tracing and isolated naming experiments; no local project tests or application reproduction ran.
Cherry Review · Blocked
2 blocking
See inline comments for individual findings.
<!-- cherry-review:run=20c5a423f33165eb -->
Fixed in 454a6499c9: buildMcpToolMetadata now claims metadata first under the same allocated record keys the runtime registers (resolveMountedAgentMcpServers), so mcp__docs__run resolves to the server that actually registered that key, and compatibility aliases (uuid/name forms, catalog id) never overwrite a runtime-key entry. Regression test (mcpCatalog.test.ts) mounts two UUID-backed servers both named docs exposing run: red on the parent commit (B's metadata won mcp__docs__run), green here; uuid-form lookups for both servers are unchanged.
Fixed in 454a6499c9: each registered runtime identity now claims its own name in the fail-closed candidate map, so a denial saved under A's runtime string (mcp__oldServer__run_4f7413c24ae4) translates to both candidates ([aRuntime, bRuntime]) instead of being rewritten onto B's disambiguated name alone — the exact-match policy keeps blocking A, with B's candidate merged fail-closed like every other ambiguous form. Regression test (DshCherryToolBridge.test.ts) mounts Old server/run before oldServer/run_4f7413c24ae4: red on the parent commit (translated to B's name only), green here.
Must fix: Preserve saved denials across collision reallocations. Mount docs/search__all before docs__search/all, then persist the second tool's allocated name, mcp__docs__search__all_353988fff1e9, in disabledTools through PATCH /agents/:agentId. After removing the first server and reconnecting, the remaining tool becomes mcp__docs__search__all. The rebuilt lookup omits its previous suffixed identity, so translation leaves the obsolete denial unchanged and the exact-match policy allows the tool under bypassPermissions. Resolve denials through stable server/tool identities, retain compatibility for saved collision names, and add a reconnect regression test.
inv_89f0638bcccfdfc6#f1
Must fix: Register every exact runtime tool name before adding camelized aliases. When a docs server lists search_docs before searchDocs, this line assigns the first tool's metadata to mcp__docs__searchDocs; first-wins insertion then rejects the second tool's exact entry. streamAdapter.ts uses that entry for the display name and description, so calls and persisted results for searchDocs receive search_docs metadata. Execution remains correctly routed, but the recorded metadata is incorrect. Move camelized aliases into a later pass and test this alias/exact-name collision.
inv_7af8200c111553d7#f1
Two confirmed regressions require changes: a saved DSH denial can stop blocking after a colliding server is removed, and Claude metadata aliases can capture another tool's exact identity.
Frozen-head CI snapshot: 15 successful checks, 3 renderer shards in progress, 2 skipped. Legacy status has zero contexts; merge CI is unavailable for the frozen parent pair. Verification used source tracing and isolated verifier experiments; no project tests or live SDK/application sessions were run.
Cherry Review · Blocked
2 blocking
See inline comments for individual findings.
<!-- cherry-review:run=5f593bd95e553737 -->
Fixed in fda31efb79: exact mcp__<key>__<tool> entries are now claimed for every tool before any camelized alias runs — camelized key-form aliases moved into the compatibility pass (first-claim-wins, never overwriting an exact entry). Regression test mounts one docs server listing search_docs before searchDocs: red on the parent commit (mcp__docs__searchDocs displayed search_docs metadata), green here.
Fixed in fda31efb79: each identity now also indexes its reconstructible historical collision name — pairCollisionName(serverKey, rawTool) is the same deterministic first candidate disambiguatedDshToolName allocates, so a denial saved under mcp__docs__search__all_353988fff1e9 follows the pair onto the plain mcp__docs__search__all after the colliding neighbor is unmounted. Regression test builds the bridge with both pairs, rebuilds it with only the survivor, and asserts the saved denial translates to the survivor's current name: red on the parent commit, green here.
Must fix: Preserve counter-allocated denial identities across reconnects too. Mount docs exposing search__all and search__all_353988fff1e9, then docs__search exposing all: the latter receives mcp__docs__search__all_4e11dd82a154. Save that name in disabledTools, remove docs, and reconnect. The survivor gets the plain name, but this lookup reconstructs only the first pair-hash alias (_353988fff1e9), leaving the saved denial unmatched. DSH checks disabled tools by exact name, so the explicitly disabled tool can execute under bypassPermissions. No cryptographic collision is needed. Persist stable server-ID/raw-tool identity or retain compatibility for all allocated denial identities, and add a counter-allocation reconnect regression test.
inv_72af0d1a27f73cb8#f1
Must fix: Refresh metadata using the running connection’s captured server allocation. Mount UUID-backed A then B, both named docs and exposing run; remove A from the agent during an active turn, then refresh B’s changed tool cache. This function reallocates docs to B, and ClaudeCodeSessionStateService replaces the adapter’s metadata in place. The active SDK connection remains bound to A until the deferred rebuild, so mcp__docs__run executes against A but receives B’s server ID and description in call/result metadata. Keep the allocation fixed until connection replacement and cover this mount-change/cache-refresh sequence.
inv_5ae37a72707f1d84#f1
Two confirmed regressions require changes: counter-allocated DSH denials can stop blocking after reconnect, and live Claude metadata refresh can attribute calls/results to the wrong MCP server while connection rebuilding is deferred.
Frozen head: fda31efb792f2811a2881387d94f464253abd0d6. CI snapshot: 5 successful, 12 in-progress, 14 skipped Check Runs; no legacy status contexts. Frozen-pair synthetic-merge CI was unavailable because its parents differed. Review used source/baseline inspection and an isolated allocation experiment; no project tests or end-to-end SDK execution ran.
Cherry Review · Blocked
2 blocking
See inline comments for individual findings.
<!-- cherry-review:run=397b9afdf34be896 -->
Fixed in 9ae2fa6946: the build-time server allocation is captured once (resolveAgentMcpServerKeys) and shared by legacy denial translation, metadata (initial build, warm reconciliation, and the live catalog refresh — the state service now stores it and passes it to every refresh), and the catalog sync registration. Metadata is attributed under the running connection's frozen allocation until a rebuild replaces the connection, so removing A mid-turn no longer hands docs to B. Regression test builds metadata for a frozen {id-a: docs, id-b: id-b} allocation while the agent only mounts B: red on the parent commit (mcp__docs__run re-attributed to B), green here.
Fixed in 9ae2fa6946: when a rule has no exact entry, translation now falls back to the stripped plain name (<name>_<12-hex disambiguator> → <name>), resolving saved denials under any counter depth — the stripped name maps through the fail-closed candidate map like every other ambiguous form. Regression test mounts docs/[search__all, search__all_353988fff1e9] + docs__search/all (counter-allocated third name), saves it, rebuilds with only the survivor, and asserts the denial translates to the survivor's plain name: red on the parent commit, green here.
One blocking technical defect: persisted DSH counter-allocated tool denials can lose their target after reconnect, allowing an explicitly disabled tool to execute under bypassPermissions. Exact-name capture and truncated-prefix recovery failures share the same missing historical-alias handling.
Frozen-head CI snapshot: 10 successful, 6 in progress, 14 skipped Check Runs; no recorded failures. Legacy status has zero contexts. Matching synthetic-merge CI is unavailable. Verification used source inspection and isolated function evaluations; no project tests or live SDK/MCP sessions ran.
Cherry Review · Blocked
1 blocking
See inline comments for individual findings.
<!-- cherry-review:run=2729a16490b2aed9 -->
One confirmed blocking regression: DSH denial translation can discard a saved tool’s historical alias after a catalog change and reconnect, allowing the explicitly disabled tool under bypassPermissions.
Frozen head: 875584f6dc195534869ca89b08bb5f7c9e15368c. CI snapshot: 15 successful Check Runs, 8 skipped, and 2 in progress (renderer 1/5 and macOS). Legacy status has zero contexts; matching merge CI is unavailable. Verification used source inspection and isolated function evaluations, not project tests or full runtime execution. A separate Claude truncation candidate remains unconfirmed and is excluded from findings.
Cherry Review · Blocked
1 blocking
See inline comments for individual findings.
<!-- cherry-review:run=cf476445bae439d6 -->
Changes requested: saved MCP denials can be rewritten away from the disabled tool, allowing execution under DSH bypassPermissions; distinct Claude server/tool pairs can also collapse into one metadata identity and lose correct attribution.
Frozen head: cc12640788c040241075db3b282d03c5d85c4d10. CI snapshot: 14 successful, 8 skipped and 4 in-progress Check Runs; no recorded failures. Legacy status had zero contexts. Matching frozen-pair merge CI was unavailable.
Review used source tracing, baseline comparison and targeted verification. No project tests ran; full application/SDK execution and CI logs were unavailable. No wrong-server SDK dispatch is alleged.
Cherry Review · Blocked
2 blocking
See inline comments for individual findings.
<!-- cherry-review:run=201fa3f4fb64557d -->
Two technical regressions require changes: DSH denial translation can allow an explicitly disabled tool, and ambiguous Claude tool names lose server attribution. The dispatch behavior of the live Claude SDK is not established.
Frozen-head CI: 13 successful, 14 skipped, two failed checks (basic-checks, repository-checks), one queued, and two running. Legacy status has zero contexts; matching merge CI and failure logs were unavailable. Review used source inspection and isolated function evaluations; no project tests or live SDK sessions ran.
Cherry Review · Blocked
2 blocking
See inline comments for individual findings.
<!-- cherry-review:run=ec3c402173f751bc -->
All four round-13 findings are addressed in 3cb59abc61:
Old server/get_time → docs/get_time).disabledTools wins — stored server rules migrate only when the PATCH omits the field; submitted lists (including an explicit empty one) are persisted verbatim, while agent-mounted rules still follow the rename.disabledTools writes go through a transaction-aware AgentService.updateDisabledToolsTx and onAgentUpdated fires after commit.Local validation: vitest suites for mcpToolName, McpServerService, DshCherryToolBridge and AgentService (416 tests) green, tsc --noEmit clean, oxlint clean, i18n checks passing.
ggbdpq
Summary
Fixes #21321.
When an Agent runtime mounts user-installed MCP servers,
buildAgentMcpServerskeyed the SDK server entry by the rawmcpId(a 36-char UUID) and set itsnameto the same UUID. Fortype: "sdk"servers the Claude Agent SDK discards the entry'snamefield and uses the record key as the server identity and tool-name prefix, so themcp__<UUID>__prefix (43 chars) ate most of the SDK's 64-char tool-name budget and long tool names got truncated to unreadable<8 chars>_<12-hex>hashes (15 of Firecrawl's 26 tools in the reporter's setup).The fix uses the configured short server name as the record key and entry name, with a conservative collision fallback to the
mcpId(unknown name, or a name already taken by another mounted server or one of the built-in cherry server keys).createMcpBridgeServerstays bound to the id, so the upstream connection path is untouched. Consumers audited: the claude-code runtime is the fix point; the DSH bridge readsvalue.name, so its tool names become readable too; the Pi runtime deliberately usesid ?? namefor stable namespacing and is unaffected.Verification
| Check | Result |
| --- | --- |
| New tests: short name registered as the SDK key with the bridge still bound by id; name collision falls back to mcpId; built-in cherry keys cannot be shadowed | 2 cases red before fix, all green after |
|
buildMcpServers.test.tsfull file | 31/31 passed || Extended: claudeCode + dsh + pi + toolApproval runtime suites | 49 files / 1117 tests passed |
|
pnpm typecheck(all groups) | 0 errors ||
oxlint+oxfmt --checkon changed files | clean |AI Use
Implemented with GLM-5.3-Flash (ZCode). Root cause localization, consumer-chain audit (claude-code / DSH / Pi), patch and tests by AI; verified locally as listed above.
Checklist
pnpm typecheckpasses locally