colmugx/mcp/protocol/tool does not have a README file

    ToToolResult

    pub trait ToToolResult {
    fn to_tool_result(Self) -> ToolResult
    }

    Trait for types that can be converted to ToolResult
    impl ToToolResult for Int

    Tool

    pub(open) trait Tool {
    fn name(Self) -> String
    fn description(Self) -> String
    fn params(Self) -> Array[ParamDef]
    async fn execute(Self, Json) -> ToolResult
    }

    Core Tool trait following MCP protocol

    ParamDef

    pub(all) struct ParamDef {
    name : String
    description : String
    type_ : String
    required : Bool
    } derive(Eq,
    Debug
    )

    Parameter definition for tool schema

    ToolResult

    pub struct ToolResult {
    content : Array[
    ContentItem
    ]
    is_error : Bool
    } derive(Eq,
    Debug
    )

    Tool execution result following MCP protocol format

    ToolResult::error

    fn ToolResult::error(message : String) -> ToolResult

    Create an error result with error message

    ToolResult::success

    Create a successful result with multiple content items

    ToolResult::text

    fn ToolResult::text(text : String) -> ToolResult

    Create a successful result with text content

    get_number

    fn get_number(json : Json, key : String) -> Result[Double, ToolResult]

    Extract number from JSON, returning error ToolResult on failure

    get_optional_number

    fn get_optional_number(json : Json, key : String) -> Result[Double?, ToolResult]

    Extract optional number from JSON

    get_optional_string

    fn get_optional_string(json : Json, key : String) -> Result[String?, ToolResult]

    Extract optional string from JSON

    get_string

    fn get_string(json : Json, key : String) -> Result[String, ToolResult]

    Extract string from JSON, returning error ToolResult on failure

    Source Files