{"record":{"id":"163586f9db5e9fa7","repo":"Kuberwastaken/claurst","slug":"mcp-server-legacy-sse-stream-returned-http","errorCode":null,"errorMessage":"MCP server '{}': legacy SSE stream returned HTTP {}: {}","messagePattern":"MCP server '(.+?)': legacy SSE stream returned HTTP (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-rust/crates/mcp/src/rmcp_backend.rs","lineNumber":277,"sourceCode":"            .header(reqwest::header::ACCEPT, \"text/event-stream\");\n        if let Some(token) = &self.auth_token {\n            request = request.header(\n                reqwest::header::AUTHORIZATION,\n                transport::bearer_header_value(token)?,\n            );\n        }\n        let response = request.send().await.map_err(|e| {\n            anyhow::anyhow!(\n                \"MCP server '{}': failed to open legacy SSE stream '{}': {}\",\n                self.server_name,\n                self.sse_url,\n                e\n            )\n        })?;\n        if !response.status().is_success() {\n            let status = response.status();\n            let body = response.text().await.unwrap_or_default();\n            anyhow::bail!(\n                \"MCP server '{}': legacy SSE stream returned HTTP {}: {}\",\n                self.server_name,\n                status,\n                body\n            );\n        }\n\n        let server_name = self.server_name.clone();\n        let sse_url = self.sse_url.clone();\n        let post_endpoint = Arc::clone(&self.post_endpoint);\n        let incoming_tx = self.incoming_tx.clone();\n        let endpoint_tx_for_task = Arc::clone(&endpoint_tx);\n        let task = tokio::spawn(async move {\n            let result = transport::process_sse_response(response, |event, data| {\n                if matches!(event, Some(\"endpoint\")) {\n                    let endpoint = transport::resolve_legacy_endpoint(&sse_url, data)?;\n                    *lock_recover(&post_endpoint) = Some(endpoint.clone());\n                    if let Some(tx) = lock_recover(&endpoint_tx_for_task).take() {","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/mcp/src/rmcp_backend.rs#L259-L295","documentation":"When establishing the legacy SSE transport, the client opens a long-lived GET stream to the server's /sse endpoint. If that initial request returns a non-success HTTP status, the connection cannot proceed and the error includes the status and response body for diagnosis.","triggerScenarios":"start_sse_listener issues the initial GET on the legacy SSE stream for server self.server_name and receives a non-success response status.","commonSituations":"Wrong URL in the MCP config (404); server requires authentication (401/403); reverse proxy returns 502/503 when the backend is down; server no longer supports legacy SSE after an upgrade.","solutions":["Fix the server URL in the MCP config (verify the /sse path with curl)","Run the MCP auth flow if the response is 401/403 — the server needs OAuth tokens","If the server migrated to streamable HTTP, change the config type from 'sse' to 'http'","Check proxy/load-balancer health if the body shows a 5xx gateway error"],"exampleFix":"// before\n{ \"mcpServers\": { \"x\": { \"type\": \"sse\", \"url\": \"https://host/mcp\" } } }\n// after\n{ \"mcpServers\": { \"x\": { \"type\": \"http\", \"url\": \"https://host/mcp\" } } }","handlingStrategy":"retry","validationCode":"let resp = reqwest::get(&sse_url).await?;\nif !resp.status().is_success() {\n    anyhow::bail!(\"precheck failed: {} {}\", resp.status(), resp.text().await?);\n}","typeGuard":null,"tryCatchPattern":"match backend.connect().await {\n    Err(e) if e.to_string().contains(\"legacy SSE stream returned HTTP\") => {\n        // inspect status: 401 -> run auth; 404 -> fix URL; 5xx -> retry with backoff\n    }\n    other => other?,\n}","preventionTips":["Curl the /sse endpoint before wiring it into the MCP config","Run the OAuth flow first for servers that require authentication","Switch to the http (streamable) transport when the server supports it"],"tags":["mcp","sse","http","connection"],"backgroundTag":"http-error-response","analyzedSha":"b0637c97ec34144387cbf2f74f65df6d16a6cef1","analyzedAt":"2026-09-10T00:24:58.650Z","contentChangedAt":"2026-09-10T00:24:58.650Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}