8000 feat: add _meta to more objects (#963) · modelcontextprotocol/python-sdk@1eb1bba · GitHub
[go: up one dir, main page]

Skip to content

Commit 1eb1bba

Browse files
feat: add _meta to more objects (#963)
1 parent f3cd20c commit 1eb1bba

File tree

1 file changed

+43
-6
lines changed

1 file changed

+43
-6
lines changed

src/mcp/types.py

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ class Meta(BaseModel):
6969

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

7675

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

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

116113

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

399400

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

420425

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

466475

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

593606

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

626643

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

641662

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

656681

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

678707

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

777810

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

10691106

0 commit comments

Comments
 (0)
0