diff --git a/codex-rs/codex-mcp/src/connection_manager.rs b/codex-rs/codex-mcp/src/connection_manager.rs index 3596486568..16a705742c 100644 --- a/codex-rs/codex-mcp/src/connection_manager.rs +++ b/codex-rs/codex-mcp/src/connection_manager.rs @@ -75,6 +75,7 @@ use tracing::trace; use tracing::trace_span; use tracing::warn; +const CODEX_APPS_PARALLEL_TOOL_ALLOWLIST: &[&str] = &["library_create_library_file"]; const MCP_UI_META_KEY: &str = "ui"; const MCP_UI_VISIBILITY_META_KEY: &str = "visibility"; const MCP_UI_MODEL_VISIBILITY: &str = "model"; @@ -797,12 +798,13 @@ impl McpConnectionManager { fn with_server_metadata(&self, mut tool: ToolInfo) -> ToolInfo { let Some(metadata) = self.server_metadata.get(&tool.server_name) else { - tool.supports_parallel_tool_calls = false; + tool.supports_parallel_tool_calls = codex_apps_tool_supports_parallel_tool_calls(&tool); tool.server_origin = None; return tool; }; - tool.supports_parallel_tool_calls = metadata.supports_parallel_tool_calls; + tool.supports_parallel_tool_calls = metadata.supports_parallel_tool_calls + || codex_apps_tool_supports_parallel_tool_calls(&tool); tool.server_origin = metadata .origin .as_ref() @@ -833,6 +835,11 @@ impl McpConnectionManager { } } +fn codex_apps_tool_supports_parallel_tool_calls(tool: &ToolInfo) -> bool { + tool.server_name == CODEX_APPS_MCP_SERVER_NAME + && CODEX_APPS_PARALLEL_TOOL_ALLOWLIST.contains(&tool.tool.name.as_ref()) +} + impl Drop for McpConnectionManager { fn drop(&mut self) { self.startup_cancellation_token.cancel(); diff --git a/codex-rs/codex-mcp/src/connection_manager_tests.rs b/codex-rs/codex-mcp/src/connection_manager_tests.rs index bfbc09c473..01e70b38f5 100644 --- a/codex-rs/codex-mcp/src/connection_manager_tests.rs +++ b/codex-rs/codex-mcp/src/connection_manager_tests.rs @@ -1156,6 +1156,31 @@ async fn list_all_tools_adds_server_metadata_to_cached_tools() { assert_eq!(tool.server_origin.as_deref(), Some("https://docs.example")); } +#[test] +fn codex_apps_parallel_tool_allowlist_uses_raw_tool_name() { + let approval_policy = Constrained::allow_any(AskForApproval::OnFailure); + let permission_profile = Constrained::allow_any(PermissionProfile::default()); + let manager = McpConnectionManager::new_uninitialized( + &approval_policy, + &permission_profile, + /*prefix_mcp_tool_names*/ true, + ); + + let allowlisted_tool = manager.with_server_metadata(create_test_tool( + CODEX_APPS_MCP_SERVER_NAME, + "library_create_library_file", + )); + assert!(allowlisted_tool.supports_parallel_tool_calls); + + let other_codex_apps_tool = + manager.with_server_metadata(create_test_tool(CODEX_APPS_MCP_SERVER_NAME, "search")); + assert!(!other_codex_apps_tool.supports_parallel_tool_calls); + + let same_named_other_server_tool = + manager.with_server_metadata(create_test_tool("other", "library_create_library_file")); + assert!(!same_named_other_server_tool.supports_parallel_tool_calls); +} + #[test] fn server_metadata_preserves_tool_approval_policy() { let mut config = crate::codex_apps_mcp_server_config(