Langflow gives a Streamable HTTP server two seconds to answer initialize, and a timeout never falls back to SSE

Kind: idiosyncrasy · Status: current · Last verified: 2026-11-27 · Clients: langflow · Revisions: 2025-11-25

The handshake budget

At 21381e5b (Langflow 1.13.3), a server registered with a URL and no explicit mode is treated as Streamable_HTTP. MCPSessionManager._create_streamable_http_session opens the SDK's streamablehttp_client and calls asyncio.wait_for(session.initialize(), timeout=2.0). It makes up to three attempts (STREAMABLE_HTTP_CONNECT_ATTEMPTS = 3), sleeping 0.35 s and then 0.7 s between them.

The 2 s figure is a literal. LANGFLOW_MCP_SERVER_TIMEOUT (default 60 s) bounds the outer connect and the wait for the session future, and the setting's own description says it "does not change the per-attempt 2 s cap on the Streamable HTTP initialize handshake, so a slow-to-start server is only tolerated over stdio". A remote server that takes longer than 2 s to answer initialize, for example on a cold start, fails all three attempts.

When SSE is tried

The SSE path runs in two cases. The server's config sets mode: "SSE", which skips Streamable HTTP. Or the Streamable HTTP failure looks like a transport mismatch: an httpx.HTTPStatusError with 400, 404, 405 or 406, or an McpError or message naming 404, 405, 406, "not found", "method not allowed" or "not acceptable".

_is_transient_streamable_http_error is checked first, and a timeout, ConnectionError, OSError, any httpx.RequestError, a 5xx, a 429, or a message such as "connection closed" or "taskgroup" makes it true. A transient failure is retried and never falls back. So the 2 s timeout above ends with an error naming Streamable HTTP and no SSE attempt.

Once SSE connects, the manager records sse as that server's preferred transport, keyed by URL and headers, and later sessions go straight to SSE for as long as that session manager lives in the component cache. The SSE path calls initialize() with no 2 s cap. Its read timeout is 30 s. A pinned preset sets allow_sse_fallback: false, and then SSE is never tried.

The extra DELETE

MCPStreamableHttpClient.disconnect() sends its own best-effort HTTP DELETE to the server URL before the session is torn down. It looks for the session id with getattr(self.session, "session_id", None) or getattr(self.session, "id", None). The SDK's ClientSession has neither attribute, so the DELETE goes without an Mcp-Session-Id header, with the configured headers. The SDK's streamablehttp_client defaults to terminate_on_close=True and sends its own DELETE with the session id when the transport closes. From the code, a server sees one DELETE without a session id and then one with it. It is also sent when the session fell back to SSE. In this commit only the GET /api/v2/mcp/servers?action_count=true check calls disconnect(). The MCP Tools component leaves its pooled sessions to the idle reaper (400 s by default). I did not run this against a server.

Not checked

I did not measure how often a real server misses the 2 s window. I did not check whether Langflow Desktop overrides any of these constants.

Sources