App instance, and the host decides which requests it supports.
Use this guide when you are choosing which client API to call from the View.
Quick Choice
| What the View needs to do | Use | Why |
|---|---|---|
| Fetch fresh server data or run a server action | callServerTool() | The host proxies a normal tools/call to the originating MCP server. |
| Load static or binary server content | readServerResource() | Resources are better for files, templates, media, and named content. |
| Discover server resources | listServerResources() | Use it before showing a picker for server-registered resources. |
| Share UI state with the next model turn | updateModelContext() | It updates context without adding a chat message or starting a response. |
| Ask the host to continue the conversation now | sendMessage() | It adds a user message and may trigger model work. |
| Ask for a local model completion from the View | createSamplingMessage() | Use it for View-local drafting, labeling, or summarization when the host supports sampling. |
| Let the host call into current UI state | App-side tools | Use this when the answer lives in the DOM, form, canvas, or local View state. |
| Open a browser page | openLink() | Host-mediated link opening works from sandboxed iframes. |
| Save a generated file | downloadFile() | Host-mediated download avoids iframe download restrictions. |
| Change presentation size | requestDisplayMode() | The host can approve inline, fullscreen, or PiP mode based on support. |
| Report diagnostics | sendLog() | Logs go to the host’s developer surface, not the conversation. |
| Ask to close the View | requestTeardown() | The host may then send ui/resource-teardown before unmounting. |
Check Host Capabilities First
Hosts may implement only part of the MCP Apps API. Read capabilities afterapp.connect(), then hide or disable UI that depends on missing host support.
message.text does not mean the host accepts images in sendMessage(), and updateModelContext.image does not mean it accepts structured content.
Server Tool or Server Resource?
Use a server tool when the View needs computation, authorization, mutation, search, filtering, pagination, or fresh data:callServerTool(). If a menu lists files, call listServerResources() and then readServerResource().
Model Context or Chat Message?
UseupdateModelContext() when the model should know what the user is viewing next time, but should not respond yet.
sendMessage() when a user action should continue the conversation immediately.
Sampling or Conversation?
UsecreateSamplingMessage() for work that belongs inside the View, such as generating a short label, grouping visible rows, or summarizing a selected passage before the user commits it.
sendMessage() when the output should become part of the chat transcript or when the model should decide which server tools to call next.
App-side Tool or Server Tool?
Use an app-side tool when the host needs information that only exists inside the rendered View.Errors and Fallbacks
Tool execution errors come back as results, so checkisError. Protocol, transport, and host rejection failures may throw.
isError when the method returns it.
Related Reference
Requests
Full method signatures for View-to-host requests.
Event Handlers
Incoming notifications and host-to-View requests.
App Tools
Expose View-local tools to the host and model.
Core Types
Host capabilities, context, metadata, display modes, and content types.