[MCP] Sanitize MCP tool names to ensure they are compatible with the Responses APO#8694
[MCP] Sanitize MCP tool names to ensure they are compatible with the Responses APO#8694
Conversation
There was a problem hiding this comment.
💡 Codex Review
codex/codex-rs/core/src/mcp_connection_manager.rs
Lines 139 to 141 in 708f6ca
When two MCP tools differ only by characters that get sanitized (e.g., server.one vs server_one), both map to the same qualified_name. The new sanitization introduces this collision, but the code now just skips the second entry when used_names already contains the sanitized key, which silently drops a valid tool from the aggregated map. This is a regression because previously both tools were distinct; now one becomes unreachable. Consider appending a hash of the raw name on collision (as the comment suggests) instead of skipping.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The Responses API requires that all tool names conform to '^[a-zA-Z0-9_-]+$'. This PR replaces all non-conforming characters with
_to ensure that they can be used.Fixes #8174