Repository navigation
Commit 3cbc745
fix: switch MCP transport from legacy SSE to Streamable HTTP
The legacy SSE transport in the MCP Python SDK splits a session across two
independent HTTP requests (a long-lived GET /sse stream that hands out a
session_id, plus separate POST /messages?session_id=... calls) without
verifying the GET side finished the initialize handshake before accepting
POSTs on that session_id. When a client reopens a second /sse connection
(observed from mcp-remote), requests race and land on a session before
it's marked initialized, causing every tool call to fail with:
Failed to validate request: Received request before initialization
was complete
Mounts the FastMCP app with transport="http" (Streamable HTTP) instead,
still at path="/sse" for backward compatibility so existing client configs
keep working unchanged. Streamable HTTP tracks sessions via a single
Mcp-Session-Id header instead of two endpoints racing over a query param,
which avoids this class of bug entirely.
See modelcontextprotocol/python-sdk#423 and
modelcontextprotocol/python-sdk#1844
Bumps version to 0.5.2.
Co-Authored-By: Claude Sonnet 5 <[email protected]>1 parent 6afdca2 commit 3cbc745
3 files changed
Lines changed: 42 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
8 | 30 | | |
9 | 31 | | |
10 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
613 | 613 | | |
614 | 614 | | |
615 | 615 | | |
616 | | - | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
617 | 634 | | |
618 | 635 | | |
619 | 636 | | |
| |||
633 | 650 | | |
634 | 651 | | |
635 | 652 | | |
636 | | - | |
| 653 | + | |
637 | 654 | | |
638 | 655 | | |
639 | 656 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
0 commit comments