Skip to main content
sunpeak API

Overview

Returns a function to send model context updates to the host. Unlike useAppState (which automatically syncs structured state), this hook gives direct control over when and what is sent to the model context — including text content blocks. Each call overwrites the previous context. The host includes the last update in the model’s next turn.

Wraps updateModelContext

MCP Apps SDK reference

Import

Signature

UpdateModelContextParams

content
ContentBlock[]
Array of content blocks to include in model context.
structuredContent
Record<string, unknown>
Structured data to include in model context. Serialized as JSON.

Returns

updateModelContext
(params: UpdateModelContextParams) => Promise<void>
Function to push context updates to the host. Each call replaces the previous context.

Usage

Structured Content

Text Content

Comparison with useAppState

See Also

useAppState

Automatic state persistence and sync.