Skip to content

ZodTool

Defined in: src/tools/zod-tool.ts:50

Zod-based tool implementation. Extends Tool abstract class and implements InvokableTool interface.

| Type Parameter | Default type | | ------------------------------------------------ | ---------------------------- | | TInput extends z.ZodType | undefined | - | | TReturn extends JSONValue | JSONValue |

new ZodTool<TInput, TReturn>(config): ZodTool<TInput, TReturn>;

Defined in: src/tools/zod-tool.ts:73

| Parameter | Type | | --------- | ---------------------------------------------------------- | | config | ZodToolConfig<TInput, TReturn> |

ZodTool<TInput, TReturn>

Tool.constructor

get name(): string;

Defined in: src/tools/zod-tool.ts:117

The unique name of the tool.

string

The unique name of the tool. This MUST match the name in the toolSpec.

InvokableTool.name

Tool.name


get description(): string;

Defined in: src/tools/zod-tool.ts:124

Human-readable description of what the tool does.

string

Human-readable description of what the tool does. This helps the model understand when to use the tool.

This MUST match the description in the toolSpec.description.

InvokableTool.description

Tool.description


get toolSpec(): ToolSpec;

Defined in: src/tools/zod-tool.ts:131

OpenAPI JSON specification for the tool.

ToolSpec

OpenAPI JSON specification for the tool. Defines the tool’s name, description, and input schema.

InvokableTool.toolSpec

Tool.toolSpec

stream(toolContext): ToolStreamGenerator;

Defined in: src/tools/zod-tool.ts:142

Executes the tool with streaming support. Delegates to internal FunctionTool implementation.

| Parameter | Type | Description | | ------------- | -------------------------------- | ----------------------------------------------------------------------- | | toolContext | ToolContext | Context information including the tool use request and invocation state |

ToolStreamGenerator

Async generator that yields ToolStreamEvents and returns a ToolResultBlock

InvokableTool.stream

Tool.stream


invoke(input, context?): Promise<TReturn>;

Defined in: src/tools/zod-tool.ts:158

Invokes the tool directly with type-safe input and returns the unwrapped result.

Unlike stream(), this method:

  • Returns the raw result (not wrapped in ToolResult)
  • Consumes async generators and returns only the final value
  • Lets errors throw naturally (not wrapped in error ToolResult)

| Parameter | Type | Description | | ---------- | -------------------------------- | --------------------------------- | | input | ZodInferred<TInput> | The input parameters for the tool | | context? | ToolContext | Optional tool execution context |

Promise<TReturn>

The unwrapped result

InvokableTool.invoke