> ## Documentation Index
> Fetch the complete documentation index at: https://sunpeak.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# useCallServerTool

> Call other MCP server tools.

<Badge color="yellow">sunpeak API</Badge>

## Overview

Returns a function to invoke other MCP tools registered on the server. Useful for multi-step workflows where one app needs to trigger another tool.

<Card horizontal title="Wraps callServerTool" icon="cube" href="/mcp-apps/app/requests/call-server-tool">
  MCP Apps SDK reference
</Card>

## Import

```tsx theme={null}
import { useCallServerTool } from 'sunpeak';
```

## Signature

```tsx theme={null}
function useCallServerTool(): (params: CallServerToolParams) => Promise<CallServerToolResult | undefined>
```

### CallServerToolParams

<ResponseField name="name" type="string" required>
  Name of the MCP tool to call.
</ResponseField>

<ResponseField name="arguments" type="Record<string, unknown>">
  Arguments to pass to the tool.
</ResponseField>

## Returns

<ResponseField name="callTool" type="(params: CallServerToolParams) => Promise<CallServerToolResult | undefined>">
  Function to call an MCP server tool.
</ResponseField>

### CallServerToolResult

<ResponseField name="content" type="Array<{ type: string; text?: string }>">
  Tool response content (human-readable text for the host model).
</ResponseField>

<ResponseField name="structuredContent" type="Record<string, unknown>">
  Structured data from the tool response. Use this for machine-readable data the calling resource needs to render (e.g., `{ status: 'success', message: '...' }`).
</ResponseField>

<ResponseField name="isError" type="boolean">
  Whether the tool call resulted in an error. Only set for actual execution failures — not for expected outcomes like cancellations.
</ResponseField>

## Usage

```tsx theme={null}
import { useCallServerTool } from 'sunpeak';

function ReviewResource() {
  const callTool = useCallServerTool();

  const handleApply = async () => {
    const result = await callTool({
      name: 'apply_changes',
      arguments: { changesetId: 'cs_789' },
    });
    console.log('Tool result:', result);
  };

  return <button onClick={handleApply}>Apply Changes</button>;
}
```
