{"record":{"id":"23623d23b4cf4cac","repo":"PrefectHQ/fastmcp","slug":"sse-transport-does-not-support-stateless-mode","errorCode":null,"errorMessage":"SSE transport does not support stateless mode","messagePattern":"SSE transport does not support stateless mode","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/server/mixins/transport.py","lineNumber":309,"sourceCode":"                settings.http_host_origin_protection. \"auto\" protects\n                localhost-bound servers and explicit host/origin allowlists.\n            allowed_hosts: Additional hostnames that may appear in the Host header.\n            allowed_origins: Additional browser origins trusted by the request guard.\n                Configure CORS separately when browser JavaScript must read\n                cross-origin responses.\n            sockets: Pre-bound sockets to pass to Uvicorn\n        \"\"\"\n        # Allow stateless as alias for stateless_http\n        if stateless is not None and stateless_http is None:\n            stateless_http = stateless\n\n        # Resolve from settings/env var if not explicitly set\n        if stateless_http is None:\n            stateless_http = fastmcp.settings.stateless_http\n\n        # SSE doesn't support stateless mode\n        if stateless_http and transport == \"sse\":\n            raise ValueError(\"SSE transport does not support stateless mode\")\n\n        host = host if host is not None else fastmcp.settings.host\n        port = port if port is not None else fastmcp.settings.port\n        resolved_host_origin_protection = (\n            host_origin_protection\n            if host_origin_protection is not None\n            else fastmcp.settings.http_host_origin_protection\n        )\n        resolved_allowed_hosts = _resolve_allowed_hosts_for_run(\n            host=host,\n            host_origin_protection=resolved_host_origin_protection,\n            allowed_hosts=allowed_hosts,\n            configured_allowed_hosts=fastmcp.settings.http_allowed_hosts,\n        )\n        default_log_level_to_use = (\n            log_level if log_level is not None else fastmcp.settings.log_level\n        ).lower()\n","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/server/mixins/transport.py#L291-L327","documentation":"SSE (Server-Sent Events) is inherently a stateful transport, so FastMCP refuses to run it with stateless_http=True. run_http_async validates the combination up front and raises ValueError before starting uvicorn.","triggerScenarios":"Calling run_http_async(transport='sse', stateless_http=True), or transport='sse' while fastmcp.settings.stateless_http is enabled (e.g. FASTMCP_STATELESS_HTTP=1).","commonSituations":"Deployments that globally enable stateless mode for scaling, then switch transport to 'sse'; copying a stateless config from a streamable-http deployment onto an SSE server.","solutions":["Use transport='streamable-http' (or 'http') with stateless_http=True","Set stateless_http=False (and unset FASTMCP_STATELESS_HTTP) when using SSE"],"exampleFix":"// before\nserver.run(transport='sse', stateless_http=True)\n\n// after\nserver.run(transport='http', stateless_http=True)  # or keep sse without stateless","handlingStrategy":"validation","validationCode":"if transport == 'sse' and (stateless_http or fastmcp.settings.stateless_http):\n    raise ValueError('Use streamable-http for stateless mode; SSE is stateful only')","typeGuard":null,"tryCatchPattern":"try:\n    await server.run_http_async(transport='sse', stateless_http=stateless)\nexcept ValueError as e:\n    if 'stateless' in str(e):\n        await server.run_http_async(transport='http', stateless_http=stateless)\n    else:\n        raise","preventionTips":["Unset FASTMCP_STATELESS_HTTP when deploying SSE","Keep transport and statelessness config co-located and validated together","Prefer streamable-http for new stateless deployments"],"tags":["transport","sse","stateless","configuration"],"backgroundTag":"incompatible-transport-options","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}