fix: add default values to Literal type fields in content types (#1867)

This commit is contained in:
Felix Weinberger 2026-01-16 10:01:57 +00:00 • committed by GitHub
commit 9f427f3292
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -939,7 +939,7 @@ class GetPromptRequest(Request[GetPromptRequestParams, Literal["prompts/get"]]):
class TextContent(MCPModel): class TextContent(MCPModel):
"""Text content for a message.""" """Text content for a message."""
type: Literal["text"] type: Literal["text"] = "text"
text: str text: str
"""The text content of the message.""" """The text content of the message."""
annotations: Annotations | None = None annotations: Annotations | None = None
@ -953,7 +953,7 @@ class TextContent(MCPModel):
class ImageContent(MCPModel): class ImageContent(MCPModel):
"""Image content for a message.""" """Image content for a message."""
type: Literal["image"] type: Literal["image"] = "image"
data: str data: str
"""The base64-encoded image data.""" """The base64-encoded image data."""
mimeType: str mimeType: str
@ -972,7 +972,7 @@ class ImageContent(MCPModel):
class AudioContent(MCPModel): class AudioContent(MCPModel):
"""Audio content for a message.""" """Audio content for a message."""
type: Literal["audio"] type: Literal["audio"] = "audio"
data: str data: str
"""The base64-encoded audio data.""" """The base64-encoded audio data."""
mimeType: str mimeType: str
@ -997,7 +997,7 @@ class ToolUseContent(MCPModel):
in the next user message. in the next user message.
""" """
type: Literal["tool_use"] type: Literal["tool_use"] = "tool_use"
"""Discriminator for tool use content.""" """Discriminator for tool use content."""
name: str name: str
@ -1024,7 +1024,7 @@ class ToolResultContent(MCPModel):
from the assistant. It contains the output of executing the requested tool. from the assistant. It contains the output of executing the requested tool.
""" """
type: Literal["tool_result"] type: Literal["tool_result"] = "tool_result"
"""Discriminator for tool result content.""" """Discriminator for tool result content."""
toolUseId: str toolUseId: str
@ -1089,7 +1089,7 @@ class EmbeddedResource(MCPModel):
of the LLM and/or the user. of the LLM and/or the user.
""" """
type: Literal["resource"] type: Literal["resource"] = "resource"
resource: TextResourceContents | BlobResourceContents resource: TextResourceContents | BlobResourceContents
annotations: Annotations | None = None annotations: Annotations | None = None
meta: dict[str, Any] | None = Field(alias="_meta", default=None) meta: dict[str, Any] | None = Field(alias="_meta", default=None)
@ -1106,7 +1106,7 @@ class ResourceLink(Resource):
Note: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests. Note: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests.
""" """
type: Literal["resource_link"] type: Literal["resource_link"] = "resource_link"
ContentBlock = TextContent | ImageContent | AudioContent | ResourceLink | EmbeddedResource ContentBlock = TextContent | ImageContent | AudioContent | ResourceLink | EmbeddedResource
@ -1480,7 +1480,7 @@ class CreateMessageResultWithTools(Result):
class ResourceTemplateReference(MCPModel): class ResourceTemplateReference(MCPModel):
"""A reference to a resource or resource template definition.""" """A reference to a resource or resource template definition."""
type: Literal["ref/resource"] type: Literal["ref/resource"] = "ref/resource"
uri: str uri: str
"""The URI or URI template of the resource.""" """The URI or URI template of the resource."""
@ -1488,7 +1488,7 @@ class ResourceTemplateReference(MCPModel):
class PromptReference(MCPModel): class PromptReference(MCPModel):
"""Identifies a prompt.""" """Identifies a prompt."""
type: Literal["ref/prompt"] type: Literal["ref/prompt"] = "ref/prompt"
name: str name: str
"""The name of the prompt or prompt template""" """The name of the prompt or prompt template"""