Skip to content

Commit e448b42

Browse files
committed
Proper handle extra data in MCP objects
1 parent f0ab53e commit e448b42

File tree

3 files changed

+17
-154
lines changed

3 files changed

+17
-154
lines changed

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ dependencies = [
2626
"anyio>=4.5",
2727
"httpx>=0.27.1",
2828
"httpx-sse>=0.4",
29-
"pydantic>=2.12.0; python_version >= '3.14'",
30-
"pydantic>=2.11.0; python_version < '3.14'",
29+
"pydantic>=2.12.0",
3130
"starlette>=0.48.0; python_version >= '3.14'",
3231
"starlette>=0.27; python_version < '3.14'",
3332
"python-multipart>=0.0.9",

src/mcp/types/_types.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
class MCPModel(BaseModel):
3333
"""Base class for all MCP protocol types. Allows extra fields for forward compatibility."""
3434

35-
# TODO(Marcelo): The extra="allow" should be only on specific types e.g. `Meta`, not on the base class.
36-
model_config = ConfigDict(extra="allow", alias_generator=to_camel, populate_by_name=True)
35+
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
3736

3837

3938
Meta: TypeAlias = dict[str, Any]
@@ -472,10 +471,13 @@ class GetTaskPayloadRequest(Request[GetTaskPayloadRequestParams, Literal["tasks/
472471

473472
class GetTaskPayloadResult(Result):
474473
"""The response to a tasks/result request.
474+
475475
The structure matches the result type of the original request.
476476
For example, a tools/call task would return the CallToolResult structure.
477477
"""
478478

479+
model_config = ConfigDict(extra="allow")
480+
479481

480482
class CancelTaskRequestParams(RequestParams):
481483
task_id: str

0 commit comments

Comments
 (0)