Skip to content

Move MCP tool naming mode into manager#21576

Merged
pakrym-oai merged 10 commits into
mainfrom
pakrym/mcp-tool-names-flag
May 26, 2026
Merged

Move MCP tool naming mode into manager#21576
pakrym-oai merged 10 commits into
mainfrom
pakrym/mcp-tool-names-flag

Conversation

@pakrym-oai

Copy link
Copy Markdown
Collaborator

Why

The non_prefixed_mcp_tool_names feature should be applied where MCP tools become model-visible, not by remapping names later in core. Keeping the decision in McpConnectionManager construction makes ToolInfo the single shaped view that spec building, deferred tool search, routing, and unavailable-tool placeholders can consume directly.

This also preserves the existing external behavior while the feature is off, and keeps the feature-on behavior for code mode and hooks explicit at the manager boundary.

What Changed

  • Add McpToolNameMode to codex-mcp and flow it through McpConfig into McpConnectionManager::new.
  • Normalize MCP ToolInfo names in the manager using either legacy-prefixed namespaces or non-prefixed namespaces; the legacy path adds mcp__ without restoring the old trailing namespace suffix.
  • Remove the core-side MCP name remapping path so specs, tool search, session resolution, and unavailable-tool placeholder construction use the manager-provided ToolName values directly.
  • Keep code mode flattening on the __ namespace separator.
  • Preserve hook compatibility by giving non-prefixed MCP hook names legacy mcp__... matcher aliases.
  • Add/adjust integration and unit coverage for non-prefixed code-mode behavior, hook matching with the feature on and off, and manager-level legacy prefixing.

Testing

  • cargo test -p codex-mcp --lib
  • cargo test -p codex-core --lib tools::spec::tests -- --nocapture
  • cargo test -p codex-core --lib mcp_tools -- --nocapture
  • cargo test -p codex-core --lib mcp_tool_exposure -- --nocapture
  • cargo test -p codex-core --test all mcp_tool -- --nocapture
  • cargo test -p codex-core --test all search_tool -- --nocapture
  • cargo test -p codex-core --test all hooks_mcp -- --nocapture
  • cargo test -p codex-core --test all code_mode_uses_non_prefixed_mcp_tool_names_when_feature_enabled -- --nocapture
  • cargo test -p codex-tools
  • cargo test -p codex-features

@pakrym-oai pakrym-oai force-pushed the pakrym/mcp-tool-names-flag branch 6 times, most recently from c23f0b7 to 9869ea8 Compare May 7, 2026 20:47
@pakrym-oai pakrym-oai force-pushed the pakrym/mcp-tool-names-flag branch from 9869ea8 to a0a59cf Compare May 7, 2026 20:53
@pakrym-oai pakrym-oai marked this pull request as ready for review May 7, 2026 20:59
@pakrym-oai pakrym-oai requested a review from a team as a code owner May 7, 2026 20:59

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a0a59cffb4

ℹ️ 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/codex-mcp/src/codex_apps.rs
Comment thread codex-rs/core/src/unavailable_tool.rs Outdated
Comment thread codex-rs/codex-mcp/src/codex_apps.rs
Comment thread codex-rs/codex-mcp/src/tools.rs Outdated

@sayan-oai sayan-oai left a comment

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.

approach makes sense, and centralizing into McpConnectionManager is attractive. left some questions but overall makes sense to me

pakrym-oai added 7 commits May 8, 2026 12:42
…-flag

# Conflicts:
#	codex-rs/codex-mcp/src/connection_manager_tests.rs
#	codex-rs/core/src/tools/handlers/mcp.rs
#	codex-rs/core/src/tools/spec.rs
#	codex-rs/core/src/unavailable_tool.rs
…-flag

# Conflicts:
#	codex-rs/core/src/config/config_tests.rs
#	codex-rs/core/tests/suite/sqlite_state.rs
…-flag

# Conflicts:
#	codex-rs/codex-mcp/src/connection_manager.rs
#	codex-rs/codex-mcp/src/mcp/mod.rs
#	codex-rs/codex-mcp/src/mcp/mod_tests.rs
#	codex-rs/core/src/config/config_tests.rs
#	codex-rs/core/src/config/mod.rs
#	codex-rs/core/src/connectors.rs
#	codex-rs/core/src/mcp_tool_call_tests.rs
#	codex-rs/core/src/session/mcp.rs
#	codex-rs/core/src/session/session.rs
…-flag

# Conflicts:
#	codex-rs/core/config.schema.json
…-flag

# Conflicts:
#	codex-rs/codex-mcp/src/connection_manager_tests.rs
#	codex-rs/core/src/mcp_tool_call_tests.rs
#	codex-rs/core/src/mcp_tool_exposure_test.rs
#	codex-rs/core/src/session/session.rs
#	codex-rs/core/src/session/tests.rs
#	codex-rs/core/src/tools/handlers/mcp.rs
#	codex-rs/core/src/tools/spec.rs
#	codex-rs/core/src/tools/spec_plan_tests.rs
#	codex-rs/core/src/tools/spec_tests.rs
#	codex-rs/core/src/unavailable_tool.rs
#	codex-rs/core/tests/suite/hooks_mcp.rs
#	codex-rs/core/tests/suite/openai_file_mcp.rs
#	codex-rs/core/tests/suite/tools.rs
#	codex-rs/features/src/lib.rs
…-flag

# Conflicts:
#	codex-rs/core/src/tools/handlers/mcp.rs
@pakrym-oai

Copy link
Copy Markdown
Collaborator Author

@codex review this

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 98a057b214

ℹ️ 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/codex-mcp/src/tools.rs
Comment thread codex-rs/core/src/tools/handlers/mcp.rs
Comment thread codex-rs/core/src/tools/handlers/mcp.rs
@pakrym-oai pakrym-oai merged commit ff7513c into main May 26, 2026
31 checks passed
@pakrym-oai pakrym-oai deleted the pakrym/mcp-tool-names-flag branch May 26, 2026 15:21
@github-actions github-actions Bot locked and limited conversation to collaborators May 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants