Skip to content

feat: add _meta to more objects #963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 43 additions & 6 deletions src/mcp/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ class Meta(BaseModel):

meta: Meta | None = Field(alias="_meta", default=None)
"""
This parameter name is reserved by MCP to allow clients and servers to attach
additional metadata to their notifications.
Reserved by MCP for protocol-level metadata; implementations must not make assumptions about its contents.
"""


Expand Down Expand Up @@ -105,13 +104,11 @@ class Notification(BaseModel, Generic[NotificationParamsT, MethodT]):
class Result(BaseModel):
"""Base class for JSON-RPC results."""

model_config = ConfigDict(extra="allow")

meta: dict[str, Any] | None = Field(alias="_meta", default=None)
"""
This result property is reserved by the protocol to allow clients and servers to
attach additional metadata to their responses.
Reserved by MCP for protocol-level metadata; implementations must not make assumptions about its contents.
"""
model_config = ConfigDict(extra="allow")


class PaginatedResult(Result):
Expand Down Expand Up @@ -394,6 +391,10 @@ class Resource(BaseModel):
This can be used by Hosts to display file sizes and estimate context window usage.
"""
annotations: Annotations | None = None
meta: dict[str, Any] | None = Field(alias="_meta", default=None)
"""
Reserved by MCP for protocol-level metadata; implementations must not make assumptions about its contents.
"""
model_config = ConfigDict(extra="allow")


Expand All @@ -415,6 +416,10 @@ class ResourceTemplate(BaseModel):
included if all resources matching this template have the same type.
"""
annotations: Annotations | None = None
meta: dict[str, Any] | None = Field(alias="_meta", default=None)
"""
Reserved by MCP for protocol-level metadata; implementations must not make assumptions about its contents.
"""
model_config = ConfigDict(extra="allow")


Expand Down Expand Up @@ -461,6 +466,10 @@ class ResourceContents(BaseModel):
"""The URI of this resource."""
mimeType: str | None = None
"""The MIME type of this resource, if known."""
meta: dict[str, Any] | None = Field(alias="_meta", default=None)
"""
Reserved by MCP for protocol-level metadata; implementations must not make assumptions about its contents.
"""
model_config = ConfigDict(extra="allow")


Expand Down Expand Up @@ -588,6 +597,10 @@ class Prompt(BaseModel):
"""An optional description of what this prompt provides."""
arguments: list[PromptArgument] | None = None
"""A list of arguments to use for templating the prompt."""
meta: dict[str, Any] | None = Field(alias="_meta", default=None)
"""
Reserved by MCP for protocol-level metadata; implementations must not make assumptions about its contents.
"""
model_config = ConfigDict(extra="allow")


Expand Down Expand Up @@ -621,6 +634,10 @@ class TextContent(BaseModel):
text: str
"""The text content of the message."""
annotations: Annotations | None = None
meta: dict[str, Any] | None = Field(alias="_meta", default=None)
"""
Reserved by MCP for protocol-level metadata; implementations must not make assumptions about its contents.
"""
model_config = ConfigDict(extra="allow")


Expand All @@ -636,6 +653,10 @@ class ImageContent(BaseModel):
image types.
"""
annotations: Annotations | None = None
meta: dict[str, Any] | None = Field(alias="_meta", default=None)
"""
Reserved by MCP for protocol-level metadata; implementations must not make assumptions about its contents.
"""
model_config = ConfigDict(extra="allow")


Expand All @@ -651,6 +672,10 @@ class AudioContent(BaseModel):
audio types.
"""
annotations: Annotations | None = None
meta: dict[str, Any] | None = Field(alias="_meta", default=None)
"""
Reserved by MCP for protocol-level metadata; implementations must not make assumptions about its contents.
"""
model_config = ConfigDict(extra="allow")


Expand All @@ -673,6 +698,10 @@ class EmbeddedResource(BaseModel):
type: Literal["resource"]
resource: TextResourceContents | BlobResourceContents
annotations: Annotations | None = None
meta: dict[str, Any] | None = Field(alias="_meta", default=None)
"""
Reserved by MCP for protocol-level metadata; implementations must not make assumptions about its contents.
"""
model_config = ConfigDict(extra="allow")


Expand Down Expand Up @@ -772,6 +801,10 @@ class Tool(BaseModel):
"""A JSON Schema object defining the expected parameters for the tool."""
annotations: ToolAnnotations | None = None
"""Optional additional tool information."""
meta: dict[str, Any] | None = Field(alias="_meta", default=None)
"""
Reserved by MCP for protocol-level metadata; implementations must not make assumptions about its contents.
"""
model_config = ConfigDict(extra="allow")


Expand Down Expand Up @@ -1064,6 +1097,10 @@ class Root(BaseModel):
identifier for the root, which may be useful for display purposes or for
referencing the root in other parts of the application.
"""
meta: dict[str, Any] | None = Field(alias="_meta", default=None)
"""
Reserved by MCP for protocol-level metadata; implementations must not make assumptions about its contents.
"""
model_config = ConfigDict(extra="allow")


Expand Down
Loading