Skip to content

Move MCP tool naming mode into manager#21576

Open
pakrym-oai wants to merge 7 commits into
mainfrom
pakrym/mcp-tool-names-flag
Open

Move MCP tool naming mode into manager#21576
pakrym-oai wants to merge 7 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
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: 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 on lines 58 to 60
fn should_collect_unavailable_tool(name: &str, namespace: Option<&str>) -> bool {
namespace.is_some_and(|namespace| namespace.starts_with("mcp__")) || name.starts_with("mcp__")
}
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.

wouldnt this break with the new flag on? we wouldnt catch them as unavailable if they dont have the prefix

Comment thread codex-rs/codex-mcp/src/codex_apps.rs
Comment on lines +169 to +172
callable_namespace: callable_namespace_with_prefix(
&sanitize_responses_api_tool_name(&tool.callable_namespace),
prefix_mcp_tool_names,
),
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.

the mcp__ prefix was preventing collisions with reserved top-level namespaces like web and tools, and dynamic namespaces. what if user now has mcp server named web, or a conflicting dynamic namespace? i dont think we currently have all the info needed in McpConnectionManager to do collision detection, but maybe we can at least reserve some known names

Copy link
Copy Markdown
Collaborator

@sayan-oai sayan-oai left a comment

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 4 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
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