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. Attach a handler to a Tool via Tool::with_handler, then install the resulting tools on a session via SessionConfig::with_tools. The SDK builds an internal name-keyed registry from the handlers and dispatches to the matching handler when the CLI broadcasts external_tool.requested.

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

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’s runtime implementation.

Functions§

convert_mcp_call_tool_result
Convert an MCP CallToolResult JSON value into a Copilot tool result.
define_tool
Define a Tool from an async function (or closure) that takes a typed, JsonSchema-derived parameter struct.
define_tool_declaration
Define a declaration-only Tool with a JSON Schema derived from P.
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.