Skip to main content
MCP Apps SDK

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

object
required
The tool call parameters.
string
required
The name of the server tool to call. Must match a tool registered on the MCP server.
Record<string, unknown>
Arguments to pass to the tool. The shape must match the tool’s inputSchema. Omit if the tool takes no arguments.
RequestOptions
Optional request configuration.
AbortSignal
An AbortSignal to cancel the request.

Returns

object
The result returned by the server tool.
ContentBlock[]
Array of content blocks returned by the tool (text, images, embedded resources, etc.).
Record<string, unknown>
Structured output if the tool defines an outputSchema. Parsed and validated by the server.
boolean
true if the tool handler returned an error. When true, inspect content for error details. When false or absent, the call succeeded.

Usage

Basic tool call

Using structured content

When the server tool defines an outputSchema, the parsed result is available on structuredContent:

Cancelling a request

Pass an AbortSignal 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.