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: README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,13 +18,13 @@
18
18
>
19
19
> **v1.x is the only stable release line and remains recommended for production.** It lives on the [`v1.x` branch](https://github.com/modelcontextprotocol/python-sdk/tree/v1.x) and continues to receive critical bug fixes and security patches; see [the v1.x README](https://github.com/modelcontextprotocol/python-sdk/blob/v1.x/README.md) for its documentation. `pip` and `uv` don't select a pre-release unless you explicitly request one, so existing installs are unaffected. **If your package depends on `mcp`, add a `<2` upper bound to your version constraint (for example `mcp>=1.27,<2`) before the stable release lands.**
20
20
>
21
-
> v2 is a major rework of the SDK, both to support the [2026-07-28 MCP specification release](https://blog.modelcontextprotocol.io/posts/2026-07-28-release-candidate/) and to fix long-standing architectural issues. See the [migration guide](https://py.sdk.modelcontextprotocol.io/v2/migration/) for what's changed. Stable v2 is targeted for 2026-07-27, alongside the spec release. Try the pre-releases and [tell us what breaks](https://github.com/modelcontextprotocol/python-sdk/issues/new?template=v2-feedback.yaml) — or discuss in [#python-sdk-dev on the MCP Contributors Discord](https://discord.gg/6CSzBmMkjX).
21
+
> v2 is a major rework of the SDK, both to support the [2026-07-28 MCP specification release](https://blog.modelcontextprotocol.io/posts/2026-07-28-release-candidate/) and to fix long-standing architectural issues. See [What's new in v2](https://py.sdk.modelcontextprotocol.io/v2/whats-new/) for the tour of what changed, and the [migration guide](https://py.sdk.modelcontextprotocol.io/v2/migration/) for every breaking change. Stable v2 is targeted for 2026-07-27, alongside the spec release. Try the pre-releases and [tell us what breaks](https://github.com/modelcontextprotocol/python-sdk/issues/new?template=v2-feedback.yaml), or discuss in [#python-sdk-dev on the MCP Contributors Discord](https://discord.gg/6CSzBmMkjX).
22
22
23
23
## Documentation
24
24
25
25
**The documentation lives at <https://py.sdk.modelcontextprotocol.io/v2/>.**
26
26
27
-
It has a [Get started guide](https://py.sdk.modelcontextprotocol.io/v2/get-started/), the [API reference](https://py.sdk.modelcontextprotocol.io/v2/api/mcp/), and the [migration guide](https://py.sdk.modelcontextprotocol.io/v2/migration/).
27
+
It has a [Get started guide](https://py.sdk.modelcontextprotocol.io/v2/get-started/), [What's new in v2](https://py.sdk.modelcontextprotocol.io/v2/whats-new/), the [API reference](https://py.sdk.modelcontextprotocol.io/v2/api/mcp/), and the [migration guide](https://py.sdk.modelcontextprotocol.io/v2/migration/).
Copy file name to clipboardExpand all lines: docs/index.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,7 @@
2
2
3
3
!!! info "You are viewing the in-development v2 documentation"
4
4
For the current stable release, see the [v1.x documentation](https://py.sdk.modelcontextprotocol.io/).
5
+
New to v2, or coming from v1? **[What's new in v2](whats-new.md)** is the five-minute tour of what changed.
5
6
Trying v2? [Tell us what you find](https://github.com/modelcontextprotocol/python-sdk/issues/new?template=v2-feedback.yaml) — it is the most useful thing you can do for the SDK right now.
6
7
7
8
The **Model Context Protocol (MCP)** lets applications provide context to LLMs in a standardized way, separating the concern of *providing* context from the LLM interaction itself.
@@ -93,6 +94,7 @@ You wrote two Python functions with type hints and a docstring. The SDK does the
93
94
* Building an application that *uses* MCP servers? Start with **[Clients](client/index.md)**.
94
95
* Already have a FastAPI or Starlette app? **[Add to an existing app](run/asgi.md)** mounts an MCP server inside it.
95
96
* Hunting an exact error message? **[Troubleshooting](troubleshooting.md)** is keyed by the verbatim text.
97
+
* Wondering what changed in v2? **[What's new in v2](whats-new.md)** is the five-minute tour.
96
98
* Migrating from v1? Start with the **[Migration Guide](migration.md)**.
97
99
* Hunting for an exact signature? The **[API Reference](api/mcp/index.md)** is generated from the source.
98
100
* Reading with an LLM? This documentation is also published in the [llms.txt](https://llmstxt.org/) format:
### Sync handler functions now run on a worker thread
710
+
711
+
In v1, a synchronous (`def`) tool, resource, or prompt function was called inline on the event
712
+
loop, so a body that blocked (an HTTP call with a sync client, `time.sleep()`, heavy
713
+
computation) stalled every other in-flight request on the server. In v2 the SDK runs
714
+
synchronous handler functions in a worker thread via `anyio.to_thread.run_sync()`;
715
+
`async def` handlers are unchanged. Resolver functions (`Resolve(...)`) follow the same rule.
716
+
717
+
Most servers simply gain concurrency. Port with care if a synchronous handler relied on
718
+
running on the event-loop thread:
719
+
720
+
- Thread-affine state (thread locals shared with startup code, non-thread-safe objects that
721
+
were only ever touched from the event loop's thread) is now touched from a worker thread.
722
+
-`asyncio.get_running_loop()` inside a synchronous handler body raises `RuntimeError`; there
723
+
is no running loop in a worker thread.
724
+
- Synchronous handlers can run concurrently with each other, up to anyio's default
725
+
worker-thread limit.
726
+
727
+
Declare the handler `async def` to keep it on the event loop.
728
+
709
729
### `MCPServer.call_tool()`, `read_resource()`, `get_prompt()` now accept a `context` parameter
710
730
711
731
`MCPServer.call_tool()`, `MCPServer.read_resource()`, and `MCPServer.get_prompt()` now accept an optional `context: Context | None = None` parameter. The framework passes this automatically during normal request handling. If you call these methods directly and omit `context`, a Context with no active request is constructed for you — tools that don't use `ctx` work normally, but any attempt to use `ctx.session`, `ctx.request_id`, etc. will raise.
If you relied on extra fields round-tripping through MCP types, move that data into `_meta`.
1609
1629
1630
+
### `mcp dev` and `mcp install` pin the spawned environment to your SDK version
1631
+
1632
+
Both commands run your server through a fresh `uv run --with ...` environment. In v1 the
1633
+
`mcp` requirement in that command was unpinned, so the spawned environment resolved to the
1634
+
newest stable release rather than the version you had installed; with a v2 pre-release
1635
+
installed, `mcp dev server.py` built a v1 environment that could not import a v2 server.
1636
+
Both commands now pin the requirement to the version you are running
1637
+
(`mcp==<installed version>`). Source builds and other unpublished versions, which have
1638
+
nothing on PyPI to pin to, keep the unpinned form.
1639
+
1610
1640
## New Features
1611
1641
1612
1642
### OAuth client credentials are bound to their authorization server ([SEP-2352](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2352))
0 commit comments