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

# Connect tools to extend your voice agent's capabilities

> Give your agent the ability to act: call server APIs, trigger client-side events, connect MCP servers, and enable built-in system tools.

Tools let your agent do more than answer questions — they let it take action. When a tool is configured, the LLM can decide to invoke it mid-conversation based on the user's request. You define the tool's parameters and behavior; the platform handles invocation and passes results back to the model.

<CardGroup cols={2}>
  <Card title="Client tools" icon="browser">
    Executed in the user's browser or app. Use these to trigger client-side actions like opening a modal, updating the UI, or logging an event.
  </Card>

  <Card title="Server tools" icon="server">
    Executed on your backend via HTTP. Use these to read or write data, call third-party APIs, or run server-side logic.
  </Card>

  <Card title="MCP tools" icon="plug">
    Connect to Model Context Protocol servers. Use these to access entire toolsets exposed by an MCP-compatible service.
  </Card>

  <Card title="System tools" icon="gear">
    Built-in platform tools provided by XUNA AI. No configuration required beyond enabling them.
  </Card>
</CardGroup>

## Client tools

Client tools run in the browser or native app. When the agent decides to call a client tool, it sends a tool-call event over the WebSocket or WebRTC connection. Your client-side code handles the event and returns a result.

Use client tools for:

* Opening a UI dialog or confirmation modal.
* Navigating to a different page.
* Reading local state (e.g., items in a cart).
* Logging analytics events.

Define a client tool by specifying its name, description, and parameters. The description is what the LLM reads to decide when to invoke it.

```json client-tool-definition.json theme={null}
{
  "name": "open_cart",
  "description": "Opens the shopping cart drawer so the user can review their items.",
  "parameters": {
    "type": "object",
    "properties": {}
  }
}
```

In your client code, register a handler for the tool. The handler's return value is sent back to the agent as the tool result.

<CodeGroup>
  ```tsx react.tsx theme={null}
  import { ConversationProvider } from "@xuna-ai/react";

  <ConversationProvider
    clientTools={{
      open_cart: () => {
        openCartDrawer();
        return "Cart opened";
      },
    }}
  >
    <Agent />
  </ConversationProvider>
  ```

  ```javascript browser.js theme={null}
  import { Conversation } from "@xuna-ai/client";

  const conversation = await Conversation.startSession({
    agentId: "YOUR_AGENT_ID",
    clientTools: {
      open_cart: () => {
        openCartDrawer();
        return "Cart opened";
      },
    },
  });
  ```
</CodeGroup>

## Server tools

Server tools execute on your backend. When the agent calls a server tool, the platform sends an HTTP POST request to your endpoint with the tool's parameters. Your server processes the request and returns a result.

Use server tools for:

* Looking up order status from your database.
* Creating a support ticket in an external system.
* Sending an email or SMS.
* Fetching real-time data like inventory or pricing.

Define a server tool with a name, description, parameters schema, and your endpoint URL:

```json server-tool-definition.json theme={null}
{
  "name": "get_order_status",
  "description": "Looks up the status of a customer order by order ID.",
  "parameters": {
    "type": "object",
    "properties": {
      "order_id": {
        "type": "string",
        "description": "The customer's order ID."
      }
    },
    "required": ["order_id"]
  },
  "url": "https://api.yourapp.com/orders/status"
}
```

The platform sends a POST request with a JSON body:

```json tool-call-request.json theme={null}
{
  "tool_name": "get_order_status",
  "parameters": {
    "order_id": "ORD-9821"
  }
}
```

Your endpoint should return a JSON object. The agent includes the response in its context before generating the next turn.

<Note>
  Server tool calls add latency equal to your endpoint's response time. Keep server tools fast — aim for under 500ms. For slower operations, consider a pattern where the tool queues work and the agent tells the user it will follow up.
</Note>

## MCP tools

Model Context Protocol (MCP) is an open standard for connecting AI models to external toolsets. Connecting an MCP server gives your agent access to all the tools and resources that server exposes — without defining each one individually.

<Steps>
  <Step title="Get your MCP server URL">
    Obtain the URL of the MCP-compatible server you want to connect.
  </Step>

  <Step title="Add the MCP server to your agent">
    In the dashboard, go to **Tools** → **MCP** and enter the server URL and any required authentication headers.
  </Step>

  <Step title="Verify available tools">
    After connecting, the dashboard shows the list of tools discovered from the server. The agent can invoke any of them.
  </Step>
</Steps>

## System tools

System tools are built into the XUNA AI platform. Enable them in the **Tools** tab without any code.

| Tool                       | Description                                                              |
| -------------------------- | ------------------------------------------------------------------------ |
| **End call**               | Terminates the conversation gracefully.                                  |
| **Language detection**     | Detects the user's language and switches ASR and TTS automatically.      |
| **Agent transfer**         | Hands off the conversation to another XUNA AI agent.                     |
| **Transfer to number**     | Transfers a phone call to a specified number (telephony only).           |
| **Skip turn**              | Instructs the agent to wait silently for the next user input.            |
| **Play keypad touch tone** | Plays DTMF tones (useful for navigating phone menus).                    |
| **Voicemail detection**    | Detects when a call reaches a voicemail system and responds accordingly. |

<Tip>
  Use the **end call** system tool in your system prompt instructions so the agent knows when to hang up. For example: "If the user says goodbye and the issue is resolved, use the end call tool."
</Tip>
