pub struct CallToolResult {
pub content: Vec<Content>,
pub is_error: Option<bool>,
pub structured_content: Option<Value>,
pub meta: Option<HashMap<String, Value>>,
}Expand description
Re-exports of the canonical tool types from turbomcp_types.
The result of a CallToolRequest.
Fields§
§content: Vec<Content>The output of the tool as a series of content blocks. Required.
is_error: Option<bool>Whether the tool execution resulted in an error.
When true, all content blocks should be treated as error information;
the message may span multiple text blocks for structured error reporting.
structured_content: Option<Value>Optional structured output conforming to the tool’s output_schema.
Tools that emit structured content SHOULD also include the serialized
JSON in a TextContent block for clients that don’t support structured
output.
meta: Option<HashMap<String, Value>>Optional metadata for the result.
For client applications and tools to pass context that should NOT be exposed to LLMs (tracking IDs, metrics, cache status, etc.).
Implementations§
Source§impl CallToolResult
impl CallToolResult
Sourcepub fn text(text: impl Into<String>) -> CallToolResult
pub fn text(text: impl Into<String>) -> CallToolResult
Create a successful result with a single text content block.
Sourcepub fn error(message: impl Into<String>) -> CallToolResult
pub fn error(message: impl Into<String>) -> CallToolResult
Create an error result with a single text content block and is_error = true.
Sourcepub fn json<T>(value: &T) -> Result<CallToolResult, Error>where
T: Serialize,
pub fn json<T>(value: &T) -> Result<CallToolResult, Error>where
T: Serialize,
Create a successful JSON result (pretty-printed text content).
Sourcepub fn contents(contents: Vec<Content>) -> CallToolResult
pub fn contents(contents: Vec<Content>) -> CallToolResult
Create a result with multiple content items.
Sourcepub fn image(
data: impl Into<String>,
mime_type: impl Into<String>,
) -> CallToolResult
pub fn image( data: impl Into<String>, mime_type: impl Into<String>, ) -> CallToolResult
Create an image result (base64-encoded).
Sourcepub fn all_text(&self) -> String
pub fn all_text(&self) -> String
Extracts and concatenates all text content (newline-joined).
Returns an empty string if no text blocks are present.
Sourcepub fn first_text(&self) -> Option<&str>
pub fn first_text(&self) -> Option<&str>
Returns the text of the first text block, if any.
Trait Implementations§
Source§impl Clone for CallToolResult
impl Clone for CallToolResult
Source§fn clone(&self) -> CallToolResult
fn clone(&self) -> CallToolResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CallToolResult
impl Debug for CallToolResult
Source§impl Default for CallToolResult
impl Default for CallToolResult
Source§fn default() -> CallToolResult
fn default() -> CallToolResult
Source§impl<'de> Deserialize<'de> for CallToolResult
impl<'de> Deserialize<'de> for CallToolResult
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<CallToolResult, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<CallToolResult, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl IntoToolResponse for CallToolResult
impl IntoToolResponse for CallToolResult
Source§fn into_tool_response(self) -> CallToolResult
fn into_tool_response(self) -> CallToolResult
CallToolResult