Skip to main content

define_tool

Function define_tool 

Source
pub fn define_tool(
    name: &str,
    description: &str,
    parameters_schema: Option<Value>,
) -> Tool
Expand description

Define a tool with metadata for registration on a session.

Returns a Tool struct with name, description, and parameters schema. The handler must be registered separately on the session via session.register_tool_with_handler().

§Example

use copilot_sdk::tools::define_tool;
use serde_json::json;

let tool = define_tool(
    "my_tool",
    "A description of my tool",
    Some(json!({"type": "object", "properties": {"query": {"type": "string"}}})),
);
// Register on session: session.register_tool_with_handler(tool, Some(handler)).await;