{"record":{"id":"bf20cf79ee82a89d","repo":"chatboxai/chatbox","slug":"streamable-http-connection-failed-streamablemes","errorCode":null,"errorMessage":"Streamable HTTP connection failed: ${streamableMessage}\\nLegacy SSE fallback failed: ${fallbackMessage}","messagePattern":"Streamable HTTP connection failed: (.+?)\\\\nLegacy SSE fallback failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderer/packages/mcp/controller.ts","lineNumber":63,"sourceCode":"      })\n    } catch (err) {\n      console.error('Streamable HTTP connection failed', err)\n      try {\n        return await createMCPClient({\n          name,\n          transport: {\n            type: 'sse',\n            url: transportConfig.url,\n            headers: transportConfig.headers,\n          },\n          onUncaughtError(error: unknown) {\n            console.error('mcp:client:onUncaughtError', error)\n          },\n        })\n      } catch (fallbackError) {\n        const streamableMessage = err instanceof Error ? err.message : String(err)\n        const fallbackMessage = fallbackError instanceof Error ? fallbackError.message : String(fallbackError)\n        throw new Error(\n          `Streamable HTTP connection failed: ${streamableMessage}\\nLegacy SSE fallback failed: ${fallbackMessage}`,\n          { cause: err }\n        )\n      }\n    }\n  }\n  throw new Error('Unknown transport type')\n}\n\nexport class MCPServer extends Emittery<{ status: MCPServerStatus }> {\n  private _status: MCPServerStatus = { state: 'idle' }\n  private client?: MCPClient\n  private tools?: ToolSet\n\n  constructor(private readonly transportConfig: TransportConfig) {\n    super()\n  }\n","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/chatboxai/chatbox/blob/81571269addb6bafb589a920b2883f1e1e084fd1/src/renderer/packages/mcp/controller.ts#L45-L81","documentation":"Thrown by createClient() in the MCP controller when an HTTP-type transport fails to connect via the modern StreamableHTTPClientTransport AND the legacy SSE fallback also fails. The combined message embeds both underlying error messages and chains the original streamable error as `cause`, so both failure modes are visible in one error.","triggerScenarios":"An MCP server config with transport.type 'http' whose URL is unreachable or returns errors for BOTH the streamable-HTTP handshake and the SSE fallback path. This is the catch block reached only after both createMCPClient attempts inside the 'http' branch throw.","commonSituations":"Wrong/unreachable server URL; server requires auth headers that are missing or wrong; CORS/network policy blocks both transport protocols; server only speaks an older MCP protocol unsupported by both transports; the server is down.","solutions":["Read both embedded messages: the streamable message usually identifies the primary failure (auth, 404, DNS) — fix that first.","Verify the server URL is correct, reachable, and serves the MCP streamable-HTTP or SSE endpoint.","Check transportConfig.headers for missing/invalid auth tokens.","If the server only supports SSE, consider configuring transport.type 'sse' directly to get a cleaner single error.","Confirm network/CORS allows the renderer to reach the endpoint."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"function isValidHttpTransportConfig(c: TransportConfig): boolean {\n  return c.type === 'http' && typeof c.url === 'string' && URL.canParse(c.url)\n}\n// pre-check connectivity before createClient:\n// await fetch(url, { method: 'HEAD' }).catch(() => null) as a cheap liveness probe","typeGuard":"function isHttpTransportConfig(c: TransportConfig): c is { type: 'http'; url: string; headers?: Record<string,string> } {\n  return c.type === 'http'\n}","tryCatchPattern":"try {\n  await createClient(transportConfig)\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Streamable HTTP connection failed')) {\n    // inspect e.cause and e.message; offer to switch transport.type or check URL/headers\n  }\n  throw e\n}","preventionTips":["Validate the server URL and headers before connecting.","Keep transport.type 'http' to benefit from the SSE fallback rather than forcing one protocol.","Surface both embedded messages to the user for diagnosis."],"tags":["mcp","network","transport","connection"],"backgroundTag":null,"analyzedSha":"81571269addb6bafb589a920b2883f1e1e084fd1","analyzedAt":"2026-08-12T21:51:44.981Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}