fix(rmcp): add Audio variant to PromptMessageContent#865
Open
bricef wants to merge 1 commit into
Open
Conversation
The spec's prompt-message ContentBlock union is
`text | image | audio | resource_link | resource`, but
PromptMessageContent omitted `Audio`. Because the enum is
`#[serde(tag = "type")]` with no catch-all, a spec-conformant
`{"type":"audio",...}` content block failed to deserialize with
"unknown variant `audio`", breaking prompts/get for any server that
returns audio prompt content (the audio analogue of modelcontextprotocol#842 / modelcontextprotocol#843).
The supporting AudioContent type already existed, and Audio was
already a variant of the general RawContent enum (tool results,
sampling) -- only PromptMessageContent lacked it.
Add the flattened Audio variant (mirroring Image), a
PromptMessage::new_audio constructor (mirroring new_image), and
serialization + deserialization regression tests.
Fixes modelcontextprotocol#864.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the missing
Audiovariant toPromptMessageContent, bringing it in line with the MCP spec's prompt-messageContentBlockunion (text | image | audio | resource_link | resource).Why
PromptMessageContenthad noAudiovariant, and since it is#[serde(tag = "type")]with no catch-all, a spec-conformant{"type":"audio",...}content block fails to deserialize:This breaks
prompts/getend-to-end for any server that returns audio prompt content. It is the audio analogue of #842 / #843 (the embedded-resource variant). The supportingAudioContenttype already exists, andAudiois already a variant of the generalRawContentenum (tool results, sampling) — onlyPromptMessageContentomitted it.Fixes #864.
Changes
Audio { #[serde(flatten)] audio: AudioContent }variant (mirrorsImage).PromptMessage::new_audioconstructor (mirrorsnew_image).mimeType) + deserialization regression tests, in the style of fix(rmcp): flatten Resource variant of PromptMessageContent #843'stest_prompt_message_resource_serialization_is_flat.ServerJsonRpcMessageschema snapshot (UPDATE_SCHEMA=1) to include the new audio content block.Verification
just check(clippy,--all-features --all-targets -- -D warnings): clean.just test(cargo test --all-features): passing, including the regenerated schema snapshot and the two new prompt tests. (tests/test_with_python.rsrequires an external Python MCP server unavailable in my environment; unrelated to this change.)cargo +nightly fmt --check: clean.