openai/codex · error · HandshakeError
handshaking with MCP server failed
Error message
handshaking with MCP server failed: {source} What it means
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.
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
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at codex-rs/rmcp-client/src/streamable_http_retry.rs:247 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/3ad6342cf8af9807.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/rmcp-client/src/streamable_http_retry.rs:247
let duration = timeout.unwrap_or(fallback);
anyhow!("timed out handshaking with MCP server after {duration:?}")
}
pub(super) async fn sleep_with_retry_deadline(delay: Duration, deadline: Option<Instant>) -> bool {
if let Some(deadline) = deadline {
let remaining = deadline.saturating_duration_since(Instant::now());
if remaining.is_zero() {
return false;
}
time::timeout(remaining, time::sleep(delay)).await.is_ok()
} else {
time::sleep(delay).await;
true
}
}
#[derive(Debug, thiserror::Error)]
#[error("handshaking with MCP server failed: {source}")]
pub(super) struct HandshakeError {
#[source]
pub(super) source: rmcp::service::ClientInitializeError,
}
#[cfg(test)]
#[path = "streamable_http_retry_tests.rs"]
mod tests;
View on GitHub (pinned to 339751715c)