ui:// resource, and a View that can talk back to the host. The basic flow is covered in Lifecycle. This page covers common implementation patterns you will need once the first View is working.
Use App-only Tools for UI Interactions
Set_meta.ui.visibility to ["app"] when a tool should be callable by the View but hidden from the model. Use app-only tools for UI actions that do not help the model decide what to do next:
- Refreshing dashboard data
- Loading the next page of results
- Saving form edits after the user clicks a button
- Polling server state
- Loading private or bulky data that should stay out of model context
content block even when the View mostly uses structuredContent. Text-only hosts, logs, and debugging tools still need a readable summary.
Poll Live Data Deliberately
For dashboards, job progress, or monitoring UIs, poll through an app-only tool. Stop polling during teardown and when the app is hidden or no longer needs updates.complete, failed, or cancelled, stop the interval as soon as that status arrives.
Load Large Data in Chunks
Large files and large result sets should not go through one model-visible tool response. Split them into app-only requests and render progress in the View.hasMore is false:
readServerResource() for data that naturally belongs in MCP resources, such as images, video, generated files, or cached artifacts.
Report Errors at the Right Layer
Use a tool-level error when the model can recover:updateModelContext():
Adapt to Host Context
Hosts can differ in theme, display mode, size, safe area insets, locale, and available capabilities. Read host context afterconnect() and listen for changes.
getHostCapabilities() before relying on host-mediated features such as server tool calls, resource reads, file downloads, link opening, sampling, or message sending.
Keep Model Context Small
Usecontent for the model-readable summary, structuredContent for the View, and app-only tools for data the model does not need.
Good model context:
content. If the model needs a summary later, let the View call updateModelContext() with the specific facts the user selected.
Related
- Tool
_meta- Link tools to Views and set visibility - Resource
_meta- Set CSP, permissions, domains, and borders callServerTool()- Call MCP server tools from the ViewreadServerResource()- Read MCP resources from the ViewupdateModelContext()- Send model-visible context from the View- MCP App Lifecycle - Understand the host and View handshake