8000 chore: create union for working with message content by LucaButBoring · Pull Request #939 · modelcontextprotocol/python-sdk · GitHub
[go: up one dir, main page]

Skip to content

chore: create union for working with message content #939

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

Conversation

LucaButBoring
Copy link
Contributor

Moves message content types into a union and uses that throughout the codebase. Suggested by @Kludex in #725.

Motivation and Context

Simplifies code, makes for fewer places to update when new content types are introduced in the future.

How Has This Been Tested?

Unit tests

Breaking Changes

None

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@@ -7,18 +7,16 @@
import pydantic_core
from pydantic import BaseModel, Field, TypeAdapter, validate_call

from mcp.types import AudioContent, EmbeddedResource, ImageContent, TextContent

CONTENT_TYPES = TextContent | ImageContent | AudioContent | EmbeddedResource
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will accept this PR as I don't think anyone is importing this directly.

@Kludex Kludex merged commit d69b290 into modelcontextprotocol:main Jun 12, 2025
24 of 27 checks passed
@LucaButBoring LucaButBoring deleted the chore/message-content-union branch June 12, 2025 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0