From 76f47103feceb43cee8b8c9a6d8a7b4bc4567e86 Mon Sep 17 00:00:00 2001 From: victor-openai Date: Wed, 2 Sep 2026 20:20:20 +0000 Subject: [PATCH] Improve MCP server startup error logging (#42370) ## What changed - Log failed MCP server startup outcomes once per startup attempt, including failures during discovery that do not emit startup notifications. - Preserve the full error chain when converting startup failures into cloneable outcome errors. GitOrigin-RevId: 54bbf2abaf3329d9828b2d2bc5d877fddc2917e1 --- codex-rs/codex-mcp/src/rmcp_client.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/codex-rs/codex-mcp/src/rmcp_client.rs b/codex-rs/codex-mcp/src/rmcp_client.rs index 9b4c8137b8..e469b865a2 100644 --- a/codex-rs/codex-mcp/src/rmcp_client.rs +++ b/codex-rs/codex-mcp/src/rmcp_client.rs @@ -362,7 +362,7 @@ impl ManagedClientStartup { } }; start_server_task( - server_name, + server_name.clone(), client, StartServerTaskParams { is_codex_apps_mcp_server, @@ -385,6 +385,10 @@ impl ManagedClientStartup { Ok(result) => result, Err(CancelErr::Cancelled) => Err(StartupOutcomeError::Cancelled), }; + // Log once per startup attempt, including discovery without startup notifications. + if let Err(StartupOutcomeError::Failed { error, .. }) = &outcome { + warn!(server_name, %error, "MCP server startup failed"); + } if outcome.is_ok() && let Some(refresh_start) = refresh_start { @@ -618,7 +622,7 @@ impl From for StartupOutcomeError { fn from(error: anyhow::Error) -> Self { let is_authentication_required = is_authentication_required_error(&error); Self::Failed { - error: error.to_string(), + error: format!("{error:#}"), is_authentication_required, } }