Support mcp 2.x (Python SDK): pin blocks mcp 2.0.0
Summary
chainlit currently pins the MCP Python SDK to the 1.x line and cannot be installed alongside mcp 2.0.0 (released 2026-07-28). This issue tracks the breaking changes in mcp 2.0 that affect the backend.
Current constraint
mcp>=1.11.0,<2.0.0 — backend/pyproject.toml:45.
Breaking changes in mcp 2.0 that affect chainlit
All in backend/chainlit/server.py, verified against the installed mcp==2.0.0 SDK:
-
streamablehttp_clientrenamed →streamable_http_client.server.py:1306—from mcp.client.streamable_http import streamablehttp_client. In 2.0 the function isstreamable_http_client.
-
streamable_http_client/sse_clientdropped theheaderskwarg.server.py:1434-1437—streamablehttp_client(url=..., headers=mcp_connection.headers). In 2.0headersis removed; it must be set on anhttpx2.AsyncClientpassed ashttp_client=.server.py:1418-1421—sse_client(url=..., headers=mcp_connection.headers), same change.
Notes
- The tuple-arity change is already handled:
server.py:1442doesread, write = transport[:2], which works for both the old 3-tuple and the new 2-tuple, so no change needed there.server.py:1445-1449constructsClientSessionwithoutread_timeout_seconds, so the timedelta→float change does not apply. The main work is the import rename and movingheadersinto anhttpx/httpx2client. - Dependency-floor updates.
mcp2.0 requirespydantic>=2.12,anyio>=4.9,typing-extensions>=4.13, and adds required depsopentelemetry-apiandmcp-types(exact-pinned to the SDK version); the SDK's HTTP layer moved fromhttpx/httpx-ssetohttpx2>=2.5.0.
Happy to help with a PR if the maintainers are open to it.
We hit this from the downstream side: chainlit is now the only thing in our dependency graph holding mcp below 2.0.
Two data points that might be useful here:
claude-agent-sdkrelaxed its ownmcp<2.0.0to<3.0.0in 0.2.140 and now supports 1.x and 2.x side by side. Of the packages we depend on that touchmcp, every other one is floor-only or capped at<3— this is the last<2.0.0we're carrying.- Verified by resolution rather than by reading metadata: with a whole-graph
mcp>=2.0.0constraint, the resolve fails through chainlit alone, andchainlit==2.11.1+mcp>=2.0.0reports the conflict directly. Worth flagging for anyone else testing this — an unpinnedchainlit>=1.0.0resolves "successfully" by walking back to a version predating themcpdependency, which looks like a pass but means you've lost chainlit.
The analysis above matches what we see, the three changes look small, and we'd be glad to send a PR.
One practical question first: would a release be likely to follow a merge? The last release was 2.11.1 (2026-04-22) while PRs have kept merging, so a merged fix wouldn't reach consumers via PyPI on its own. Knowing whether to expect a release or to plan on pinning a main SHA would help us — and probably others landing on this issue.
I verified the 2.x surface against the actual SDKs (mcp 1.28.1, 1.29.1 and 2.1.1 on Python 3.13) before picking this up, and two of the details above have changed since the issue was written — both in the direction of making this smaller. Posting the findings and the shape I'd propose, in case you'd rather steer it differently.
1. sse_client still accepts headers= and httpx_client_factory= in 2.x.
mcp 2.1.1
sse_client(url, headers=None, timeout=5.0, sse_read_timeout=300.0,
httpx_client_factory=create_mcp_http_client, auth=None,
on_session_created=None)
That is identical to 1.29.1 apart from the httpx→httpx2 types, so the SSE call site needs no signature change.
2. streamable_http_client already exists on the current floor.
server.py still imports the deprecated streamablehttp_client, but the new name landed in 1.24.0 — below the mcp>=1.28.1 floor — and its signature is identical across 1.28.1, 1.29.1 and 2.1.1:
streamable_http_client(url, *, http_client: AsyncClient | None = None,
terminate_on_close: bool = True)
So one code path covers both major lines: no conditional imports and no version sniffing. The existing NOTE at server.py:1679 is exactly right about what to do on bump.
3. No dependency-floor changes are needed.
Chainlit's constraints are ranges rather than pins, so the resolver satisfies mcp 2.x on its own. Relaxing only the cap resolves to:
mcp==2.1.1 mcp-types==2.1.1 httpx2==2.12.0
pydantic==2.13.4 anyio==4.14.2
pydantic, anyio and starlette resolve to the same versions under mcp<2.0.0 as under mcp>=2.0.0, so nothing needs bumping — httpx-sse drops out, httpx2 and mcp-types come in, and chainlit's own httpx stays alongside httpx2.
The real work is narrower than the dependency list suggests, but it does touch the SSRF guard:
http_client=replaces the factory for streamable-http, and ownership flips —streamable_http_clientonly closes a client it created (if not client_provided:), so a caller-supplied client must be closed by the caller.- mcp 2.x dispatches with
httpx2while 1.x dispatches withhttpx, somake_mcp_http_client_factoryhas to build from whichever module the installed SDK actually uses. Otherwise the guard inchainlit/mcp.py(follow_redirects=Falseplus the per-requestcheck_destinationhook) ends up attached to the wrong client type.
Proposed shape, keeping mcp>=1.28.1,<3.0.0 so neither line is dropped:
- resolve the httpx module from the installed SDK rather than from what happens to be importable, so the guard cannot silently bind to the wrong library;
- keep
make_mcp_http_client_factoryforsse_client, and add a single-client helper forstreamable_http_client(http_client=...), entered into the existingAsyncExitStackso it is closed; - update the regression guards in
TestMakeMcpHttpClientFactory—test_streamablehttp_client_accepts_httpx_client_factory_kwargasserts a parameter that no longer exists in 2.x, so it should asserthttp_clientonstreamable_http_clientinstead; - run the backend suite against both 1.29.1 and 2.1.1.
Happy to open a PR on that shape. If you'd prefer 2.x-only, or want the deprecated alias kept for a release, let me know and I'll adjust.