pub enum ContentBlock {
Text {
text: String,
annotations: Option<Annotations>,
meta: Option<HashMap<String, Value>>,
},
Image {
data: String,
mime_type: String,
annotations: Option<Annotations>,
meta: Option<HashMap<String, Value>>,
},
Audio {
data: String,
mime_type: String,
annotations: Option<Annotations>,
meta: Option<HashMap<String, Value>>,
},
ResourceLink {
resource: ResourceReference,
},
Resource {
resource: ResourceContents,
annotations: Option<Annotations>,
meta: Option<HashMap<String, Value>>,
},
ToolUse {
id: String,
name: String,
input: HashMap<String, Value>,
meta: Option<HashMap<String, Value>>,
},
ToolResult {
tool_use_id: String,
content: Vec<ContentBlock>,
structured_content: Option<Value>,
is_error: Option<bool>,
meta: Option<HashMap<String, Value>>,
},
}Expand description
Content block union — text | image | audio | resource_link | resource | tool_use | tool_result.
Variants§
Text
Text content
Image
Image content
Fields
annotations: Option<Annotations>Audio
Audio content
Fields
annotations: Option<Annotations>ResourceLink
Resource link (ResourceLink from MCP spec).
Schema: ResourceLink extends Resource — exactly ONE annotations?
and ONE _meta?, both inherited from Resource. The flattened
ResourceReference is the single source of truth for both — do NOT
add variant-level annotations/meta fields alongside it, which
would emit the same key twice on the wire.
Fields
resource: ResourceReferenceResource
Embedded resource (EmbeddedResource from MCP spec)
ToolUse
Deprecated per SEP-2577 (2026-07-28) with the Sampling surface. Earliest removal: first release on/after 2027-07-28.
Tool use content block.
Fields
id: StringDeprecated per SEP-2577 (2026-07-28) with the Sampling surface. Earliest removal: first release on/after 2027-07-28.
Unique identifier for this tool use
name: StringDeprecated per SEP-2577 (2026-07-28) with the Sampling surface. Earliest removal: first release on/after 2027-07-28.
Name of the tool being called
ToolResult
Deprecated per SEP-2577 (2026-07-28) with the Sampling surface. Earliest removal: first release on/after 2027-07-28.
Tool result content block.
Fields
tool_use_id: StringDeprecated per SEP-2577 (2026-07-28) with the Sampling surface. Earliest removal: first release on/after 2027-07-28.
ID of the tool use this result corresponds to
content: Vec<ContentBlock>Deprecated per SEP-2577 (2026-07-28) with the Sampling surface. Earliest removal: first release on/after 2027-07-28.
Content returned by the tool
structured_content: Option<Value>Deprecated per SEP-2577 (2026-07-28) with the Sampling surface. Earliest removal: first release on/after 2027-07-28.
Structured content matching the tool’s output schema
Implementations§
Source§impl ContentBlock
impl ContentBlock
Sourcepub fn text(text: impl Into<String>) -> ContentBlock
pub fn text(text: impl Into<String>) -> ContentBlock
Create text content
Sourcepub fn text_with_annotations(
text: impl Into<String>,
annotations: Annotations,
) -> ContentBlock
pub fn text_with_annotations( text: impl Into<String>, annotations: Annotations, ) -> ContentBlock
Create text content with annotations
Sourcepub fn image(
data: impl Into<String>,
mime_type: impl Into<String>,
) -> ContentBlock
pub fn image( data: impl Into<String>, mime_type: impl Into<String>, ) -> ContentBlock
Create image content
Sourcepub fn audio(
data: impl Into<String>,
mime_type: impl Into<String>,
) -> ContentBlock
pub fn audio( data: impl Into<String>, mime_type: impl Into<String>, ) -> ContentBlock
Create audio content
Sourcepub fn resource_link(resource: ResourceReference) -> ContentBlock
pub fn resource_link(resource: ResourceReference) -> ContentBlock
Create resource link
Sourcepub fn resource(resource: ResourceContents) -> ContentBlock
pub fn resource(resource: ResourceContents) -> ContentBlock
Create embedded resource
Sourcepub fn tool_use(
id: impl Into<String>,
name: impl Into<String>,
input: HashMap<String, Value>,
) -> ContentBlock
👎Deprecated since 0.4.0: Deprecated per SEP-2577 (2026-07-28) with the Sampling surface.
pub fn tool_use( id: impl Into<String>, name: impl Into<String>, input: HashMap<String, Value>, ) -> ContentBlock
Deprecated per SEP-2577 (2026-07-28) with the Sampling surface.
Create tool use content block
Sourcepub fn tool_result(
tool_use_id: impl Into<String>,
content: Vec<ContentBlock>,
) -> ContentBlock
👎Deprecated since 0.4.0: Deprecated per SEP-2577 (2026-07-28) with the Sampling surface.
pub fn tool_result( tool_use_id: impl Into<String>, content: Vec<ContentBlock>, ) -> ContentBlock
Deprecated per SEP-2577 (2026-07-28) with the Sampling surface.
Create tool result content block
Sourcepub fn tool_result_error(
tool_use_id: impl Into<String>,
content: Vec<ContentBlock>,
) -> ContentBlock
👎Deprecated since 0.4.0: Deprecated per SEP-2577 (2026-07-28) with the Sampling surface.
pub fn tool_result_error( tool_use_id: impl Into<String>, content: Vec<ContentBlock>, ) -> ContentBlock
Deprecated per SEP-2577 (2026-07-28) with the Sampling surface.
Create tool result error content block
Sourcepub fn with_annotations(self, annotations: Annotations) -> ContentBlock
pub fn with_annotations(self, annotations: Annotations) -> ContentBlock
Add annotations to any content block that supports them. ToolUse and ToolResult do not have annotations per spec — this is a no-op for those variants.
Trait Implementations§
Source§impl Clone for ContentBlock
impl Clone for ContentBlock
Source§fn clone(&self) -> ContentBlock
fn clone(&self) -> ContentBlock
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more