{"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":"Error \"handshaking with MCP server failed: {source}\" thrown in openai/codex.","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":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}