Skip to content

Normalize supported MCP media types during content conversion - #1987

Open
sylvesterkaczmarek wants to merge 1 commit into
anthropics:mainfrom
sylvesterkaczmarek:fix/mcp-media-type-normalization-20261006-s
Open

sylvesterkaczmarek wants to merge 1 commit into
anthropics:mainfrom
sylvesterkaczmarek:fix/mcp-media-type-normalization-20261006-s

Conversation

@sylvesterkaczmarek

@sylvesterkaczmarek sylvesterkaczmarek commented Oct 5, 2026 •

Copy link
Copy Markdown

Fixes #1986.

Normalize the base MIME type when selecting and converting MCP images and resources, and emit canonical image media types. Previously an uppercase or parameterized supported type could raise UnsupportedMCPValueError or cause selection to return a later resource.

Normalization is private and shared by the existing conversion paths. It strips the parameter suffix, trims surrounding whitespace and lowercases the type/subtype. Original objects, bytes, cache-control fields, helper tags and file-upload metadata are preserved. No new base types, charset transcoding or parameter-grammar validation are added.

Validation

Existing public-helper tests cover canonical, mixed-case and parameterized values, image/PDF/text resources, exact payloads, first-supported selection, missing-blob and unsupported-type controls, cache control and nonmutation. On unchanged main, 15 fail and 43 pass.

The MCP suite passes 58 tests with both the locked MCP SDK and MCP v2 on Python 3.10.16 and 3.14.7. The Pydantic v1 run skips the optional MCP module. Repository ./scripts/format, complete ./scripts/lint and git diff --check pass.

Tests use mock/local data through ./scripts/test. No live API requests or other operating-system runs. No dependencies, public signatures, release metadata or workflow changes.

Corresponding Go SDK fix: anthropics/anthropic-sdk-go#469

Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

MCP helpers reject or skip supported content with mixed-case or parameterized MIME types

1 participant