Skip to content

[codex] Remove string-keyed MCP tool maps#21454

Open
pakrym-oai wants to merge 4 commits intomainfrom
pakrym/mcp-toolname-exposure
Open

[codex] Remove string-keyed MCP tool maps#21454
pakrym-oai wants to merge 4 commits intomainfrom
pakrym/mcp-toolname-exposure

Conversation

@pakrym-oai
Copy link
Copy Markdown
Collaborator

Summary

This PR removes the synthetic HashMap<String, ToolInfo> keys from MCP tool discovery. McpConnectionManager::list_all_tools() now returns normalized Vec<ToolInfo>, and downstream code derives identity from ToolInfo::canonical_tool_name().

The motivation is to keep model-visible tool identity on ToolName/ToolInfo instead of parallel string map keys, so future namespace changes do not have to preserve otherwise-unused lookup keys.

Changes

  • Rename the MCP normalization path from qualify_tools to normalize_tools_for_model and return tool values directly.
  • Flow MCP tool lists through connectors, plugin injection, router/spec building, code mode, and tool search as vectors/slices.
  • Keep direct/deferred subtraction local to mcp_tool_exposure, using ToolName values.
  • Update tests to compare ToolName instances where MCP identity matters.

Validation

  • cargo test -p codex-mcp test_normalize_tools
  • cargo test -p codex-core mcp_tool_exposure
  • cargo test -p codex-core direct_mcp_tools_register_namespaced_handlers
  • cargo test -p codex-core search_tool_registers_namespaced_mcp_tool_aliases
  • just fix -p codex-mcp
  • just fix -p codex-core

@pakrym-oai pakrym-oai marked this pull request as ready for review May 7, 2026 01:52
@pakrym-oai pakrym-oai requested a review from a team as a code owner May 7, 2026 01:52
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0c1c82874c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread codex-rs/core/src/unavailable_tool.rs Outdated
!mcp_tools.as_ref().is_some_and(|direct_tools| {
direct_tools
.iter()
.any(|direct_tool| direct_tool.canonical_tool_name() == tool_name)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nitpicky, do we care about n^2 here? we could use set

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants