> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# SWAIG

> Functions and MCP servers the ai_sidecar observer can call while watching a call.

[ai_sidecar]: /docs/swml/reference/calling/ai-sidecar

SWAIG (SignalWire AI Gateway) is SignalWire's function-calling system for AI. It lets the sidecar's model call functions that **you** define and run on your own server, so it can do more than just talk.

While the sidecar watches the call, the model can call a function whenever it needs to look something up or take an action — look up an account, flag a sales signal, update the agent's screen, and so on. When it does, the sidecar sends a request to that function's webhook (`web_hook_url`), your server runs the function and returns a result, and the model uses that result in its next response.

You define these functions under `functions`. You can also connect external MCP (Model Context Protocol) servers under `mcp_servers`, and their tools become available to the model the same way.

## **Properties**

An object that defines the functions and MCP servers available to the sidecar.

Default settings applied to every function that does not override them.

Default webhook URL for functions without their own `web_hook_url`. Basic auth can be embedded as `username:password@url`.

Default basic-auth username for the function webhook.

Default basic-auth password for the function webhook.

An array of functions the model can call during the conversation.

The name of the function. This is the only required field — the model calls the function by this name.

A description of what the function does, sent to the model so it knows when to call it.

A fallback for `description`, used only when `description` is not set.

The JSON-Schema object describing the function's arguments: `type: object` with a `properties` map and an optional `required` array. Each property allows only `type`, `description`, `enum`, and `default` — additional validation keywords such as `pattern`, `minimum`, and `maximum` are not accepted; express those constraints in the property `description` and validate them server-side. When omitted, the function takes no arguments.

Webhook URL for this function. Falls back to `defaults.web_hook_url`. Basic auth can be embedded as `username:password@url`.

Basic-auth username for this function's webhook. Falls back to `defaults.web_hook_auth_user`.

Basic-auth password for this function's webhook. Falls back to `defaults.web_hook_auth_password`.

An array of MCP (Model Context Protocol) servers whose tools and resources are made available to the AI. Each server's tools are discovered at startup and registered as callable functions, so they can be invoked like any other SWAIG function.

The MCP server URL.

HTTP headers sent to the MCP server. Authorization tokens go here — there is no separate auth field. Header values support variable expansion (e.g. `Bearer ${global_data.token}`).

Whether to fetch the server's resources into `global_data`, when the server advertises resource support.

Template variables passed to the MCP server when fetching resources. Used only when `resources` is enabled.

The function name `sidecar_skip` is reserved. It is auto-registered as a built-in tool — do not declare a function with that name. See [Built-in `sidecar_skip` tool](/docs/swml/reference/calling/ai-sidecar#built-in-sidecar_skip-tool).

## **Examples**

```yaml
ai_sidecar:
  prompt: "Coach the agent."
  lang: "en-US"
  SWAIG:
    defaults:
      web_hook_url: "https://your-app.example.com/sidecar/swaig"
    functions:
      - function: lookup_competitor
        description: "Look up a competitor by name."
        parameters:
          type: object
          properties:
            competitor:
              type: string
              description: "Competitor name."
          required:
            - competitor
    mcp_servers:
      - url: "https://crm.example.com/mcp"
        headers:
          Authorization: "Bearer ${global_data.crm_token}"
        resources: true
        resource_vars:
          customer_id: "${global_data.customer_id}"
```

```json
{
  "ai_sidecar": {
    "prompt": "Coach the agent.",
    "lang": "en-US",
    "SWAIG": {
      "defaults": {
        "web_hook_url": "https://your-app.example.com/sidecar/swaig"
      },
      "functions": [
        {
          "function": "lookup_competitor",
          "description": "Look up a competitor by name.",
          "parameters": {
            "type": "object",
            "properties": {
              "competitor": {
                "type": "string",
                "description": "Competitor name."
              }
            },
            "required": ["competitor"]
          }
        }
      ],
      "mcp_servers": [
        {
          "url": "https://crm.example.com/mcp",
          "headers": {
            "Authorization": "Bearer ${global_data.crm_token}"
          },
          "resources": true,
          "resource_vars": {
            "customer_id": "${global_data.customer_id}"
          }
        }
      ]
    }
  }
}
```