Skip to content

fix MCP tool name prefix stripping in callTool#2837

Merged
dgageot merged 1 commit into
docker:mainfrom
dgageot:fix-mcp-catalog-tool-call
May 20, 2026
Merged

fix MCP tool name prefix stripping in callTool#2837
dgageot merged 1 commit into
docker:mainfrom
dgageot:fix-mcp-catalog-tool-call

Conversation

@dgageot
Copy link
Copy Markdown
Member

@dgageot dgageot commented May 20, 2026

Tool calls when using the mcp catalog builtin tool would fail because a prefix is added to each tool in order to avoid conflicts

@dgageot dgageot requested a review from a team as a code owner May 20, 2026 14:14
Copy link
Copy Markdown

@docker-agent docker-agent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

The fix correctly addresses the root cause: callTool was forwarding the prefixed tool name (e.g. github-official_get_issue) to the remote MCP server, which only knows the unprefixed name (get_issue), causing every catalog tool call to fail with "tool not found".

Fix analysis:

  • strings.TrimPrefix(name, ts.name+"_") is the right primitive — it strips exactly one leading occurrence of <name>_ and is a no-op when ts.name is empty (unnamed toolsets) or the prefix is absent (misrouted calls)
  • No off-by-one, no nil-dereference (Go strings are never nil), no double-stripping (TrimPrefix is not iterative)
  • The ts.name != "" guard avoids any inadvertent behavior for unnamed toolsets

Test coverage is thorough — TestToolsAndCallToolRoundTrip and TestCallToolStripsToolsetNamePrefix together cover: named toolsets, unnamed toolsets, hyphenated catalog IDs, double-prefix tool names, and unprefixed calls forwarded unchanged.

No issues found in the changed lines.

@dgageot dgageot merged commit 278e383 into docker:main May 20, 2026
8 checks passed
@aheritier aheritier added area/mcp MCP protocol, MCP tool servers, integration kind/fix PR fixes a bug (maps to fix: commit prefix) labels May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/mcp MCP protocol, MCP tool servers, integration kind/fix PR fixes a bug (maps to fix: commit prefix)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants