From 7ab2179c255cb6b15e96b3095c7aed9320358b3b Mon Sep 17 00:00:00 2001 From: Felipe Coury Date: Sat, 30 May 2026 18:17:13 -0300 Subject: [PATCH] fix(core): refresh app inventory after mcp install --- codex-rs/core/src/session/turn.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/codex-rs/core/src/session/turn.rs b/codex-rs/core/src/session/turn.rs index 99070b248c..d2a8ece228 100644 --- a/codex-rs/core/src/session/turn.rs +++ b/codex-rs/core/src/session/turn.rs @@ -547,7 +547,7 @@ async fn build_skills_and_plugins( explicitly_requested_mcp_servers, ) .await?; - let mcp_tools = if turn_context.apps_enabled() || !mentioned_plugins.is_empty() { + let mut mcp_tools = if turn_context.apps_enabled() || !mentioned_plugins.is_empty() { // Plugin mentions need raw MCP/app inventory even when app tools // are normally hidden so we can describe the plugin's currently // usable capabilities for this turn. @@ -567,7 +567,7 @@ async fn build_skills_and_plugins( } else { Vec::new() }; - let available_connectors = if turn_context.apps_enabled() { + let mut available_connectors = if turn_context.apps_enabled() { let connectors = codex_connectors::merge::merge_plugin_connectors_with_accessible( loaded_plugins .effective_apps() @@ -607,6 +607,30 @@ async fn build_skills_and_plugins( skill_dependency_servers, ) .await?; + mcp_tools = match sess + .services + .mcp_connection_manager + .read() + .await + .list_ready_or_cached_tools() + .or_cancel(cancellation_token) + .await + { + Ok(mcp_tools) => mcp_tools, + Err(_) if turn_context.apps_enabled() => return None, + Err(_) => Vec::new(), + }; + if turn_context.apps_enabled() { + let connectors = codex_connectors::merge::merge_plugin_connectors_with_accessible( + loaded_plugins + .effective_apps() + .into_iter() + .map(|connector_id| connector_id.0), + connectors::accessible_connectors_from_mcp_tools(&mcp_tools), + ); + available_connectors = + connectors::with_app_enabled_state(connectors, &turn_context.config); + } } let structured_skill_paths = structured_mentioned_skills