feat(mcp): #1167 prefix colliding MCP tool names#2788
feat(mcp): #1167 prefix colliding MCP tool names#2788IgnazioDS wants to merge 3 commits intoopenai:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9179a99593
ℹ️ 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".
|
Addressed the review thread in Change made:
Validation:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b9f25db053
ℹ️ 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".
|
Addressed the follow-up naming-collision thread in Change made:
Validation:
|
seratch
left a comment
There was a problem hiding this comment.
Thanks for working on this. I think the feature is useful, but I don't think it's merge-ready yet because the new naming scheme can still generate invalid function tool names in two ways.
First, _server_tool_name_prefix() currently preserves non-ASCII alphanumeric characters. With include_server_in_tool_names=True, a server label like 天気サーバー becomes part of the public tool name and is then forwarded unchanged to the Responses payload. OpenAI function tool names need to stay within the allowed ASCII character set, so this path can fail at runtime even though the current tests are green.
Second, the prefixed name is never bounded to the API's 64-character limit. A sufficiently long server.name plus tool.name can easily produce a function name longer than 64 characters, and that overlong name is also passed through unchanged to the Responses tool definition.
So I think we need two additional safeguards before merging:
- Normalize the server-derived prefix to an ASCII-safe subset only.
- Enforce the 64-character limit on the final generated tool name, probably with a deterministic shortening/hash scheme so collisions remain impossible.
Once those two cases are covered, the overall approach looks good to me.
Summary
mcp_config["include_server_in_tool_names"]flag to expose MCP tools as<server_name>_<tool_name>Fixes #1167.
Validation
uv run ruff check src/agents/agent.py src/agents/mcp/util.py tests/mcp/test_mcp_util.pyuv run pytest tests/mcp/test_mcp_util.py -quv run mypy src/agents/agent.py src/agents/mcp/util.py tests/mcp/test_mcp_util.pyNotes
mainbranch and keeps the surface area limited to MCP config/util behavior plus focused tests.