zeroclaw-labs/zeroclaw · error · anyhow::Error

MCP response id mismatch: expected {:?}, received {:?}

Error message

MCP response id mismatch: expected {:?}, received {:?}

What it means

Error "MCP response id mismatch: expected {:?}, received {:?}" thrown in zeroclaw-labs/zeroclaw.

Source

Thrown at crates/zeroclaw-tools/src/mcp_transport.rs:1119

    fn update_session_id_from_headers(&self, headers: &reqwest::header::HeaderMap) {
        if let Some(session_id) = headers
            .get(MCP_SESSION_ID_HEADER)
            .and_then(|v| v.to_str().ok())
            .map(str::trim)
            .filter(|v| !v.is_empty())
        {
            *self.session_id.lock() = Some(session_id.to_string());
        }
    }
}

fn finish_response(
    request: &JsonRpcRequest,
    lifecycle: &McpRequestLifecycle,
    response: JsonRpcResponse,
) -> Result<JsonRpcResponse> {
    if response.id != request.id {
        bail!(
            "MCP response id mismatch: expected {:?}, received {:?}",
            request.id,
            response.id
        );
    }
    lifecycle.mark_completed();
    Ok(response)
}

#[async_trait::async_trait]
impl SharedMcpTransportConn for HttpTransport {
    async fn send_and_recv(
        &self,
        request: &JsonRpcRequest,
        lifecycle: &McpRequestLifecycle,
    ) -> Result<JsonRpcResponse> {
        let body = serde_json::to_string(request)?;

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. The MCP server answered out of order or the wrong request; restart the server connection and retry.

When it happens

Trigger: Thrown at crates/zeroclaw-tools/src/mcp_transport.rs:1119 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/c4985665c2ce6627. Report an issue: GitHub.