Overview
Theontoolresult notification handler is called when the host sends the result of a tool execution. The result includes text content for model context, optional structured data optimized for UI rendering, and an error flag.
Like all notification handlers, ontoolresult should be registered before calling connect().
Signature
Parameters
Standard MCP tool execution result containing the following fields:
Text content blocks intended for model context.
Structured data optimized for UI rendering. Use this for displaying rich results in your app.
Whether the tool returned an error. When
true, content contains error details.Metadata object. Contains
viewUUID which can be used for state persistence across tool calls.Usage
Handling success and error states
Rendering structured content
Using viewUUID for state persistence
Using with the sunpeak framework
The sunpeak framework provides theuseToolData hook, which wraps ontoolresult (along with related handlers) into a reactive value for React components.
Related
- Event Handlers overview — all notification and request handlers
- ontoolinput — receive complete tool arguments before the result