Repository navigation
fix(mcp): with_prefix names the tool <prefix>__<tool> - #323
Merged
Merged
Conversation
McpToolAdapter::with_prefix / from_client_with_prefix stored the prefix but name() and label() returned the server's raw tool name, so two MCP servers offering the same tool (or a server tool named like a built-in) gave the agent duplicate tool names, which a provider rejects. The name is now computed once at construction, as the OpenAPI adapter's with_name_prefix does (`prefix__tool`); execute still calls the server with its own name. Test: two servers both offering `search`, called through the prefixed name; it fails without the fix. Reported by the yobuild session (found in yologdev/yobuild#11's review). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG
…ests - Docs: the MCP guide shows how to prefix a server's tools (the with_mcp_server_* helpers add none) and that with_tools replaces the list; tools.md notes the agent's own tools are not de-duplicated; the pointer is OpenApiConfig::with_name_prefix (not the adapter); provider name limits are hedged and the prefix is not validated. - Tests: the client's call timeout is carried onto prefixed adapters (fails without it); a second prefix replaces the first; the other server gets no tools/call; tests/mcp_prefix_agent_test.rs runs two prefixed servers through an Agent: the model's `web__search` reaches only the web server, as `search`, and ToolExecutionStart names `web__search`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
McpToolAdapter::with_prefixandfrom_client_with_prefixstored the prefix, butname()andlabel()returned the server's raw tool name, and nothing else read the prefix. Two MCP servers offering the same tool, or a server tool named like a built-in (bash,read_file), therefore still gave the agent duplicate tool names. yoagent doesn't de-duplicatewith_tools, so a real provider rejects the request. A caller using the prefix to avoid this was silently unprotected.Reported by the yobuild session, from the review of yologdev/yobuild#11. yobuild now uses
from_clientand refuses duplicate names itself, so it does not depend on this fix.Fix
<prefix>__<tool>with a prefix. This is the same form as the OpenAPI adapter'swith_name_prefixand what the field's doc comment already described.name()andlabel()return it.executestill calls the server with its own tool name._and-, and 64 characters on most providers.Tests
searchbecomedocs__searchandweb__search. A call throughweb__searchreaches that server astools/callwithname: "search", and an unprefixed adapter keepssearch. The test fails with the fix reverted.cargo test --all-features, clippy-D warningswith all features and on wasm32 (decision), rustdoc, fmt.CHANGELOG: Unreleased.
🤖 Generated with Claude Code
https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG