pub enum Content {
Text {
text: String,
annotations: Option<ContentAnnotations>,
},
Image {
data: String,
mime_type: String,
annotations: Option<ContentAnnotations>,
},
Audio {
data: String,
mime_type: String,
annotations: Option<ContentAnnotations>,
},
Resource {
resource: ResourceContent,
annotations: Option<ContentAnnotations>,
},
ResourceLink {
uri: String,
name: Option<String>,
description: Option<String>,
mime_type: Option<String>,
annotations: Option<ContentAnnotations>,
},
}Expand description
Content types for tool results, resources, and prompts.
Content can be text, images, audio, or embedded resources. Each variant supports optional annotations for audience targeting and priority hints.
Variants§
Text
Plain text content.
Fields
annotations: Option<ContentAnnotations>Optional annotations for this content.
Image
Base64-encoded image content.
Fields
annotations: Option<ContentAnnotations>Optional annotations for this content.
Audio
Base64-encoded audio content.
Fields
annotations: Option<ContentAnnotations>Optional annotations for this content.
Resource
Embedded resource content.
Fields
resource: ResourceContentThe embedded resource.
annotations: Option<ContentAnnotations>Optional annotations for this content.
ResourceLink
Link to a resource (without embedding the content)
Implementations§
Source§impl Content
impl Content
Sourcepub fn text(text: impl Into<String>) -> Self
pub fn text(text: impl Into<String>) -> Self
Extract the text from a Content::Text variant.
Returns None for non-text content variants.
§Example
use tower_mcp::Content;
let content = Content::Text { text: "hello".into(), annotations: None };
assert_eq!(content.as_text(), Some("hello"));Create a Content::Text variant with no annotations.
This is a shorthand for the common case of creating text content without annotations.
§Example
use tower_mcp::Content;
let content = Content::text("hello world");
assert_eq!(content.as_text(), Some("hello world"));