Conversation
|
| let mut counts = std::collections::HashMap::<&str, usize>::new(); | ||
| for base in &bases { | ||
| *counts.entry(base).or_default() += 1; | ||
| } |
There was a problem hiding this comment.
Cached startup registration can assign an unsuffixed name when it sees only one member of a normalized collision. Live discovery then assigns suffixed names after it sees both members, but leaves the original cached key registered. The same MCP tool family is therefore exposed under three names, and the obsolete cached alias can continue advertising cached metadata instead of the refreshed definition. Remove obsolete MCP registry keys during refresh, or assign names from one stable set of server/tool identities.
Knowledge Base Used: Agent runtime and tool loop
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/jcode-base/src/mcp/tool.rs
Line: 125-128
Comment:
**Reconcile refresh aliases**
Cached startup registration can assign an unsuffixed name when it sees only one member of a normalized collision. Live discovery then assigns suffixed names after it sees both members, but leaves the original cached key registered. The same MCP tool family is therefore exposed under three names, and the obsolete cached alias can continue advertising cached metadata instead of the refreshed definition. Remove obsolete MCP registry keys during refresh, or assign names from one stable set of server/tool identities.
**Knowledge Base Used:** [Agent runtime and tool loop](https://app.greptile.com/solo-systems/-/custom-context/knowledge-base/1jehuang/jcode/-/docs/agent-runtime-and-tool-loop.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| let suffix = format!("__{:08x}", stable_dispatch_hash(server, &tool.name)); | ||
| let mut candidate = format!("{base}{suffix}"); | ||
| let mut counter = 2u32; | ||
| while !used.insert(candidate.clone()) { | ||
| candidate = format!("{base}{suffix}_{counter}"); | ||
| counter = counter.saturating_add(1); | ||
| } | ||
| names[index] = candidate; |
There was a problem hiding this comment.
For normalized MCP-name collisions, eager registration and execution use generated suffixed aliases, but session allow/deny entries continue to match the historical unsuffixed name. A deny entry for the configured MCP capability therefore does not match either eager collision alias, allowing that external capability to execute despite being disabled. Resolve policy entries and generated aliases through the same MCP identity.
How this was verified: A session deny for the unsuffixed name allowed a suffixed collision alias to invoke the test external capability.
Knowledge Base Used:
Artifacts
- The complete regression test creates the normalized collision, applies the historical deny entry, and invokes the generated alias.
- The output records exit code 0 and `test tool::tests::unsuffixed_mcp_deny_does_not_block_a_suffixed_collision_alias ... ok`, showing that the denied capability executed through the suffixed alias.
Ran code and verified through T-Rex
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/jcode-base/src/mcp/tool.rs
Line: 148-155
Comment:
**Match policies to aliases**
For normalized MCP-name collisions, eager registration and execution use generated suffixed aliases, but session allow/deny entries continue to match the historical unsuffixed name. A deny entry for the configured MCP capability therefore does not match either eager collision alias, allowing that external capability to execute despite being disabled. Resolve policy entries and generated aliases through the same MCP identity.
**How this was verified:** A session deny for the unsuffixed name allowed a suffixed collision alias to invoke the test external capability.
**Knowledge Base Used:**
- [Agent runtime and tool loop](https://app.greptile.com/solo-systems/-/custom-context/knowledge-base/1jehuang/jcode/-/docs/agent-runtime-and-tool-loop.md)
- [Agent execution and tooling](https://app.greptile.com/solo-systems/-/custom-context/knowledge-base/1jehuang/jcode/-/docs/agent-execution-and-tooling.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.795fd91 to
beeb0e2
Compare
Summary
Prevent normalized MCP tool names from colliding at provider boundaries while preserving the original server-qualified dispatch identity.
Changes
Validation
git diff --check upstream/master...HEADupstream/mastercompleted successfully.Refs #972