Skip to content

Tool

Internal representation of a registered tool. Created by tools.function() from a ToolDef.

description: string

Description the LLM uses to decide when to call this tool.


execute: (args, ctx) => Promise<unknown>

Execution function. Receives validated args and a context reference.

Record<string, unknown>

unknown

Promise<unknown>


jsonSchema: Record<string, unknown>

JSON Schema representation sent to the LLM.


name: string

Tool name sent to the LLM.


optional requireApproval?: boolean | ((args) => boolean | Promise<boolean>)

Whether this tool requires human approval before execution. Set by tools.function() or tools.mcp().


optional schema?: ZodType<any, ZodTypeDef, any>

Zod schema for runtime input validation. Optional for MCP tools (which use jsonSchema directly).


optional timeout?: number

Maximum execution time in ms. Default: 30000.