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 moreAuto Trait Implementations§
impl Freeze for McpContent
impl RefUnwindSafe for McpContent
impl Send for McpContent
impl Sync for McpContent
impl Unpin for McpContent
impl UnsafeUnpin for McpContent
impl UnwindSafe for McpContent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
map-response-body only.Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
trace only.Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
trace only.