You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: docs/migration.md
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1182,28 +1182,32 @@ Tasks are expected to return as a separate MCP extension in a future release.
1182
1182
1183
1183
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.
1184
1184
1185
-
### Extra fields no longer allowed on top-level MCP types
1185
+
### Extra fields on MCP types are no longer preserved
1186
1186
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:
1188
1190
1189
1191
```python
1190
-
# This will now raise a validation error
1191
1192
from mcp.types import CallToolRequestParams
1192
1193
1193
1194
params = CallToolRequestParams(
1194
1195
name="my_tool",
1195
1196
arguments={},
1196
-
unknown_field="value", #ValidationError: extra fields not permitted
1197
+
unknown_field="value", #silently ignored, not stored
1197
1198
)
1199
+
"unknown_field"in params.model_dump() # False
1198
1200
1199
-
#Extra fields are still allowed in _meta
1201
+
#_meta remains the supported place for custom data, per the MCP spec
1200
1202
params = CallToolRequestParams(
1201
1203
name="my_tool",
1202
1204
arguments={},
1203
-
_meta={"my_custom_key": "value", "another": 123}, # OK
0 commit comments