Commit 1313fc2
committed
fix(mcp): use HTTP/1.1 for the streamable-HTTP transport (drop allowH2)
The MCP transport was the only place in the codebase opting undici into HTTP/2
(`allowH2: true`). undici's h2 support is experimental and has a documented
cluster of stalls where response headers arrive but the body DATA frames never
do, on POST bodies over reused/coalesced sessions (nodejs/undici #2311, #3433,
#4143). Behind a shared egress IP fronted by a CDN, that is exactly what hung the
streamable-HTTP `initialize` after OAuth: 200 + Mcp-Session-Id, then an empty
body until the SDK's 30s timeout — reproducible only from the deployed egress,
never from a fresh IP or in isolation.
h2 buys the MCP transport nothing (one POST per JSON-RPC message plus a single
long-lived SSE stream — no concurrency to multiplex), and both official MCP SDKs
run the transport on HTTP/1.1: the TypeScript SDK's StreamableHTTPClientTransport
calls global fetch (undici h1.1, no allowH2), and the Python SDK builds its httpx
client with no http2=True. Dropping allowH2 aligns with them and steps off the h2
stall surface. CDN fronts serve h1.1 anyway; SSRF IP-pinning and Agent teardown
are unchanged.1 parent e02dbce commit 1313fc2
2 files changed
Lines changed: 47 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
31 | 57 | | |
32 | 58 | | |
33 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
25 | 34 | | |
26 | 35 | | |
27 | | - | |
28 | | - | |
29 | | - | |
| 36 | + | |
30 | 37 | | |
31 | 38 | | |
32 | 39 | | |
| |||
0 commit comments