Skip to main content
sunpeak API

Overview

Manages UI state that is automatically synced to the host via updateModelContext. Works like React’s useState, but each update is pushed to the host so the AI model can see it on the next message. Use this for user decisions, selections, or any state the model should be aware of.

Wraps updateModelContext

MCP Apps SDK reference

Import

Signature

Parameters

defaultState
T
required
Initial state value.

Returns

return
[T, (state: SetStateAction<T>) => void]
A tuple containing the current state and a setter function, similar to React’s useState.

Usage