DS DevShelfHub Projects · AI tools
Tutorials / MCP / Reference / Interfaces / AudioContent
Interface content-blocks modelcontextprotocol/types

AudioContent

By DevShelfHub

Audio content block, added in spec 2025-11-25.

What is AudioContent?

AudioContent is a discriminated-union content block that carries raw audio as a base64-encoded string alongside a MIME type. It sits in the same family as TextContent and ImageContent — all three share the same structural pattern of a literal `type` discriminator, a payload field, and an optional `annotations` object. AudioContent specifically uses `"type": "audio"` as its discriminator, making it unambiguous when a host deserializes a heterogeneous ContentBlock array.\n\nIn the MCP message flow, AudioContent can appear wherever a ContentBlock is accepted: inside a `CallToolResult`'s `content` array (tool results), inside a `PromptMessage`'s `content` field (prompt templates), and as the `content` of a `CreateMessageResult` returned by a sampling-capable host. This broad placement means a TTS server can return spoken audio directly from a tool call, and a sampling host can return audio as part of an assistant turn — no special audio-specific API surface is needed.\n\nAudioContent was added in the 2025-11-25 revision of the MCP specification, the same revision that introduced Tasks and refined several lifecycle primitives. Before that version, audio had no first-class representation in the protocol. Because `mimeType` is a free-form string, the spec does not enumerate valid values — in practice `audio/mpeg`, `audio/wav`, `audio/ogg`, and `audio/webm` are the most interoperable choices. Hosts that do not recognise a given MIME type are expected to ignore or pass through the block rather than error.

When to use

Tools that produce audio (TTS, transcription playback).

When NOT to use

Long recordings — use ResourceLink instead.

Notes

Base64 payload size constraints

Base64 encoding inflates binary size by roughly 33 %. For audio files this can push a single content block into the hundreds of kilobytes for even a short clip. JSON parsers in some SDK environments impose message-size limits, so keep inline AudioContent payloads to short utterances (a few seconds). For anything longer, return a ResourceLink pointing at a hosted URL instead of embedding the bytes directly.

MIME type is not validated by the spec

The specification treats `mimeType` as an opaque string. A server can send `audio/flac` or a vendor type, and a conformant host must not reject the block on that basis alone. In practice, whether the client can actually play the audio depends entirely on the host application's media stack. Stick to `audio/mpeg` or `audio/wav` for maximum compatibility across Claude Desktop, web clients, and third-party hosts.

Version compatibility with pre-2025-11-25 servers

AudioContent did not exist before the 2025-11-25 protocol revision. If your server negotiates an older `protocolVersion` during initialization, sending an `audio` block will likely cause the client to drop or error on the unknown type. Always check the negotiated version in `InitializeResult` before emitting AudioContent, or document the minimum required version in your server's capability metadata.

Annotations carry display hints, not playback config

The optional `annotations` field on AudioContent follows the same Annotations schema as all other content blocks — it carries `audience`, `priority`, and `lastModified`. These are rendering hints, not audio-playback directives: there is no duration, volume, or autoplay field in the spec. If a host needs playback metadata, embed it in a companion TextContent block or in custom `_meta` fields on the enclosing message.

Discriminator must be the string literal 'audio'

When constructing AudioContent manually, the `type` field must be exactly the string `"audio"` — not `"AudioContent"`, not `"AUDIO"`. Hosts use strict string matching on the discriminator to decide which branch of the union to parse. Sending a wrong or missing `type` will cause most SDK deserializers to fall through to an unknown-type handler and silently discard the block, which can be difficult to debug because no error is raised.

Fields

Field Type Required Purpose
type 'audio' yes Discriminator.
data string yes Base64-encoded audio bytes.
mimeType string yes audio/mpeg, audio/wav, etc.
annotations Annotations? no Optional annotations.

Examples

Audio block

json
{ "type": "audio", "data": "SUQzBA...", "mimeType": "audio/mpeg" }

Common mistakes

❌ Sending raw bytes

✅ Always base64-encode before placing in data.

Related

AudioContent FAQ

What is AudioContent in the MCP protocol?

AudioContent is an MCP interface type that defines the structure of protocol data exchanged between MCP clients and servers. It is part of the Model Context Protocol's JSON-RPC 2.0 message schema.

Which package provides the AudioContent type?

AudioContent is defined in the modelcontextprotocol/types package of the MCP TypeScript SDK. Equivalent types are available in the Python, Kotlin, Go, Ruby, and C# SDK implementations.

When should I use AudioContent in my MCP implementation?

Use AudioContent when your MCP host, client, or server implementation needs to work with this protocol structure. Refer to the When to use section above and the MCP specification for authoritative guidance.

What fields does AudioContent contain?

See the Fields table on this page for a complete list of fields in AudioContent, their types, whether they are required or optional, and their purpose.

Where can I find more MCP interface documentation?

The complete MCP API reference on DevShelfHub documents all MCP interfaces, methods, and notifications. Visit the MCP API Reference index to browse all types.