#[non_exhaustive]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/updatenotifications - 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 (Non-exhaustive)§
This enum is marked as non-exhaustive
Text(TextContent)
Text content. May be plain text or formatted with Markdown.
All agents MUST support text content blocks in prompts. Clients SHOULD render this text as Markdown.
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§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<ContentBlock, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ContentBlock, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl<T> From<T> for ContentBlock
impl<T> From<T> for ContentBlock
Source§fn from(value: T) -> ContentBlock
fn from(value: T) -> ContentBlock
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 moreSource§impl PartialEq for ContentBlock
impl PartialEq for ContentBlock
Source§impl Serialize for ContentBlock
impl Serialize for ContentBlock
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for ContentBlock
Auto Trait Implementations§
impl Freeze for ContentBlock
impl RefUnwindSafe for ContentBlock
impl Send for ContentBlock
impl Sync for ContentBlock
impl Unpin for ContentBlock
impl UnwindSafe for ContentBlock
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)