{"record":{"id":"98b8f6a23e489b64","repo":"langflow-ai/langflow","slug":"internal-server-error-in-streamable-http-transport","errorCode":null,"errorMessage":"Internal server error in Streamable HTTP transport","messagePattern":"Internal server error in Streamable HTTP transport","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"src/backend/base/langflow/api/v1/mcp.py","lineNumber":374,"sourceCode":"    current_user: CurrentActiveMCPUser,\n) -> Response:\n    \"\"\"Common handler for Streamable HTTP requests with user context propagation.\"\"\"\n    await logger.adebug(\n        \"Handling %s %s via Streamable HTTP for user %s\",\n        request.method,\n        request.url.path,\n        current_user.id,\n    )\n\n    context_token = current_user_ctx.set(current_user)\n    try:\n        manager = get_streamable_http_manager()\n        await manager.handle_request(request.scope, request.receive, request._send)  # noqa: SLF001\n    except HTTPException:\n        raise\n    except Exception as exc:\n        await logger.aexception(f\"Error handling Streamable HTTP request: {exc!s}\")\n        raise HTTPException(status_code=500, detail=\"Internal server error in Streamable HTTP transport\") from exc\n    finally:\n        current_user_ctx.reset(context_token)\n\n    return ResponseNoOp()\n","sourceCodeStart":356,"sourceCodeEnd":379,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/mcp.py#L356-L379","documentation":"Catch-all 500 from the Streamable HTTP MCP endpoint: manager.handle_request raised something other than an HTTPException. The user-context ContextVar is reset in finally, and the specific exception is logged via aexception ('Error handling Streamable HTTP request'), but the client only sees the generic detail string.","triggerScenarios":"Invalid MCP session id header (mcp-session-id) on a Streamable HTTP request causing an SDK error; protocol violations (bad JSON-RPC, wrong content type); tool code raising during a tools/call; errors inside the session manager while resuming an SSE stream.","commonSituations":"Client sending requests after the server restarted (stale session header); mismatched MCP SDK versions; tools with unhandled exceptions; proxies altering the Accept header so the SDK picks an unsupported transport mode.","solutions":["Read the server log for the 'Error handling Streamable HTTP request' entry to get the true exception.","Start a fresh session (send initialize, use the returned mcp-session-id header) instead of reusing one from before a restart.","Verify the request uses the MCP Streamable HTTP content type and both text/event-stream + application/json Accept values where required.","Fix the underlying tool/protocol bug the log reveals."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"except httpx.HTTPStatusError as e: if e.response.status_code == 500: check server logs; if session-related, re-initialize and retry once.","preventionTips":["Re-initialize the MCP session after any server restart instead of reusing mcp-session-id.","Send correct Accept headers for Streamable HTTP (both application/json and text/event-stream)."],"tags":["mcp","http-500","streamable-http","server-error","session"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}