Overview
TheuseToolData hook provides reactive access to both the tool’s input arguments and output data (structured content). It replaces the need for separate input/output hooks. The output field contains the data from your MCP tool’s structuredContent response.
Wraps ontoolinput · ontoolresult · ontoolcancelled
MCP Apps SDK reference
Import
Signature
Parameters
TInput
Fallback value when no input is available. Optional.
TOutput
Fallback value when no output is available. Optional.
Returns
Returns aToolData<TInput, TOutput> object with the following fields:
TInput | null
The complete tool call arguments. Partial notifications do not overwrite this field.
TInput | null
The latest streaming partial input. sunpeak clears it when complete input arrives.
TOutput | null
The structured content from the tool result.
boolean
Whether the tool result indicates an error.
boolean
Whether the tool is still executing.
boolean
Whether the tool call was cancelled by the host or user.
string | null
Optional reason for cancellation, or null if not cancelled.
Usage
Stream a Preview Before Complete Input Arrives
MCP hosts may send zero or more partial input notifications before the complete tool arguments. ReadinputPartial for preview UI and input for the finalized value:
inputPartial can contain missing, truncated, or changing fields. Use it only for rendering a preview. Wait for input before saving data or starting an action. See ontoolinputpartial for the protocol event order and local testing steps.