Skip to content

Commit d52fbc6

Browse files
committed
Protocol types for 2026-07-28: superset monolith, generated per-version packages, and wire-method maps
One public type set (mcp.types) covering every protocol revision through 2026-07-28; two per-version model packages generated from vendored schema.json (scripts/gen_surface_types.py, --check enforced in CI) that act as the schema-exact validating layer; and plain (method, version) maps with two-step parse functions. Version gating is data: key absence is the gate. Outbound serialization is the model dump, with the new 2026-07-28 result fields as ordinary serialized defaults.
1 parent 1012d60 commit d52fbc6

25 files changed

Lines changed: 17456 additions & 193 deletions

.github/workflows/shared.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ jobs:
3030
env:
3131
SKIP: no-commit-to-branch,readme-v1-frozen
3232

33+
- name: Surface types match vendored schema
34+
run: |
35+
uv sync --group codegen --frozen
36+
uv run --group codegen python scripts/gen_surface_types.py --check
37+
3338
# TODO(Max): Drop this in v2. Deliberate updates (e.g. the v2 status
3439
# banner) go through the 'override-readme-freeze' label.
3540
- name: Check README.md is not modified

docs/migration.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ Common renames:
221221

222222
Because `populate_by_name=True` is set, the old camelCase names still work as constructor kwargs (e.g., `Tool(inputSchema={...})` is accepted), but attribute access must use snake_case (`tool.input_schema`).
223223

224+
### Results now serialize `resultType` and cache-directive defaults
225+
226+
Serialized results now include `resultType` by default (and `ttlMs`/`cacheScope` on cacheable results). Peers ignore unknown result fields, so this interoperates across protocol versions, but tests or recorded fixtures that compare exact serialized payloads need the new keys added.
227+
224228
### `args` parameter removed from `ClientSessionGroup.call_tool()`
225229

226230
The deprecated `args` parameter has been removed from `ClientSessionGroup.call_tool()`. Use `arguments` instead.
@@ -1181,7 +1185,7 @@ Behavior changes:
11811185

11821186
### Experimental Tasks support removed
11831187

1184-
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`.
1188+
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 the `experimental` properties on `ClientSession`, `ServerSession`, `Server`, and `ServerRequestContext`. The corresponding `Task*` types remain in `mcp.types` as types-only definitions.
11851189

11861190
Tasks are expected to return as a separate MCP extension in a future release.
11871191

@@ -1227,6 +1231,10 @@ If you relied on extra fields round-tripping through MCP types, move that data i
12271231

12281232
## New Features
12291233

1234+
### 2025-11-25 and 2026-07-28 protocol fields modeled
1235+
1236+
`mcp.types` models the 2025-11-25 and 2026-07-28 protocol fields (e.g. `resultType`, `ttlMs`/`cacheScope` on cacheable results, `inputResponses`/`requestState` on retried requests), so inbound payloads carrying these keys parse into typed fields and round-trip. Most are optional with `None` defaults; the result-directive fields carry serialized defaults - see [Results now serialize `resultType` and cache-directive defaults](#results-now-serialize-resulttype-and-cache-directive-defaults).
1237+
12301238
### `streamable_http_app()` available on lowlevel Server
12311239

12321240
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ docs = [
104104
"mkdocs-material[imaging]>=9.5.45",
105105
"mkdocstrings-python>=2.0.1",
106106
]
107+
codegen = ["datamodel-code-generator==0.57.0"]
107108

108109
[build-system]
109110
requires = ["hatchling", "uv-dynamic-versioning"]

schema/2025-11-25.json

Lines changed: 4057 additions & 0 deletions
Large diffs are not rendered by default.

schema/2026-07-28.json

Lines changed: 3873 additions & 0 deletions
Large diffs are not rendered by default.

schema/PINNED.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{
3+
"protocol_version": "2025-11-25",
4+
"source_path_in_spec_repo": "schema/2025-11-25/schema.json",
5+
"spec_commit": "6d441518de8a9d5adbab0b10a76a667a63f90665",
6+
"sha256": "4e01628360a2149892eab8f298ceee626d24a58862184eb8ec85d95b8f353e31"
7+
},
8+
{
9+
"protocol_version": "2026-07-28",
10+
"source_path_in_spec_repo": "schema/draft/schema.json",
11+
"spec_commit": "6d441518de8a9d5adbab0b10a76a667a63f90665",
12+
"sha256": "bce2e7c9622bb0b449475ba6d8d80228c71190a09250e75dabd502b280ecf3cb"
13+
}
14+
]

schema/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Vendored protocol schemas
2+
3+
JSON Schema files for each protocol version the SDK has a wire-shape surface
4+
package for, vendored from the [spec repository] at the commit recorded in
5+
`PINNED.json`. `scripts/gen_surface_types.py` reads these to regenerate
6+
`src/mcp/types/v<version>/__init__.py`; CI runs the generator with `--check`.
7+
8+
To bump: drop the new `schema.json` here as `<protocol-version>.json`, update
9+
the matching entry in `PINNED.json` (commit + sha256), and run
10+
`uv run --group codegen python scripts/gen_surface_types.py`.
11+
12+
[spec repository]: https://github.com/modelcontextprotocol/modelcontextprotocol

0 commit comments

Comments
 (0)