{"record":{"id":"55838a99135e80b3","repo":"tinyhumansai/openhuman","slug":"mcp-events-get","errorCode":null,"errorMessage":"MCP events GET {} — {}","messagePattern":"MCP events GET (.+?) — (.+?)","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"src/openhuman/mcp/http_client/client.rs","lineNumber":432,"sourceCode":"    ) -> anyhow::Result<Vec<McpSseEvent>> {\n        self.initialize().await?;\n        let protocol_version = self.state.lock().negotiated_protocol_version.clone();\n        let session_id = self.state.lock().session_id.clone();\n        let mut request = self\n            .apply_auth(self.http.get(&self.endpoint), false)\n            .header(ACCEPT, \"text/event-stream\")\n            .header(HEADER_PROTOCOL_VERSION, protocol_version);\n        if let Some(session_id) = session_id {\n            request = request.header(HEADER_SESSION_ID, session_id);\n        }\n        if let Some(last_event_id) = last_event_id {\n            request = request.header(\"Last-Event-ID\", last_event_id);\n        }\n        let response = request.send().await?;\n        let status = response.status();\n        let text = response.text().await?;\n        if !status.is_success() {\n            anyhow::bail!(\"MCP events GET {} — {}\", status.as_u16(), text);\n        }\n        parse_sse_events(&text)\n    }\n\n    pub async fn close_session(&self) -> anyhow::Result<()> {\n        let session_id = self.state.lock().session_id.clone();\n        let Some(session_id) = session_id else {\n            return Ok(());\n        };\n        let response = self\n            .http\n            .delete(&self.endpoint)\n            .header(HEADER_SESSION_ID, session_id)\n            .send()\n            .await?;\n        if !(response.status().is_success()\n            || response.status() == reqwest::StatusCode::METHOD_NOT_ALLOWED)\n        {","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/mcp/http_client/client.rs#L414-L450","documentation":"The Streamable-HTTP transport's SSE recovery path fetched the event-stream endpoint (`GET` with `Accept: text/event-stream`, plus `Mcp-Session-Id` and `Last-Event-ID` headers when known) and got a non-2xx status; the status code and response body are embedded. This endpoint is only hit to (re)attach to server-pushed events, so a failure here usually means the session or stream resumption was rejected.","triggerScenarios":"Reconnecting an SSE stream after the server expired/deleted the session (404 with `Mcp-Session-Id` no longer valid); 401 when the OAuth token expired between calls; 4xx/5xx from a gateway in front of the MCP endpoint; `Last-Event-ID` the server no longer retains.","commonSituations":"Long-lived sessions behind load balancers that drop idle connections and evict session state; auth token expiring during a long tool chain; reverse proxy rejecting the `text/event-stream` accept header; server restart losing in-memory sessions.","solutions":["Treat it as session loss: reset state and re-run `initialize` to establish a new session id, then retry the logical operation.","If 401/403, refresh OAuth credentials before reconnecting.","Check any proxy in front of the endpoint allows SSE (no buffering, long read timeouts).","If the server restarts often, move to per-request re-initialization rather than long-lived sessions."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match client.get_events(/* ... */).await {\n    Err(e) if e.to_string().starts_with(\"MCP events GET 4\") => {\n        client.reset_session();\n        client.initialize().await?; // fresh session, then retry attach\n    }\n    Err(e) if e.to_string().contains(\" 50\") => { /* transient: backoff and retry */ }\n    other => other,\n}","preventionTips":["Re-initialize the session whenever the SSE stream drops rather than reusing the old session id.","Keep proxies SSE-friendly: disable buffering, extend read timeouts.","Expect servers to evict idle sessions; re-attach with Last-Event-ID only within a short window."],"tags":["mcp","http","sse","session","reconnect"],"backgroundTag":"http-error-response","analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}