openai/codex · error · anyhow::Error

timed out handshaking with MCP server after {duration:?}

Error message

timed out handshaking with MCP server after {duration:?}

What it means

Error "timed out handshaking with MCP server after {duration:?}" thrown in openai/codex.

Source

Thrown at codex-rs/rmcp-client/src/rmcp_client.rs:1235

                client_service
                    .serve_with_lifecycle(transport, lifecycle)
                    .boxed(),
                Some(oauth_persistor),
            ),
            PendingTransport::StreamableHttpWithAccessTokenOnly { transport } => (
                client_service
                    .serve_with_lifecycle(transport, lifecycle)
                    .boxed(),
                None,
            ),
        };

        let service_result = match timeout {
            Some(duration) => match time::timeout(duration, transport).await {
                Ok(result) => {
                    result.map_err(|source| anyhow::Error::from(HandshakeError { source }))
                }
                Err(_elapsed) => Err(anyhow!(
                    "timed out handshaking with MCP server after {duration:?}"
                )),
            },
            None => transport
                .await
                .map_err(|source| anyhow::Error::from(HandshakeError { source })),
        };
        let service = match service_result {
            Ok(service) => service,
            Err(error) => {
                if let Some(runtime) = oauth_persistor.as_ref()
                    && let Err(persist_error) = runtime.persist_if_needed().await
                {
                    warn!(
                        "failed to persist OAuth tokens after failed initialize: {persist_error}"
                    );
                }
                return Err(error);

View on GitHub (pinned to 339751715c)

When it happens

Trigger: Thrown at codex-rs/rmcp-client/src/rmcp_client.rs:1235 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/1b8a5129dbb7df74. Report an issue: GitHub.