Tools

Toolkits

Define model-facing tools and compose them into named toolkits registered with an assistant-ui runtime scope.

A Toolkit is a named map of model-facing tool definitions. The Tools resource installs a toolkit into an assistant subtree, registering each tool with the model context and each render component with the tool-call renderer scope.

Use these APIs when you want a tool's availability to follow your runtime or provider tree rather than the mount state of a specific React component. For tools whose lifetime should follow a specific UI surface, see Component Tools.

API Reference

tool

Defines a model tool with its argument schema, execution behavior, and optional model-output conversion.

This helper keeps reusable tool definitions type-checked and convenient to export for a Toolkit, Tools, or useAssistantTool. Inference from parameter schemas is currently limited, so provide generic arguments when you need precise args or result types.

const getWeather = tool<{ city: string }, string>({
  type: "frontend",
  description: "Get the weather for a city.",
  parameters: {
    type: "object",
    properties: { city: { type: "string" } },
    required: ["city"],
  },
  execute: async ({ city }) => `Sunny in ${city}`,
});
tool
tool : Tool<TArgs, TResult>

streamCalldeprecated ?: ToolStreamCallFunction<TArgs, TResult>

Deprecated: Experimental, API may change.

type ?: "frontend"

Tool that is executed in the frontend runtime.

description ?: string

Natural-language description shown to the model when selecting tools.

parameters ?: StandardSchemaV1<TArgs> | JSONSchema7

Schema for the arguments the model must provide when calling the tool.

disabled ?: boolean

Prevents the tool from being exposed to the model while true.

execute ?: ToolExecuteFunction<TArgs, TResult>

Executes the tool after the model provides valid arguments.

toModelOutput ?: ToolModelOutputFunction<TArgs, TResult>

Converts the execution result into model-visible output.

experimental_onSchemaValidationError ?: OnSchemaValidationErrorFunction<TResult>

Handles invalid tool arguments when schema validation fails.

ToolDefinition

Tool definition accepted by the React tool registry.

Extends the core tool contract with a render component. Human tools rely on the renderer to collect input from the user. Frontend tools execute in the browser and require a UI surface for their progress and result. Backend tools execute server-side and may omit a renderer. The render component is required for frontend and human tools and optional for backend tools.

ToolDefinition
streamCalldeprecated ?: ToolStreamCallFunction<TArgs, TResult>

Deprecated: Experimental, API may change.

type ?: "frontend"

Tool that is executed in the frontend runtime.

description ?: string

Natural-language description shown to the model when selecting tools.

parameters ?: StandardSchemaV1<TArgs> | JSONSchema7

Schema for the arguments the model must provide when calling the tool.

disabled ?: boolean

Prevents the tool from being exposed to the model while true.

execute ?: ToolExecuteFunction<TArgs, TResult>

Executes the tool after the model provides valid arguments.

toModelOutput ?: ToolModelOutputFunction<TArgs, TResult>

Converts the execution result into model-visible output.

experimental_onSchemaValidationError ?: OnSchemaValidationErrorFunction<TResult>

Handles invalid tool arguments when schema validation fails.

render ?: ToolCallMessagePartComponent<TArgs, TResult>

Toolkit

Named collection of tools exposed to the assistant model.

Keys are the tool names the model receives and uses in tool calls.

const toolkit = {
  get_weather: {
    type: "frontend",
    description: "Get the weather for a city.",
    parameters: weatherSchema,
    execute: async ({ city }: { city: string }) => fetchWeather(city),
    render: WeatherToolUI,
  },
} satisfies Toolkit;
type Toolkit = Record<string, ToolDefinition<any, any>>;

Tools

Registers tools with model context and installs tool-call renderers.

Mount this resource near an assistant subtree when you want to expose a group of tools declaratively. Tool definitions are registered with model context, while each tool renderer is registered with the tools scope for message rendering.

Tools props
toolkit ?: Toolkit

Tools to expose to the model and optional renderers to install.

mcpApp ?: ResourceElement<McpAppResourceOutput>

Optional MCP app resource whose tools should be merged into context.

type : Resource<R, P> & { [fnSymbol]: (props: P) => R }

props : P

key ?: string | number