ZodTool
Defined in: src/tools/zod-tool.ts:50
Zod-based tool implementation. Extends Tool abstract class and implements InvokableTool interface.
Extends
Section titled “Extends”Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
TInput extends z.ZodType | undefined | - |
TReturn extends JSONValue | JSONValue |
Implements
Section titled “Implements”InvokableTool<ZodInferred<TInput>,TReturn>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ZodTool<TInput, TReturn>(config): ZodTool<TInput, TReturn>;Defined in: src/tools/zod-tool.ts:73
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
config | ZodToolConfig<TInput, TReturn> |
Returns
Section titled “Returns”ZodTool<TInput, TReturn>
Overrides
Section titled “Overrides”Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get name(): string;Defined in: src/tools/zod-tool.ts:117
The unique name of the tool.
Returns
Section titled “Returns”string
The unique name of the tool. This MUST match the name in the toolSpec.
Implementation of
Section titled “Implementation of”Overrides
Section titled “Overrides”description
Section titled “description”Get Signature
Section titled “Get Signature”get description(): string;Defined in: src/tools/zod-tool.ts:124
Human-readable description of what the tool does.
Returns
Section titled “Returns”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.
Implementation of
Section titled “Implementation of”Overrides
Section titled “Overrides”toolSpec
Section titled “toolSpec”Get Signature
Section titled “Get Signature”get toolSpec(): ToolSpec;Defined in: src/tools/zod-tool.ts:131
OpenAPI JSON specification for the tool.
Returns
Section titled “Returns”OpenAPI JSON specification for the tool. Defines the tool’s name, description, and input schema.
Implementation of
Section titled “Implementation of”Overrides
Section titled “Overrides”Methods
Section titled “Methods”stream()
Section titled “stream()”stream(toolContext): ToolStreamGenerator;Defined in: src/tools/zod-tool.ts:142
Executes the tool with streaming support. Delegates to internal FunctionTool implementation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
toolContext | ToolContext | Context information including the tool use request and invocation state |
Returns
Section titled “Returns”Async generator that yields ToolStreamEvents and returns a ToolResultBlock
Implementation of
Section titled “Implementation of”Overrides
Section titled “Overrides”invoke()
Section titled “invoke()”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)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
input | ZodInferred<TInput> | The input parameters for the tool |
context? | ToolContext | Optional tool execution context |
Returns
Section titled “Returns”Promise<TReturn>
The unwrapped result