From 637c42947236017bc78da59d1a22916400ccae63 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 18 Nov 2026 21:14:45 +0000 Subject: [PATCH] Enable lazy startup for stdio MCP servers by default (#62366) ## What changed Mark `mcp_lazy_stdio_startup` stable and enable it by default. When a tool catalog is already cached, Codex can expose tools from an optional stdio MCP server and defer starting the server until the first tool call. Required servers still establish a live connection at startup. ## Testing Exercise lazy startup with the default configuration in the tool-cache test and explicitly disable the feature for the eager-start control. Update the code mode and working-directory tests to proceed without waiting for an optional server when its catalog is cached. GitOrigin-RevId: a65d83fd1a4c141dba3c10e68b138539aa0a44f0 --- codex-rs/core/tests/suite/code_mode.rs | 3 ++- codex-rs/core/tests/suite/mcp_tool_cache.rs | 14 ++++++++------ codex-rs/core/tests/suite/rmcp_client.rs | 2 +- codex-rs/features/src/lib.rs | 4 ++-- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/codex-rs/core/tests/suite/code_mode.rs b/codex-rs/core/tests/suite/code_mode.rs index 2ea57626f0..d15f4dd34f 100644 --- a/codex-rs/core/tests/suite/code_mode.rs +++ b/codex-rs/core/tests/suite/code_mode.rs @@ -1202,7 +1202,8 @@ async fn code_mode_excludes_mcp_servers_using_their_configured_identity() -> Res let mut test = base_test; test.codex = new_thread.thread; test.session_configured = new_thread.session_configured; - wait_for_mcp_server(&test.codex, "rmcp").await?; + // The base thread may already have warmed the catalog, so this thread can + // expose the cached tools without starting the optional server. test.submit_turn("inspect the directly callable MCP tool") .await?; diff --git a/codex-rs/core/tests/suite/mcp_tool_cache.rs b/codex-rs/core/tests/suite/mcp_tool_cache.rs index f5ef2f6a13..98146876a8 100644 --- a/codex-rs/core/tests/suite/mcp_tool_cache.rs +++ b/codex-rs/core/tests/suite/mcp_tool_cache.rs @@ -688,19 +688,21 @@ pub(super) async fn cached_stdio_first_use_scenario() -> anyhow::Result anyhow::Result .await?; fixture.codex = started.thread; fixture.session_configured = started.session_configured; - wait_for_mcp_server(&fixture.codex, server_name).await?; + // The catalog is warm; the optional server starts on its first tool call. // A fresh thread must still discover the primary executor's repository // skills; host routing must not silently replace them with local skills. diff --git a/codex-rs/features/src/lib.rs b/codex-rs/features/src/lib.rs index 154e4f6539..02a4541c84 100644 --- a/codex-rs/features/src/lib.rs +++ b/codex-rs/features/src/lib.rs @@ -1806,8 +1806,8 @@ pub const FEATURES: &[FeatureSpec] = &[ FeatureSpec { id: Feature::McpLazyStdioStartup, key: "mcp_lazy_stdio_startup", - stage: Stage::UnderDevelopment, - default_enabled: false, + stage: Stage::Stable, + default_enabled: true, }, FeatureSpec { id: Feature::MultiEnvironmentMcp,