Overview
oncalltool is a request handler that receives tool calls from the host directed at your app. This enables bidirectional tool communication — in addition to calling server tools, the host (or model) can call tools that the View implements.
To use oncalltool, you must declare the tools capability when constructing the App. The host discovers available tools through onlisttools, then calls them through this handler.
Because this is a request handler, the host waits for your response. Return a result object containing content blocks, or throw an error to signal failure.
Signature
Parameters
The tool call parameters sent by the host.
Name of the tool being called. Must match one of the tools declared in
onlisttools.Tool arguments as key-value pairs. The shape corresponds to the tool’s
inputSchema.Usage
Declare tools capability and handle calls
Handle multiple tools with structured results
Return errors without throwing
For expected failures, return an error result instead of throwing:Related
- Event Handlers overview — all notification and request handlers
onlisttools— declare the tools your app providesuseAppTools— sunpeak React convenience hook for app-side tools- App Class constructor — declaring
toolscapability