pub enum ContentBlock {
Text(TextContent),
Image(ImageContent),
Audio(AudioContent),
ResourceLink(ResourceLink),
Resource(EmbeddedResource),
}
Expand description
Content blocks represent displayable information in the Agent Client Protocol.
They provide a structured way to handle various types of user-facing content—whether it’s text from language models, images for analysis, or embedded resources for context.
Content blocks appear in:
- User prompts sent via
session/prompt
- Language model output streamed through
session/update
notifications - Progress updates and results from tool calls
This structure is compatible with the Model Context Protocol (MCP), enabling agents to seamlessly forward content from MCP tool outputs without transformation.
See protocol docs: Content
Variants§
Text(TextContent)
Plain text content
All agents MUST support text content blocks in prompts.
Image(ImageContent)
Images for visual context or analysis.
Requires the image
prompt capability when included in prompts.
Audio(AudioContent)
Audio data for transcription or analysis.
Requires the audio
prompt capability when included in prompts.
ResourceLink(ResourceLink)
References to resources that the agent can access.
All agents MUST support resource links in prompts.
Resource(EmbeddedResource)
Complete resource contents embedded directly in the message.
Preferred for including context as it avoids extra round-trips.
Requires the embeddedContext
prompt capability when included in prompts.
Trait Implementations§
Source§impl Clone for ContentBlock
impl Clone for ContentBlock
Source§fn clone(&self) -> ContentBlock
fn clone(&self) -> ContentBlock
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ContentBlock
impl Debug for ContentBlock
Source§impl<'de> Deserialize<'de> for ContentBlock
impl<'de> Deserialize<'de> for ContentBlock
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for ContentBlock
impl JsonSchema for ContentBlock
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref
keyword. Read more