Skip to content

Commit 6e1bfac

Browse files
committed
Add multi-version protocol types: two wire-shape surface packages
One superset type set in mcp.types plus two hand-validated model packages: mcp.types.v2025_11_25, whose models serve every protocol version up to and including 2025-11-25 (the schemas through that revision evolve strictly additively; a structural coverage test proves the newest one covers them all), and mcp.types.v2026_07_28 for the new protocol revision. Serialization is additive-only: nothing is ever removed from a model's dump at any version. Sessions at 2025-11-25 and earlier emit the plain dump byte for byte; on 2026-07-28 sessions the wire boundary injects the protocol-required fields the caller left unset (resultType, the ttlMs/cacheScope don't-cache defaults, the reserved protocolVersion _meta entry) and validates the result through the 2026-07-28 models as a check before emitting the injected dump unchanged.
1 parent 7267818 commit 6e1bfac

32 files changed

Lines changed: 27067 additions & 194 deletions

docs/migration.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,11 +1166,18 @@ In practice, replace direct `ServerSession` use with `Server.run(read_stream, wr
11661166

11671167
`BaseSession` is still used by `ClientSession`, which never relied on these members. `RequestResponder.respond()` is unchanged.
11681168

1169-
### Experimental Tasks support removed
1169+
### Experimental Tasks support removed (types restored, types-only)
11701170

1171-
Tasks (SEP-1686) have been removed from the MCP specification and are no longer part of this SDK. The `mcp.client.experimental`, `mcp.server.experimental`, `mcp.shared.experimental`, and `mcp.server.lowlevel.experimental` modules have been removed, along with all `Task*` types, the `tasks` capability fields, `Tool.execution`, and the `experimental` properties on `ClientSession`, `ServerSession`, `Server`, and `ServerRequestContext`.
1171+
Tasks (SEP-1686) runtime support has been removed from this SDK. The `mcp.client.experimental`, `mcp.server.experimental`, `mcp.shared.experimental`, and `mcp.server.lowlevel.experimental` modules are gone, along with the `experimental` properties on `ClientSession`, `ServerSession`, `Server`, and `ServerRequestContext`.
11721172

1173-
Tasks are expected to return as a separate MCP extension in a future release.
1173+
The 2025-11-25 protocol *types* are back in `mcp.types` so that 2025-11-25 task payloads can still be modeled: the `Task*` types, the `tasks` capability subtrees, `Tool.execution`, and the `task` field on the four task-augmentable params classes. They are types-only definitions:
1174+
1175+
- Attributes are snake_case (`task_id`, `created_at`), aliased to the camelCase wire names.
1176+
- Timestamps are plain `str` values, not `datetime`.
1177+
- `GetTaskPayloadResult` follows the default extra-field policy (`ignore`), so it retains only `_meta`; validate a tasks/result payload into the original request's result type instead.
1178+
- None of the task methods is a member of the request/notification unions, and `add_request_handler` does not dispatch them.
1179+
1180+
Tasks runtime support is expected to return as a separate MCP extension in a future release.
11741181

11751182
## Deprecations
11761183

@@ -1214,6 +1221,10 @@ If you relied on extra fields round-tripping through MCP types, move that data i
12141221

12151222
## New Features
12161223

1224+
### Newer protocol fields are modeled and retained
1225+
1226+
`mcp.types` now models the 2025-11-25 and 2026-07-28 protocol fields and types (for example `resultType`, `ttlMs`/`cacheScope` on the cacheable results, and `inputResponses`/`requestState` on retried requests). Inbound payloads carrying these keys used to lose them to the unknown-field policy on re-dump; they now parse into typed fields and survive a user-level round-trip. All of the new fields are optional with `None` defaults, so dumps of values that do not set them are unchanged.
1227+
12171228
### `streamable_http_app()` available on lowlevel Server
12181229

12191230
The `streamable_http_app()` method is now available directly on the lowlevel `Server` class, not just `MCPServer`. This allows using the streamable HTTP transport without the MCPServer wrapper.

pyproject.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,19 @@ venv = ".venv"
143143
# those private functions instead of testing the private functions directly. It makes it easier to maintain the code source
144144
# and refactor code that is not public.
145145
executionEnvironments = [
146+
# Generated spec-oracle modules carry two emission shapes pyright rejects
147+
# but pydantic handles correctly, and no semantics-preserving spelling
148+
# avoids either: (1) the schema's named-error defs require `data` while the
149+
# base JSON-RPC error object has it optional - the required-field override
150+
# is right on the wire (the requiredness audit in
151+
# scripts/update_spec_types.py pins it) but trips the dataclass-transform
152+
# rule (reportGeneralTypeIssues); (2) the draft schema's recursive
153+
# JSONValue/JSONObject alias group must be emitted as a whole-string
154+
# TypeAliasType value for lazy parsing, which pyright flags at its use
155+
# sites (reportInvalidTypeForm, reportUnknownVariableType).
156+
{ root = "tests/spec_oracles", extraPaths = [
157+
".",
158+
], reportUnusedFunction = false, reportPrivateUsage = false, reportGeneralTypeIssues = false, reportInvalidTypeForm = false, reportUnknownVariableType = false },
146159
{ root = "tests", extraPaths = [
147160
".",
148161
], reportUnusedFunction = false, reportPrivateUsage = false },
@@ -177,6 +190,9 @@ max-complexity = 24 # Default is 10
177190

178191
[tool.ruff.lint.per-file-ignores]
179192
"__init__.py" = ["F401"]
193+
# Generated spec-oracle modules: docstrings come verbatim from the spec schema
194+
# and ruff format does not wrap long docstring lines.
195+
"tests/spec_oracles/v*.py" = ["E501"]
180196
"tests/server/mcpserver/test_func_metadata.py" = ["E501"]
181197
"tests/shared/test_progress_notifications.py" = ["PLW0603"]
182198

0 commit comments

Comments
 (0)