pub struct Tool {
pub name: String,
pub description: String,
pub input_schema: Value,
pub source: ToolSource,
pub execute: ExecuteFn,
pub hints: Option<ToolHints>,
pub concurrency_safe: Option<ConcurrencySafeFn>,
pub output_schema: Option<Value>,
pub annotations: Option<ToolAnnotations>,
}Expand description
A named, described, schema’d callable (SPEC §1).
Fields§
§name: String§description: String§input_schema: ValueJSON-Schema object for the arguments.
source: ToolSource§execute: ExecuteFn§hints: Option<ToolHints>Advisory hints (read-only / destructive / open-world); None = unknown.
concurrency_safe: Option<ConcurrencySafeFn>Decides per call whether this tool may run alongside other safe calls of the
same model response (SPEC §8 “Tool scheduling”). None ⇒ safe only when
hints.read_only. See is_concurrency_safe.
output_schema: Option<Value>JSON Schema of ToolResult::structured (§1). MCP serve advertises it
as outputSchema; None ⇒ omitted.
annotations: Option<ToolAnnotations>MCP annotations, passed through verbatim by the MCP handler (else
derived from hints, else omitted). Never sent to the model.
Implementations§
Source§impl Tool
impl Tool
Sourcepub fn with_output_schema(self, schema: Value) -> Self
pub fn with_output_schema(self, schema: Value) -> Self
This tool with an output schema (§1).
Sourcepub fn with_annotations(self, annotations: ToolAnnotations) -> Self
pub fn with_annotations(self, annotations: ToolAnnotations) -> Self
This tool with MCP annotations (§7C.1).
Source§impl Tool
impl Tool
Sourcepub async fn call(&self, args: Value, ctx: ToolContext) -> ToolResult
pub async fn call(&self, args: Value, ctx: ToolContext) -> ToolResult
Run the tool. A missing/null args value is passed as {}.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Tool
impl !UnwindSafe for Tool
impl Freeze for Tool
impl Send for Tool
impl Sync for Tool
impl Unpin for Tool
impl UnsafeUnpin for Tool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more