{"record":{"id":"f223f47a6b8ab2ef","repo":"can1357/oh-my-pi","slug":"http-response-status-text-f223f4","errorCode":null,"errorMessage":"HTTP ${response.status}: ${text}","messagePattern":"HTTP (.+?): (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/mcp/transports/sse.ts","lineNumber":87,"sourceCode":"\t\tif (this.#connected) return;\n\t\tif (this.#sseConnection) return;\n\n\t\tconst connection = new AbortController();\n\t\tconst timeout = resolveMCPTimeoutMs(this.#config.timeout);\n\t\tconst operation = createMCPTimeout(timeout, connection.signal);\n\t\tconst endpointReady = Promise.withResolvers<void>();\n\t\tthis.#sseConnection = connection;\n\n\t\ttry {\n\t\t\tconst response = await this.#fetch(\n\t\t\t\tthis.#config.url,\n\t\t\t\t{ method: \"GET\", signal: operation.signal },\n\t\t\t\t{ Accept: \"text/event-stream\" },\n\t\t\t);\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst text = await response.text();\n\t\t\t\tthrow new Error(`HTTP ${response.status}: ${text}`);\n\t\t\t}\n\t\t\tif (!response.body) {\n\t\t\t\tthrow new Error(\"Legacy SSE response did not include a body\");\n\t\t\t}\n\n\t\t\tvoid this.#readSSEStream(response.body, operation, endpointReady).finally(() => {\n\t\t\t\tconst wasConnected = this.#connected;\n\t\t\t\tif (this.#sseConnection === connection) this.#sseConnection = null;\n\t\t\t\tif (wasConnected) this.onClose?.();\n\t\t\t});\n\t\t\tawait endpointReady.promise;\n\t\t} catch (error) {\n\t\t\toperation.clear();\n\t\t\tif (this.#sseConnection === connection) this.#sseConnection = null;\n\t\t\tconnection.abort();\n\t\t\tif (operation.isTimeoutAbort(error)) {\n\t\t\t\tthrow new Error(`Legacy SSE endpoint timeout after ${timeout}ms`);\n\t\t\t}","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/mcp/transports/sse.ts#L69-L105","documentation":"During legacy SSE transport connection, the initial GET of the MCP endpoint (Accept: text/event-stream) returned a non-OK HTTP status. The transport reads the response body and throws a plain Error embedding the status code and body text; this fails connect() (and thus createSseTransport) before any events are read. Note: legacy SSE is the deprecated pre-Streamable-HTTP MCP transport.","triggerScenarios":"Wrong URL (pointing at a route that only serves the Streamable HTTP endpoint, yielding 404/405); server returning 401/403 due to missing/invalid credentials; server no longer supporting the legacy SSE protocol; 5xx from a crashing backend.","commonSituations":"Config files still using legacy SSE URLs ('/sse') after the server upgraded to Streamable HTTP only; expired OAuth tokens; reverse proxy auth intercepting the request; typo'd port or path in the MCP server config.","solutions":["Read the status and body text in the message — it usually names the exact problem (auth, not found, method not allowed).","Verify the URL is the server's legacy SSE endpoint (commonly /sse) and the server still supports the SSE transport; prefer switching to the Streamable HTTP transport if the server offers it.","Fix credentials: refresh tokens or supply correct headers for 401/403.","Test the endpoint manually: curl -N -H 'Accept: text/event-stream' <url> and compare the status.","Check the reverse proxy configuration for paths or auth rules intercepting the endpoint."],"exampleFix":"// config (before): legacy endpoint removed on the server\n{ \"mcpServers\": { \"docs\": { \"url\": \"https://mcp.example.com/sse\", \"type\": \"sse\" } } }\n// after: use streamable HTTP\n{ \"mcpServers\": { \"docs\": { \"url\": \"https://mcp.example.com/mcp\", \"type\": \"http\" } } }","handlingStrategy":"try-catch","validationCode":"const res = await fetch(sseUrl, { headers: { Accept: 'text/event-stream' } });\nif (!res.ok) throw new Error(`Legacy SSE endpoint pre-flight failed: HTTP ${res.status}`);\nawait res.body?.cancel();","typeGuard":"function isLegacySseHttpError(e: unknown): boolean {\n  return e instanceof Error && /^HTTP \\d{3}:/.test(e.message);\n}","tryCatchPattern":"try {\n  const transport = await createSseTransport(config);\n} catch (e) {\n  if (isLegacySseHttpError(e)) {\n    if (e.message.startsWith('HTTP 401')) await refreshCredentials();\n    else if (/^HTTP (404|405)/.test(e.message)) migrateToStreamableHttp();\n    else throw e;\n  } else throw e;\n}","preventionTips":["Migrate to the Streamable HTTP transport; legacy SSE is deprecated.","Validate the configured URL against the server's advertised transports.","Test endpoints with curl -N before adding them to config.","Keep OAuth tokens fresh; check proxy auth rules for the SSE path."],"tags":["mcp","sse","http-status","legacy-transport"],"backgroundTag":"http-error-response","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}