pub struct CallToolResult {
    pub content: Vec<CallToolResultContentItem>,
    pub is_error: Option<bool>,
    pub meta: Option<Map<String, Value>>,
}Expand description
The server’s response to a tool call. Any errors that originate from the tool SHOULD be reported inside the result object, with isError set to true, not as an MCP protocol-level error response. Otherwise, the LLM would not be able to see that an error occurred and self-correct. However, any errors in finding the tool, an error indicating that the server does not support tool calls, or any other exceptional conditions, should be reported as an MCP error response.
JSON schema
{
 "description": "The server's response to a tool call.\n\nAny errors that originate from the tool SHOULD be reported inside the result\nobject, with isError set to true, _not_ as an MCP protocol-level error\nresponse. Otherwise, the LLM would not be able to see that an error occurred\nand self-correct.\n\nHowever, any errors in _finding_ the tool, an error indicating that the\nserver does not support tool calls, or any other exceptional conditions,\nshould be reported as an MCP error response.",
 "type": "object",
 "required": [
   "content"
 ],
 "properties": {
   "_meta": {
     "description": "This result property is reserved by the protocol to allow clients and servers to attach additional metadata to their responses.",
     "type": "object",
     "additionalProperties": {}
   },
   "content": {
     "type": "array",
     "items": {
       "anyOf": [
         {
           "$ref": "#/definitions/TextContent"
         },
         {
           "$ref": "#/definitions/ImageContent"
         },
         {
           "$ref": "#/definitions/EmbeddedResource"
         }
       ]
     }
   },
   "isError": {
     "description": "Whether the tool call ended in an error.\n\nIf not set, this is assumed to be false (the call was successful).",
     "type": "boolean"
   }
 }
}Fields§
§content: Vec<CallToolResultContentItem>§is_error: Option<bool>Whether the tool call ended in an error. If not set, this is assumed to be false (the call was successful).
meta: Option<Map<String, Value>>This result property is reserved by the protocol to allow clients and servers to attach additional metadata to their responses.
Implementations§
Source§impl CallToolResult
 
impl CallToolResult
pub fn text_content( text: String, annotations: Option<TextContentAnnotations>, ) -> Self
pub fn image_content( data: String, mime_type: String, annotations: Option<ImageContentAnnotations>, ) -> Self
pub fn embedded_resource( resource: EmbeddedResourceResource, annotations: Option<EmbeddedResourceAnnotations>, ) -> Self
Sourcepub fn with_error(error: CallToolError) -> Self
 
pub fn with_error(error: CallToolError) -> Self
Create a CallToolResult with an error, containing an error message in the content
Trait Implementations§
Source§impl Clone for CallToolResult
 
impl Clone for CallToolResult
Source§fn clone(&self) -> CallToolResult
 
fn clone(&self) -> CallToolResult
1.0.0 · 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<'de> Deserialize<'de> for CallToolResult
 
impl<'de> Deserialize<'de> for CallToolResult
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
    __D: Deserializer<'de>,
 
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
    __D: Deserializer<'de>,
Source§impl From<CallToolError> for CallToolResult
Conversion of CallToolError into a CallToolResult with an error.
 
impl From<CallToolError> for CallToolResult
Conversion of CallToolError into a CallToolResult with an error.