{"record":{"id":"3ad6342cf8af9807","repo":"openai/codex","slug":"handshaking-with-mcp-server-failed-source","errorCode":null,"errorMessage":"handshaking with MCP server failed: {source}","messagePattern":"handshaking with MCP server failed: (.+?)","errorType":"exception","errorClass":"HandshakeError","httpStatus":null,"severity":"error","filePath":"codex-rs/rmcp-client/src/streamable_http_retry.rs","lineNumber":247,"sourceCode":"    let duration = timeout.unwrap_or(fallback);\n    anyhow!(\"timed out handshaking with MCP server after {duration:?}\")\n}\n\npub(super) async fn sleep_with_retry_deadline(delay: Duration, deadline: Option<Instant>) -> bool {\n    if let Some(deadline) = deadline {\n        let remaining = deadline.saturating_duration_since(Instant::now());\n        if remaining.is_zero() {\n            return false;\n        }\n        time::timeout(remaining, time::sleep(delay)).await.is_ok()\n    } else {\n        time::sleep(delay).await;\n        true\n    }\n}\n\n#[derive(Debug, thiserror::Error)]\n#[error(\"handshaking with MCP server failed: {source}\")]\npub(super) struct HandshakeError {\n    #[source]\n    pub(super) source: rmcp::service::ClientInitializeError,\n}\n\n#[cfg(test)]\n#[path = \"streamable_http_retry_tests.rs\"]\nmod tests;\n","sourceCodeStart":229,"sourceCodeEnd":256,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/rmcp-client/src/streamable_http_retry.rs#L229-L256","documentation":"Wrapper error type (thiserror) that surfaces the underlying cause when the MCP handshake fails outright (as opposed to timing out): transport/connection or protocol errors from serve_with_lifecycle are chained via {source}. The failing transport handshake is the input at fault.","triggerScenarios":"Thrown at codex-rs/rmcp-client/src/streamable_http_retry.rs:247 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the chained source error for the real cause (auth, DNS, TLS, protocol mismatch)","Fix server URL/credentials and retry the connection","Check MCP protocol version compatibility between client and server"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}