Skip to main content

Module tool

Module tool 

Source
Expand description

Typed tool definition framework and dispatch router. Typed tool definition framework.

Provides the ToolHandler trait for implementing tools as named types, and ToolHandlerRouter for automatic dispatch of tool calls within a SessionHandler.

Enable the derive feature for schema_for, which generates JSON Schema from Rust types via schemars.

Structs§

ToolHandlerRouter
A SessionHandler that dispatches tool calls to registered ToolHandler implementations by name.

Traits§

JsonSchema
Re-export of schemars::JsonSchema for deriving tool parameter schemas. A type which can be described as a JSON Schema document.
ToolHandler
A client-defined tool with its handler logic.

Functions§

define_tool
Define a tool from an async function (or closure) that takes a typed, JsonSchema-derived parameter struct.
schema_for
Generate a JSON Schema Value from a Rust type.
tool_parameters
Convert a JSON Schema Value into the Tool::parameters map shape expected by the protocol.
try_tool_parameters
Fallible variant of tool_parameters for callers handling dynamic schema input.

Derive Macros§

JsonSchema
Re-export of schemars::JsonSchema for deriving tool parameter schemas. Derive macro for JsonSchema trait.