Repository navigation
executeToolCall and model dispatch resolve nested MCPL tool prefixes differently #230
Description
Found while reviewing #220 (second-reviewer probe, re-checked by reading). Present on main (e457abd).
What happens. The two dispatch entry points resolve an MCPL-prefixed tool name differently:
- model dispatch uses
resolveMcplTool— the server that listed the tool, else the longest matching prefix:agent-framework/src/framework.ts
Lines 11956 to 11966 in e457abd
private resolveMcplTool(toolName: string): [string, string] | null { const listedBy = this.mcplToolServers?.get(toolName); let best: [string, string] | null = null; for (const [prefix, serverId] of this.mcplPrefixMap ?? []) { if (!toolName.startsWith(prefix + '--')) continue; if (serverId === listedBy) return [serverId, prefix]; if (!best || prefix.length > best[1].length) best = [serverId, prefix]; } return best; } executeToolCallFrom(publicexecuteToolCall,ModuleContext.callTool) takes the first configured server whose prefix matches:agent-framework/src/framework.ts
Lines 10904 to 10913 in e457abd
if (this.mcplServerRegistry) { // Check if this is an MCPL-prefixed tool const prefix = call.name.split('--').slice(0, -1).join('--'); const serverConfigs = this.mcplServerConfigs; for (const [, config] of serverConfigs) { const toolPrefix = config.toolPrefix ?? `mcpl--${config.id}`; if (call.name.startsWith(toolPrefix + '--')) { return this.executeMcplToolCall(call, config); } }
With nested prefixes (foo and foo--bar), foo--bar--x reaches server foo--bar as x from the model, but server foo as bar--x from a programmatic caller, depending on config insertion order. Any name-based permission check (per-agent allowedTools, #220) is evaluated against the declared name and so passes for both.
Direction. Route executeToolCallFrom through resolveMcplTool so both entries agree.
Activity
test(provider): the tests name what they check, without the house's r…
chore(guard): the code and tests say what they do, without the house'…
fix(mcpl): a programmatic tool call reaches the server the model's ca…