fix(rmcp): add Audio variant to PromptMessageContent (#865)

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 #842 / #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 #864.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Brice Fernandes 2026-06-23 21:35:40 +01:00 • committed by GitHub
commit 0a95c3b608
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 141 additions and 1 deletions

View file

@ -2115,6 +2115,37 @@
"mimeType"
]
},
{
"description": "Audio content with base64-encoded data",
"type": "object",
"properties": {
"annotations": {
"anyOf": [
{
"$ref": "#/definitions/Annotations"
},
{
"type": "null"
}
]
},
"data": {
"type": "string"
},
"mimeType": {
"type": "string"
},
"type": {
"type": "string",
"const": "audio"
}
},
"required": [
"type",
"data",
"mimeType"
]
},
{
"description": "Embedded server-side resource",
"type": "object",

View file

@ -2115,6 +2115,37 @@
"mimeType"
]
},
{
"description": "Audio content with base64-encoded data",
"type": "object",
"properties": {
"annotations": {
"anyOf": [
{
"$ref": "#/definitions/Annotations"
},
{
"type": "null"
}
]
},
"data": {
"type": "string"
},
"mimeType": {
"type": "string"
},
"type": {
"type": "string",
"const": "audio"
}
},
"required": [
"type",
"data",
"mimeType"
]
},
{
"description": "Embedded server-side resource",
"type": "object",