Skip to content

fix(tools): preserve MCP server-side tool name after rename - #1612

Merged
ajbozarth merged 1 commit into
generative-computing:mainfrom
ajbozarth:fix/mcp-tool-name-rename
Sep 3, 2026
Merged

fix(tools): preserve MCP server-side tool name after rename#1612
ajbozarth merged 1 commit into
generative-computing:mainfrom
ajbozarth:fix/mcp-tool-name-rename

Conversation

@ajbozarth

Copy link
Copy Markdown
Contributor

Issue

Fixes #1594

Description

When #1594 was closed, the noted workaround was to reassign MCPToolSpec.name (and .description) before calling as_mellea_tool() to disambiguate tools that share a name across multiple MCP servers. That workaround was silently broken: as_mellea_tool() used self.name both for the model-facing tool name and for the name sent to the server in call_tool(). A reassigned .name was therefore sent to the server, which only knows the original name, so the invocation failed.

This preserves the original server-side name at construction (_server_tool_name) and uses it for the actual tool invocation, leaving .name free for model-facing disambiguation. Adds a regression test and documents the supported reassignment behavior in the MCPToolSpec docstring.

Spun off from the design discussion on #1432, which resolved the tool-name-collision cases for component tools. That PR intentionally left user-supplied tools out of scope, on the basis that a user can rename their own function to avoid a conflict. MCP tools are the corner of that case: they are user-supplied, but their names come from the server rather than the user — so "rename it yourself" (reassigning MCPToolSpec.name, as noted on #1594) was the intended escape hatch. This PR makes that escape hatch actually work, by keeping the server-side name distinct from the reassignable model-facing name.

Testing

  • Tests added to the respective file if code was changed
  • New code has 100% coverage if code was added
  • Ensure existing tests and github automation passes (a maintainer will kick off the github automation when the rest of the PR is populated)

Attribution

  • AI coding assistants used

Adding a new component, requirement, sampling strategy, or tool?

If your PR adds or modifies one of the types below, check the matching box. A checklist of type-specific review items will be posted as a comment.

  • Component
  • Requirement
  • Sampling Strategy
  • Tool

MCPToolSpec.as_mellea_tool passed the user-editable `name` field as both
the model-facing tool name and the name sent to the MCP server in
call_tool(). Reassigning `name` to disambiguate tools that collide across
multiple servers therefore broke the actual invocation, because the server
only knows the original name.

Preserve the original server-side name at construction and use it for the
tool call, leaving `name` free for model-facing disambiguation. This makes
the rename workaround noted when closing generative-computing#1594 actually work.

Fixes generative-computing#1594

Assisted-by: Claude Code
Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
@ajbozarth
ajbozarth requested a review from a team as a code owner September 2, 2026 22:27
@github-actions github-actions Bot added the bug Something isn't working label Sep 2, 2026
@ajbozarth ajbozarth self-assigned this Sep 2, 2026

@akihikokuroda akihikokuroda left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@planetf1 planetf1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@ajbozarth
ajbozarth added this pull request to the merge queue Sep 3, 2026
Merged via the queue into generative-computing:main with commit 10352cb Sep 3, 2026
12 checks passed
@ajbozarth
ajbozarth deleted the fix/mcp-tool-name-rename branch September 3, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add a name prefix and additional description to MCP functions

3 participants