Skip to main content

Tool

Derive Macro Tool 

Source
#[derive(Tool)]
{
    // Attributes available to this derive:
    #[tool]
}
Expand description

Derive loopctl::tool::Tool for a struct.

Generates all four required methods from the struct’s shape: the name (container override or the snake_cased identifier), the description (container override or the struct’s doc comment — one of the two is required), the JSON Schema built statically from the fields, and a call that deserializes the incoming Value and dispatches to a handler. The struct must implement serde::Deserialize (add #[derive(serde::Deserialize)] alongside) and provide an inherent async fn run(&self, input: Self, ctx: &ToolContext) returning Result<ToolOutput, ToolError>; rename the handler with #[tool(handler = "…")]. Tools with dynamic schemas or unmappable field types fall back to a manual impl.