Overview
callServerTool lets the View invoke any tool registered on the originating MCP server. The host proxies the request to the server and returns the result. This is the primary mechanism for UI-driven server interactions — for example, fetching data, submitting forms, or triggering server-side actions from a button click.
Tool-level execution errors are returned inside the result object with isError: true rather than throwing exceptions. Only transport or protocol failures throw. Always check result.isError before consuming the response.
For tools that should only be callable from the View (not the model), register them with visibility: ["app"] on the server side. See registerAppTool for details.
Signature
Parameters
Returns
The result returned by the server tool.
Array of content blocks returned by the tool (text, images, embedded resources, etc.).
Structured output when the tool returns it. If the tool declares an
outputSchema, successful structured output must match that schema.Usage
Basic tool call
Using structured content
When the server tool returns structured output, it is available onstructuredContent. A declared outputSchema constrains its shape:
Cancelling a request
Pass anAbortSignal to cancel long-running tool calls:
Tool-level execution errors are returned in the result with
isError: true rather than throwing exceptions. Transport or protocol failures throw. Always check result.isError.Related
- Requests overview — all available View-to-host request methods
useCallServerTool— sunpeak React convenience hook- registerAppTool — register tools on the server with UI metadata
- Tool
_meta— visibility and metadata configuration