Proper handle extra data in MCP objects (#1937)

This commit is contained in:
Marcelo Trylesinski 2026-01-23 15:35:23 +01:00 • committed by GitHub
commit a1d330de9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -30,10 +30,9 @@ TASK_REQUIRED: Final[Literal["required"]] = "required"
class MCPModel(BaseModel):
"""Base class for all MCP protocol types. Allows extra fields for forward compatibility."""
"""Base class for all MCP protocol types."""
# TODO(Marcelo): The extra="allow" should be only on specific types e.g. `Meta`, not on the base class.
model_config = ConfigDict(extra="allow", alias_generator=to_camel, populate_by_name=True)
model_config = ConfigDict(alias_generator=to_camel, populate_by_name=True)
Meta: TypeAlias = dict[str, Any]
@ -472,10 +471,13 @@ class GetTaskPayloadRequest(Request[GetTaskPayloadRequestParams, Literal["tasks/
class GetTaskPayloadResult(Result):
"""The response to a tasks/result request.
The structure matches the result type of the original request.
For example, a tools/call task would return the CallToolResult structure.
"""
model_config = ConfigDict(extra="allow", alias_generator=to_camel, populate_by_name=True)
class CancelTaskRequestParams(RequestParams):
task_id: str