Skip to content

Commit 9a38b0d

Browse files
committed
Protocol types for 2026-07-28: superset monolith, committed per-version packages, and wire-method maps
One public type set (mcp.types) covering every protocol revision through 2026-07-28, two committed per-version model packages that act as the schema-exact validating layer, and plain (method, version) maps with two-step parse functions replacing the previous serializer boundary. 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 cf110e3 commit 9a38b0d

21 files changed

Lines changed: 9979 additions & 623 deletions

docs/migration.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,20 @@ 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`, `ttlMs`, and `cacheScope` defaults
225+
226+
The 2026-07-28 protocol revision requires every result to carry a `resultType` member and adds cache directives to the cacheable results. The v2 result types model these as fields with serialized defaults rather than `None`-defaulted optional fields, so serialized results now always include them:
227+
228+
- `CallToolResult`, `CompleteResult`, `DiscoverResult`, `GetPromptResult`, `ListPromptsResult`, `ListResourcesResult`, `ListResourceTemplatesResult`, `ListToolsResult`, and `ReadResourceResult` serialize `"resultType": "complete"`.
229+
- `InputRequiredResult` serializes `"resultType": "input_required"`.
230+
- The cacheable results (`DiscoverResult`, `ListPromptsResult`, `ListResourcesResult`, `ListResourceTemplatesResult`, `ListToolsResult`, `ReadResourceResult`) also serialize `"ttlMs": 0` and `"cacheScope": "private"`.
231+
232+
Modeling these as defaults keeps a single set of result types valid across protocol versions without the wire layer injecting fields at serialization time.
233+
234+
In v1 these keys never appeared in serialized results. Receivers ignore unknown result fields, so the added keys interoperate with peers on any protocol version, but tests or recorded fixtures that compare exact serialized result payloads need the new keys added.
235+
236+
`EmptyResult` is the deliberate exception: its `result_type` defaults to `None`, so `EmptyResult()` still dumps `{}`. Several deployed SDK implementations validate empty results strictly and reject unexpected keys, so the SDK never volunteers `resultType` on an empty result. Code answering with an empty result on a session negotiated at 2026-07-28 or later must construct `EmptyResult(result_type="complete")` explicitly (use `mcp.shared.version.is_version_at_least` for the floor check).
237+
224238
### `args` parameter removed from `ClientSessionGroup.call_tool()`
225239

226240
The deprecated `args` parameter has been removed from `ClientSessionGroup.call_tool()`. Use `arguments` instead.
@@ -1166,11 +1180,18 @@ In practice, replace direct `ServerSession` use with `Server.run(read_stream, wr
11661180

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

1169-
### Experimental Tasks support removed
1183+
### Experimental Tasks support removed (types restored, types-only)
1184+
1185+
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`.
1186+
1187+
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:
11701188

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`.
1189+
- Attributes are snake_case (`task_id`, `created_at`), aliased to the camelCase wire names.
1190+
- Timestamps are plain `str` values, not `datetime`.
1191+
- `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.
1192+
- None of the task methods is a member of the request/notification unions, and `add_request_handler` does not dispatch them.
11721193

1173-
Tasks are expected to return as a separate MCP extension in a future release.
1194+
Tasks runtime support is expected to return as a separate MCP extension in a future release.
11741195

11751196
## Deprecations
11761197

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

12151236
## New Features
12161237

1238+
### Newer protocol fields are modeled and retained
1239+
1240+
`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. Most of the new fields are optional with `None` defaults, so dumps of values that do not set them are unchanged; the result directive fields (`resultType`, `ttlMs`, `cacheScope`) instead carry serialized defaults — see [Results now serialize `resultType`, `ttlMs`, and `cacheScope` defaults](#results-now-serialize-resulttype-ttlms-and-cachescope-defaults) under Breaking Changes.
1241+
12171242
### `streamable_http_app()` available on lowlevel Server
12181243

12191244
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.

src/mcp/shared/version.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@
1616
"2025-03-26",
1717
"2025-06-18",
1818
"2025-11-25",
19+
"2026-07-28",
1920
)
20-
"""Every released protocol revision, oldest to newest."""
21+
"""Every protocol revision this SDK knows, oldest to newest.
22+
23+
Knowing a revision (its types and wire shapes are modeled) is independent of
24+
being able to negotiate it; see SUPPORTED_PROTOCOL_VERSIONS for the latter.
25+
"""
2126

2227
SUPPORTED_PROTOCOL_VERSIONS: list[str] = ["2024-11-05", "2025-03-26", "2025-06-18", LATEST_PROTOCOL_VERSION]
2328
"""Protocol revisions this SDK can negotiate."""

src/mcp/types/__init__.py

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
11
"""This module defines the types for the MCP protocol.
22
33
Check the latest schema at:
4-
https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/2025-11-25/schema.json
4+
https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/draft/schema.json
5+
6+
The models here are the version-superset types user code works with; the
7+
schema-exact wire shapes live in the surface packages
8+
(``mcp.types.v2025_11_25``, which serves every protocol version through
9+
2025-11-25, and ``mcp.types.v2026_07_28``).
510
"""
611

712
# Re-export everything from _types for backward compatibility
813
from mcp.types._types import (
14+
CLIENT_CAPABILITIES_META_KEY,
15+
CLIENT_INFO_META_KEY,
916
DEFAULT_NEGOTIATED_VERSION,
1017
LATEST_PROTOCOL_VERSION,
18+
LOG_LEVEL_META_KEY,
19+
PROTOCOL_VERSION_META_KEY,
1120
Annotations,
1221
AudioContent,
1322
BaseMetadata,
1423
BlobResourceContents,
24+
CacheableResult,
1525
CallToolRequest,
1626
CallToolRequestParams,
1727
CallToolResult,
1828
CancelledNotification,
1929
CancelledNotificationParams,
30+
CancelTaskRequest,
31+
CancelTaskRequestParams,
32+
CancelTaskResult,
2033
ClientCapabilities,
2134
ClientNotification,
2235
ClientRequest,
@@ -33,6 +46,9 @@
3346
CreateMessageRequestParams,
3447
CreateMessageResult,
3548
CreateMessageResultWithTools,
49+
CreateTaskResult,
50+
DiscoverRequest,
51+
DiscoverResult,
3652
ElicitationCapability,
3753
ElicitationRequiredErrorData,
3854
ElicitCompleteNotification,
@@ -49,6 +65,12 @@
4965
GetPromptRequest,
5066
GetPromptRequestParams,
5167
GetPromptResult,
68+
GetTaskPayloadRequest,
69+
GetTaskPayloadRequestParams,
70+
GetTaskPayloadResult,
71+
GetTaskRequest,
72+
GetTaskRequestParams,
73+
GetTaskResult,
5274
Icon,
5375
IconTheme,
5476
ImageContent,
@@ -58,6 +80,12 @@
5880
InitializeRequest,
5981
InitializeRequestParams,
6082
InitializeResult,
83+
InputRequest,
84+
InputRequests,
85+
InputRequiredResult,
86+
InputResponse,
87+
InputResponseRequestParams,
88+
InputResponses,
6189
ListPromptsRequest,
6290
ListPromptsResult,
6391
ListResourcesRequest,
@@ -66,12 +94,15 @@
6694
ListResourceTemplatesResult,
6795
ListRootsRequest,
6896
ListRootsResult,
97+
ListTasksRequest,
98+
ListTasksResult,
6999
ListToolsRequest,
70100
ListToolsResult,
71101
LoggingCapability,
72102
LoggingLevel,
73103
LoggingMessageNotification,
74104
LoggingMessageNotificationParams,
105+
MissingRequiredClientCapabilityErrorData,
75106
ModelHint,
76107
ModelPreferences,
77108
Notification,
@@ -92,6 +123,7 @@
92123
ReadResourceRequest,
93124
ReadResourceRequestParams,
94125
ReadResourceResult,
126+
RelatedTaskMetadata,
95127
Request,
96128
RequestParams,
97129
RequestParamsMeta,
@@ -105,6 +137,7 @@
105137
ResourceUpdatedNotification,
106138
ResourceUpdatedNotificationParams,
107139
Result,
140+
ResultType,
108141
Role,
109142
Root,
110143
RootsCapability,
@@ -124,17 +157,29 @@
124157
StopReason,
125158
SubscribeRequest,
126159
SubscribeRequestParams,
160+
SubscriptionFilter,
161+
SubscriptionsAcknowledgedNotification,
162+
SubscriptionsAcknowledgedNotificationParams,
163+
SubscriptionsListenRequest,
164+
SubscriptionsListenRequestParams,
165+
Task,
166+
TaskMetadata,
167+
TaskStatus,
168+
TaskStatusNotification,
169+
TaskStatusNotificationParams,
127170
TextContent,
128171
TextResourceContents,
129172
Tool,
130173
ToolAnnotations,
131174
ToolChoice,
175+
ToolExecution,
132176
ToolListChangedNotification,
133177
ToolResultContent,
134178
ToolsCapability,
135179
ToolUseContent,
136180
UnsubscribeRequest,
137181
UnsubscribeRequestParams,
182+
UnsupportedProtocolVersionErrorData,
138183
UrlElicitationCapability,
139184
client_notification_adapter,
140185
client_request_adapter,
@@ -150,10 +195,13 @@
150195
INTERNAL_ERROR,
151196
INVALID_PARAMS,
152197
INVALID_REQUEST,
198+
JSONRPC_VERSION,
153199
METHOD_NOT_FOUND,
200+
MISSING_REQUIRED_CLIENT_CAPABILITY,
154201
PARSE_ERROR,
155202
REQUEST_CANCELLED,
156203
REQUEST_TIMEOUT,
204+
UNSUPPORTED_PROTOCOL_VERSION,
157205
URL_ELICITATION_REQUIRED,
158206
ErrorData,
159207
JSONRPCError,
@@ -169,28 +217,41 @@
169217
# Protocol version constants
170218
"LATEST_PROTOCOL_VERSION",
171219
"DEFAULT_NEGOTIATED_VERSION",
220+
# Reserved request _meta keys
221+
"PROTOCOL_VERSION_META_KEY",
222+
"CLIENT_INFO_META_KEY",
223+
"CLIENT_CAPABILITIES_META_KEY",
224+
"LOG_LEVEL_META_KEY",
172225
# Type aliases and variables
173226
"ContentBlock",
174227
"ElicitRequestedSchema",
175228
"ElicitRequestParams",
176229
"IncludeContext",
230+
"InputRequest",
231+
"InputRequests",
232+
"InputResponse",
233+
"InputResponses",
177234
"LoggingLevel",
178235
"ProgressToken",
236+
"ResultType",
179237
"Role",
180238
"SamplingContent",
181239
"SamplingMessageContentBlock",
182240
"StopReason",
241+
"TaskStatus",
183242
# Base classes
184243
"BaseMetadata",
185244
"Request",
186245
"Notification",
187246
"Result",
188247
"RequestParams",
189248
"RequestParamsMeta",
249+
"InputResponseRequestParams",
190250
"NotificationParams",
191251
"PaginatedRequest",
192252
"PaginatedRequestParams",
193253
"PaginatedResult",
254+
"CacheableResult",
194255
"EmptyResult",
195256
# Capabilities
196257
"ClientCapabilities",
@@ -237,27 +298,40 @@
237298
"ResourceTemplateReference",
238299
"Root",
239300
"SamplingMessage",
301+
"SubscriptionFilter",
302+
"Task",
303+
"TaskMetadata",
304+
"RelatedTaskMetadata",
240305
"Tool",
241306
"ToolAnnotations",
242307
"ToolChoice",
308+
"ToolExecution",
243309
# Requests
244310
"CallToolRequest",
245311
"CallToolRequestParams",
246312
"CompleteRequest",
247313
"CompleteRequestParams",
314+
"CancelTaskRequest",
315+
"CancelTaskRequestParams",
248316
"CreateMessageRequest",
249317
"CreateMessageRequestParams",
318+
"DiscoverRequest",
250319
"ElicitRequest",
251320
"ElicitRequestFormParams",
252321
"ElicitRequestURLParams",
253322
"GetPromptRequest",
254323
"GetPromptRequestParams",
324+
"GetTaskPayloadRequest",
325+
"GetTaskPayloadRequestParams",
326+
"GetTaskRequest",
327+
"GetTaskRequestParams",
255328
"InitializeRequest",
256329
"InitializeRequestParams",
257330
"ListPromptsRequest",
258331
"ListResourcesRequest",
259332
"ListResourceTemplatesRequest",
260333
"ListRootsRequest",
334+
"ListTasksRequest",
261335
"ListToolsRequest",
262336
"PingRequest",
263337
"ReadResourceRequest",
@@ -266,23 +340,35 @@
266340
"SetLevelRequestParams",
267341
"SubscribeRequest",
268342
"SubscribeRequestParams",
343+
"SubscriptionsListenRequest",
344+
"SubscriptionsListenRequestParams",
269345
"UnsubscribeRequest",
270346
"UnsubscribeRequestParams",
271347
# Results
272348
"CallToolResult",
349+
"CancelTaskResult",
273350
"CompleteResult",
274351
"CreateMessageResult",
275352
"CreateMessageResultWithTools",
353+
"CreateTaskResult",
354+
"DiscoverResult",
276355
"ElicitResult",
277356
"ElicitationRequiredErrorData",
278357
"GetPromptResult",
358+
"GetTaskPayloadResult",
359+
"GetTaskResult",
279360
"InitializeResult",
361+
"InputRequiredResult",
280362
"ListPromptsResult",
281363
"ListResourcesResult",
282364
"ListResourceTemplatesResult",
283365
"ListRootsResult",
366+
"ListTasksResult",
284367
"ListToolsResult",
285368
"ReadResourceResult",
369+
# Error data payloads
370+
"MissingRequiredClientCapabilityErrorData",
371+
"UnsupportedProtocolVersionErrorData",
286372
# Notifications
287373
"CancelledNotification",
288374
"CancelledNotificationParams",
@@ -298,6 +384,10 @@
298384
"ResourceUpdatedNotification",
299385
"ResourceUpdatedNotificationParams",
300386
"RootsListChangedNotification",
387+
"SubscriptionsAcknowledgedNotification",
388+
"SubscriptionsAcknowledgedNotificationParams",
389+
"TaskStatusNotification",
390+
"TaskStatusNotificationParams",
301391
"ToolListChangedNotification",
302392
# Union types for request/response routing
303393
"ClientNotification",
@@ -318,10 +408,13 @@
318408
"INTERNAL_ERROR",
319409
"INVALID_PARAMS",
320410
"INVALID_REQUEST",
411+
"JSONRPC_VERSION",
321412
"METHOD_NOT_FOUND",
413+
"MISSING_REQUIRED_CLIENT_CAPABILITY",
322414
"PARSE_ERROR",
323415
"REQUEST_CANCELLED",
324416
"REQUEST_TIMEOUT",
417+
"UNSUPPORTED_PROTOCOL_VERSION",
325418
"URL_ELICITATION_REQUIRED",
326419
"ErrorData",
327420
"JSONRPCError",

0 commit comments

Comments
 (0)