Skip to content

Commit 2374c99

Browse files
committed
docs: extra fields on MCP types are ignored, not rejected
The migration guide claimed v2 MCP types raise a ValidationError for unknown top-level fields. They are configured with pydantic's default extra behavior, which silently drops unknown fields during validation. Describe the actual behavior (values do not round-trip, no error) and keep pointing users at _meta for custom data.
1 parent 3789d00 commit 2374c99

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

docs/migration.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,28 +1182,32 @@ Tasks are expected to return as a separate MCP extension in a future release.
11821182

11831183
Previously, the lowlevel `Server` hardcoded `subscribe=False` in resource capabilities even when a `subscribe_resource()` handler was registered. The `subscribe` capability is now dynamically set to `True` when an `on_subscribe_resource` handler is provided. Clients that previously didn't see `subscribe: true` in capabilities will now see it when a handler is registered, which may change client behavior.
11841184

1185-
### Extra fields no longer allowed on top-level MCP types
1185+
### Extra fields on MCP types are no longer preserved
11861186

1187-
MCP protocol types no longer accept arbitrary extra fields at the top level. This matches the MCP specification which only allows extra fields within `_meta` objects, not on the types themselves.
1187+
In v1, MCP protocol types were configured with `extra="allow"`: unknown fields passed to a constructor or received from a peer were kept on the model and re-serialized on output.
1188+
1189+
In v2, MCP types silently ignore extra fields. Unknown constructor keyword arguments and unknown keys in wire data are dropped during validation — no error is raised, and the values do not round-trip:
11881190

11891191
```python
1190-
# This will now raise a validation error
11911192
from mcp.types import CallToolRequestParams
11921193

11931194
params = CallToolRequestParams(
11941195
name="my_tool",
11951196
arguments={},
1196-
unknown_field="value", # ValidationError: extra fields not permitted
1197+
unknown_field="value", # silently ignored, not stored
11971198
)
1199+
"unknown_field" in params.model_dump() # False
11981200

1199-
# Extra fields are still allowed in _meta
1201+
# _meta remains the supported place for custom data, per the MCP spec
12001202
params = CallToolRequestParams(
12011203
name="my_tool",
12021204
arguments={},
1203-
_meta={"my_custom_key": "value", "another": 123}, # OK
1205+
_meta={"my_custom_key": "value", "another": 123}, # OK, preserved
12041206
)
12051207
```
12061208

1209+
If you relied on extra fields round-tripping through MCP types, move that data into `_meta`.
1210+
12071211
## New Features
12081212

12091213
### `streamable_http_app()` available on lowlevel Server

0 commit comments

Comments
 (0)