langflow-ai/langflow · error · HTTPException

Internal server error in Streamable HTTP transport

Error message

Internal server error in Streamable HTTP transport

What it means

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.

Source

Thrown at src/backend/base/langflow/api/v1/mcp.py:374

    current_user: CurrentActiveMCPUser,
) -> Response:
    """Common handler for Streamable HTTP requests with user context propagation."""
    await logger.adebug(
        "Handling %s %s via Streamable HTTP for user %s",
        request.method,
        request.url.path,
        current_user.id,
    )

    context_token = current_user_ctx.set(current_user)
    try:
        manager = get_streamable_http_manager()
        await manager.handle_request(request.scope, request.receive, request._send)  # noqa: SLF001
    except HTTPException:
        raise
    except Exception as exc:
        await logger.aexception(f"Error handling Streamable HTTP request: {exc!s}")
        raise HTTPException(status_code=500, detail="Internal server error in Streamable HTTP transport") from exc
    finally:
        current_user_ctx.reset(context_token)

    return ResponseNoOp()

View on GitHub (pinned to 976ec789d2)

Solutions

  1. Read the server log for the 'Error handling Streamable HTTP request' entry to get the true exception.
  2. Start a fresh session (send initialize, use the returned mcp-session-id header) instead of reusing one from before a restart.
  3. Verify the request uses the MCP Streamable HTTP content type and both text/event-stream + application/json Accept values where required.
  4. Fix the underlying tool/protocol bug the log reveals.
Defensive patterns

Strategy: try-catch

Try / catch

except httpx.HTTPStatusError as e: if e.response.status_code == 500: check server logs; if session-related, re-initialize and retry once.

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14). Data as JSON: /api/errors/98b8f6a23e489b64. Report an issue: GitHub.