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
{{ message }}
Repository navigation
Commit c2aebfb
Browse filesBrowse the repository at this point in the historyBrowse files
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.
Copy file name to clipboardExpand all lines: docs/installation.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ You don't need to know any of this to use the SDK, but if you're wondering what
35
35
*[`anyio`](https://anyio.readthedocs.io/): the async runtime. The whole SDK is written against anyio, so it runs on either `asyncio` or `trio`.
36
36
*[`pydantic`](https://docs.pydantic.dev/): what every `mcp_types` model is built on, plus all schema generation and validation.
37
37
*[`pydantic-settings`](https://docs.pydantic.dev/latest/concepts/pydantic_settings/): server configuration via `MCP_*` environment variables and `.env` files.
38
-
*[`httpx`](https://www.python-httpx.org/) and [`httpx-sse`](https://pypi.org/project/httpx-sse/): the HTTP client behind the Streamable HTTP and SSE *client* transports.
38
+
*[`httpx2`](https://pypi.org/project/httpx2/): the HTTP client behind the Streamable HTTP and SSE *client* transports, with server-sent events support built in.
39
39
*[`starlette`](https://www.starlette.io/), [`uvicorn`](https://www.uvicorn.org/), [`sse-starlette`](https://pypi.org/project/sse-starlette/), and [`python-multipart`](https://pypi.org/project/python-multipart/): the HTTP *server* transports.
40
40
*[`jsonschema`](https://pypi.org/project/jsonschema/): validates a tool's structured output against its declared output schema.
41
41
*[`pyjwt[crypto]`](https://pyjwt.readthedocs.io/): OAuth token handling for authorization.
@@ -110,7 +143,7 @@ Forward the `iss` query parameter from the redirect so the validation can run: o
110
143
111
144
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.
112
145
113
-
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:
146
+
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:
114
147
115
148
**Before (v1):**
116
149
@@ -126,23 +159,23 @@ async with streamable_http_client(url) as (read_stream, write_stream, get_sessio
126
159
**After (v2):**
127
160
128
161
```python
129
-
importhttpx
162
+
importhttpx2
130
163
from mcp.client.streamable_http import streamable_http_client
131
164
132
165
# Option 1: Simply ignore if you don't need the session ID
133
166
asyncwith streamable_http_client(url) as (read_stream, write_stream):
134
167
asyncwith ClientSession(read_stream, write_stream) as session:
135
168
await session.initialize()
136
169
137
-
# Option 2: Capture session ID via httpx event hooks if needed
170
+
# 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).
192
+
The `headers`, `timeout`, `sse_read_timeout`, and `auth` parameters have been removed from `StreamableHTTPTransport`. Configure these on the `httpx2.AsyncClient` instead (see example above).
160
193
161
194
Note: `sse_client` retains its `headers`, `timeout`, `sse_read_timeout`, and `auth` parameters — only the streamable HTTP transport changed.
0 commit comments