You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/migration.md
+49-1Lines changed: 49 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,10 +44,58 @@ async with http_client:
44
44
asyncwith streamable_http_client(
45
45
url="http://localhost:8000/mcp",
46
46
http_client=http_client,
47
-
) as (read_stream, write_stream, get_session_id):
47
+
) as (read_stream, write_stream):
48
48
...
49
49
```
50
50
51
+
### `get_session_id` callback removed from `streamable_http_client`
52
+
53
+
The `get_session_id` callback (third element of the returned tuple) has been removed from `streamable_http_client`. The function now returns a 2-tuple `(read_stream, write_stream)` instead of a 3-tuple.
54
+
55
+
If you need to capture the session ID (e.g., for session resumption testing), you can use httpx event hooks to capture it from the response headers:
56
+
57
+
**Before (v1):**
58
+
59
+
```python
60
+
from mcp.client.streamable_http import streamable_http_client
61
+
62
+
asyncwith streamable_http_client(url) as (read_stream, write_stream, get_session_id):
63
+
asyncwith ClientSession(read_stream, write_stream) as session:
64
+
await session.initialize()
65
+
session_id = get_session_id() # Get session ID via callback
66
+
```
67
+
68
+
**After (v2):**
69
+
70
+
```python
71
+
import httpx
72
+
from mcp.client.streamable_http import streamable_http_client
73
+
74
+
# Option 1: Simply ignore if you don't need the session ID
75
+
asyncwith streamable_http_client(url) as (read_stream, write_stream):
76
+
asyncwith ClientSession(read_stream, write_stream) as session:
77
+
await session.initialize()
78
+
79
+
# Option 2: Capture session ID via httpx event hooks if needed
asyncwith streamable_http_client(url, http_client=http_client) as (read_stream, write_stream):
94
+
asyncwith ClientSession(read_stream, write_stream) as session:
95
+
await session.initialize()
96
+
session_id = captured_session_ids[0] if captured_session_ids elseNone
97
+
```
98
+
51
99
### `StreamableHTTPTransport` parameters removed
52
100
53
101
The `headers`, `timeout`, `sse_read_timeout`, and `auth` parameters have been removed from `StreamableHTTPTransport`. Configure these on the `httpx.AsyncClient` instead (see example above).
0 commit comments