pub struct McpContent {
pub kind: &'static str,
pub text: String,
pub mime_type: Option<String>,
pub uri: Option<String>,
}Expand description
Content returned by tool and resource handlers.
Create with McpContent::text (plain text or JSON strings),
McpContent::json (marks MIME type as application/json),
McpContent::image (base64-encoded binary image data), or
McpContent::embedded (a resource embedded inline in a tool response).
Fields§
§kind: &'static str"text", "image", "audio", "resource", "blob", "blocks"
or "structured".
text: StringThe content string — text for "text", base64 data for "image",
or the embedded resource’s text for "resource".
mime_type: Option<String>Optional MIME type override (default "text/plain" for "text";
required in practice for "image"/"resource", set by their
constructors).
uri: Option<String>The resource URI — only set (and only serialized) for "resource".
Implementations§
Source§impl McpContent
impl McpContent
Sourcepub fn text(s: impl Into<String>) -> McpContent
pub fn text(s: impl Into<String>) -> McpContent
Plain-text content.
Sourcepub fn json(s: impl Into<String>) -> McpContent
pub fn json(s: impl Into<String>) -> McpContent
JSON content — sets mimeType to application/json.
Sourcepub fn structured(json: impl Into<String>) -> McpContent
pub fn structured(json: impl Into<String>) -> McpContent
Structured content (MCP 2025-06-18): json is a JSON value — usually an
object matching the tool’s McpServer::tool_output_schema — sent as
the result’s structuredContent, and as text for older clients.
Sourcepub fn audio(
data: impl Into<String>,
mime_type: impl Into<String>,
) -> McpContent
pub fn audio( data: impl Into<String>, mime_type: impl Into<String>, ) -> McpContent
Audio content — data is base64-encoded audio and mime_type e.g.
"audio/wav" (MCP 2025-03-26).
Sourcepub fn blob(data: impl Into<String>, mime_type: impl Into<String>) -> McpContent
pub fn blob(data: impl Into<String>, mime_type: impl Into<String>) -> McpContent
A binary resource for resources/read — data is base64-encoded and
sent as the contents’ blob (with mime_type) instead of text.
Sourcepub fn blocks(items: impl IntoIterator<Item = McpContent>) -> McpContent
pub fn blocks(items: impl IntoIterator<Item = McpContent>) -> McpContent
Several content items in one tool result — e.g. a text summary, an image and an embedded resource. Each item renders as it would alone.
Sourcepub fn input_required(input: InputRequired) -> McpContent
pub fn input_required(input: InputRequired) -> McpContent
The tool needs input from the client before it can finish (MCP
2026-07-28 multi round-trip requests): the client answers
input’s requests and calls the tool again, with the answers in
McpContext::input_response and the state in
McpContext::request_state. A client on an earlier protocol
version gets a tool error instead.
Trait Implementations§
Source§impl Clone for McpContent
impl Clone for McpContent
Source§fn clone(&self) -> McpContent
fn clone(&self) -> McpContent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more