Skip to main content

ToolResult

Type Alias ToolResult 

Source
pub type ToolResult<T> = Result<T, String>;
Expand description

Result type for MCP tool implementations.

Converts automatically to CallToolResult for macro-generated code.

§Example

#[mcp_tool(description = "Read a value")]
fn read(&self, key: String) -> ToolResult<Value> {
    self.store.get(&key).ok_or_else(|| format!("Key not found: {}", key))
}

Aliased Type§

pub enum ToolResult<T> {
    Ok(T),
    Err(String),
}

Variants§

§1.0.0

Ok(T)

Contains the success value

§1.0.0

Err(String)

Contains the error value

Trait Implementations§

Source§

impl<T: Serialize> IntoCallToolResult for ToolResult<T>

Source§

fn into_call_result(self) -> CallToolResult

Convert to a CallToolResult.