Skip to content

Commit 9f427f3

Browse files
fix: add default values to Literal type fields in content types (#1867)
1 parent d5edcb3 commit 9f427f3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/mcp/types.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,7 @@ class GetPromptRequest(Request[GetPromptRequestParams, Literal["prompts/get"]]):
939939
class TextContent(MCPModel):
940940
"""Text content for a message."""
941941

942-
type: Literal["text"]
942+
type: Literal["text"] = "text"
943943
text: str
944944
"""The text content of the message."""
945945
annotations: Annotations | None = None
@@ -953,7 +953,7 @@ class TextContent(MCPModel):
953953
class ImageContent(MCPModel):
954954
"""Image content for a message."""
955955

956-
type: Literal["image"]
956+
type: Literal["image"] = "image"
957957
data: str
958958
"""The base64-encoded image data."""
959959
mimeType: str
@@ -972,7 +972,7 @@ class ImageContent(MCPModel):
972972
class AudioContent(MCPModel):
973973
"""Audio content for a message."""
974974

975-
type: Literal["audio"]
975+
type: Literal["audio"] = "audio"
976976
data: str
977977
"""The base64-encoded audio data."""
978978
mimeType: str
@@ -997,7 +997,7 @@ class ToolUseContent(MCPModel):
997997
in the next user message.
998998
"""
999999

1000-
type: Literal["tool_use"]
1000+
type: Literal["tool_use"] = "tool_use"
10011001
"""Discriminator for tool use content."""
10021002

10031003
name: str
@@ -1024,7 +1024,7 @@ class ToolResultContent(MCPModel):
10241024
from the assistant. It contains the output of executing the requested tool.
10251025
"""
10261026

1027-
type: Literal["tool_result"]
1027+
type: Literal["tool_result"] = "tool_result"
10281028
"""Discriminator for tool result content."""
10291029

10301030
toolUseId: str
@@ -1089,7 +1089,7 @@ class EmbeddedResource(MCPModel):
10891089
of the LLM and/or the user.
10901090
"""
10911091

1092-
type: Literal["resource"]
1092+
type: Literal["resource"] = "resource"
10931093
resource: TextResourceContents | BlobResourceContents
10941094
annotations: Annotations | None = None
10951095
meta: dict[str, Any] | None = Field(alias="_meta", default=None)
@@ -1106,7 +1106,7 @@ class ResourceLink(Resource):
11061106
Note: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests.
11071107
"""
11081108

1109-
type: Literal["resource_link"]
1109+
type: Literal["resource_link"] = "resource_link"
11101110

11111111

11121112
ContentBlock = TextContent | ImageContent | AudioContent | ResourceLink | EmbeddedResource
@@ -1480,15 +1480,15 @@ def content_as_list(self) -> list[SamplingMessageContentBlock]:
14801480
class ResourceTemplateReference(MCPModel):
14811481
"""A reference to a resource or resource template definition."""
14821482

1483-
type: Literal["ref/resource"]
1483+
type: Literal["ref/resource"] = "ref/resource"
14841484
uri: str
14851485
"""The URI or URI template of the resource."""
14861486

14871487

14881488
class PromptReference(MCPModel):
14891489
"""Identifies a prompt."""
14901490

1491-
type: Literal["ref/prompt"]
1491+
type: Literal["ref/prompt"] = "ref/prompt"
14921492
name: str
14931493
"""The name of the prompt or prompt template"""
14941494

0 commit comments

Comments
 (0)