Skip to content

Commit e4d95e0

Browse files
authored
docs: add a "What's new in v2" page (#3054)
1 parent 220d362 commit e4d95e0

9 files changed

Lines changed: 348 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
>
1919
> **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.**
2020
>
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).
2222
2323
## Documentation
2424

2525
**The documentation lives at <https://py.sdk.modelcontextprotocol.io/v2/>.**
2626

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/).
2828

2929
## What is MCP?
3030

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
!!! info "You are viewing the in-development v2 documentation"
44
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.
56
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.
67

78
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
9394
* Building an application that *uses* MCP servers? Start with **[Clients](client/index.md)**.
9495
* Already have a FastAPI or Starlette app? **[Add to an existing app](run/asgi.md)** mounts an MCP server inside it.
9596
* 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.
9698
* Migrating from v1? Start with the **[Migration Guide](migration.md)**.
9799
* Hunting for an exact signature? The **[API Reference](api/mcp/index.md)** is generated from the source.
98100
* Reading with an LLM? This documentation is also published in the [llms.txt](https://llmstxt.org/) format:

docs/migration.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,26 @@ async def my_tool(x: int, ctx: Context) -> str:
706706
return str(x)
707707
```
708708

709+
### 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+
709729
### `MCPServer.call_tool()`, `read_resource()`, `get_prompt()` now accept a `context` parameter
710730

711731
`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.
@@ -1607,6 +1627,16 @@ params = CallToolRequestParams(
16071627

16081628
If you relied on extra fields round-tripping through MCP types, move that data into `_meta`.
16091629

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+
16101640
## New Features
16111641

16121642
### OAuth client credentials are bound to their authorization server ([SEP-2352](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2352))

0 commit comments

Comments
 (0)