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
httpx2 (2.5.0) is the next-generation httpx fork with server-sent
events support built in, so the separate httpx-sse dependency is no
longer needed.
- Swap the httpx/httpx-sse dependencies for httpx2>=2.5.0 in the SDK
and the example projects.
- Rewrite the SSE transports against httpx2's API: aconnect_sse(...) ->
client.stream(...)/client.sse(...) wrapped in EventSource, and
iterate the EventSource directly instead of .aiter_sse().
- Document the swap as a v2 breaking change in docs/migration.md and
update docs/installation.md, README.v2.md, and the example sources.
Verified: ruff, pyright, and the full test suite pass at 100% coverage.
@@ -109,7 +142,7 @@ Forward the `iss` query parameter from the redirect so the validation can run: o
109
142
110
143
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.
111
144
112
-
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:
145
+
If you need to capture the session ID (e.g., for session resumption testing), you can use httpx2 event hooks to capture it from the response headers:
113
146
114
147
**Before (v1):**
115
148
@@ -125,23 +158,23 @@ async with streamable_http_client(url) as (read_stream, write_stream, get_sessio
125
158
**After (v2):**
126
159
127
160
```python
128
-
importhttpx
161
+
importhttpx2
129
162
from mcp.client.streamable_http import streamable_http_client
130
163
131
164
# Option 1: Simply ignore if you don't need the session ID
132
165
asyncwith streamable_http_client(url) as (read_stream, write_stream):
133
166
asyncwith ClientSession(read_stream, write_stream) as session:
134
167
await session.initialize()
135
168
136
-
# Option 2: Capture session ID via httpx event hooks if needed
169
+
# Option 2: Capture session ID via httpx2 event hooks if needed
The `headers`, `timeout`, `sse_read_timeout`, and `auth` parameters have been removed from `StreamableHTTPTransport`. Configure these on the `httpx.AsyncClient` instead (see example above).
191
+
The `headers`, `timeout`, `sse_read_timeout`, and `auth` parameters have been removed from `StreamableHTTPTransport`. Configure these on the `httpx2.AsyncClient` instead (see example above).
159
192
160
193
Note: `sse_client` retains its `headers`, `timeout`, `sse_read_timeout`, and `auth` parameters — only the streamable HTTP transport changed.
0 commit comments