Skip to main content
sunpeak API

Overview

Returns a function to register tools that the host (or LLM) can call. Uses Standard Schema (Zod, ArkType, Valibot) for input/output validation. The returned handle supports enable(), disable(), remove(), and update(). For simpler static tool registration, see useAppTools. useRegisterTool provides lower-level control with dynamic registration and Standard Schema support. The underlying MCP Apps registry sends notifications/tools/list_changed automatically when you register, update, enable, disable, or remove a tool and the View declared tools.listChanged.

Import

Signature

RegisterToolConfig

string
Human-readable title for the tool.
string
Description of what the tool does.
StandardSchemaV1
Input validation schema (Zod, ArkType, Valibot, etc.).
StandardSchemaV1
Output validation schema.
ToolAnnotations
Tool annotations (readOnly, destructive, idempotent hints).

Returns

(name, config, cb) => RegisteredAppTool | undefined
Function to register a tool. Returns undefined if app is not connected.

RegisteredAppTool

() => void
Enable the tool.
() => void
Disable the tool.
() => void
Remove the tool registration.
(updates) => void
Update the tool configuration.

Usage

Do not call useSendToolListChanged() after these registry operations. Use that lower-level hook only when you manage a custom onlisttools result.