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

# MCP server

> Connect an AI agent to your ZapperHub instances through the Model Context Protocol, to read and send messages

## Description

The ZapperHub MCP server lets an AI agent operate the WhatsApp of your
instances. The agent lists the instances, reads conversations, waits for a reply,
and sends messages. It uses the MCP tools and needs no integration code.

The server serves instances of the types `device` (unofficial connection) and
`cloud_api` (official connection). Each connection accesses only the instances of
its own account.

| Item | Value |
| - | - |
| URL | `https://mcp.zapperhub.com/mcp` |
| Transport | Streamable HTTP |
| Authentication | Account login (OAuth) or header `Authorization: Bearer zsk_...` |

> [!NOTE]
>
> The agent never receives the key of an instance. The server uses the instance
> credentials on its own, and no tool returns them.

## Choose how to connect

There are two ways to connect. Choose by client.

| Client | How to connect |
| - | - |
| Claude.ai, Claude Desktop, and ChatGPT | [Account login](#connect-with-the-account-login). You do not paste a key |
| Claude Code, Cursor, Hermes, and OpenClaw | [Account key](#connect-with-the-account-key), in a header of the client |

A remote MCP client that supports login (OAuth) finds the login screen on its
own. Another client without this function uses the account key.

## Connect with the account login

With the account login, you sign in to ZapperHub and choose what the agent
accesses. You do not copy any key. The connection stays in the list
[Connected apps](https://docs.zapperhub.com/en/panel/connected-apps.md), where you edit or revoke the access.

### Preliminary requirements

* A connected instance. See [Quickstart](https://docs.zapperhub.com/en/quickstart.md).
* A client that supports a remote MCP server with login (OAuth).

### Add the connector in the client

In all clients, the address of the server is `https://mcp.zapperhub.com/mcp`.

> [tab] Claude.ai and Claude Desktop
>
> **1. Open the connectors**
>
> Go to **Customize** > **Connectors**.
>
> **2. Add the connector**
>
> Click **+ Add** and **Add custom connector**.
>
> **3. Enter the data**
>
> Enter a name, for example `ZapperHub`. Enter the URL `https://mcp.zapperhub.com/mcp`. Click **Continue**.
>
> **4. Finish**
>
> Review the authentication options and click **Continue**. Then click **Add**.
>
> **5. Sign in to ZapperHub**
>
> Claude opens ZapperHub. If ZapperHub asks for a login, sign in to your account. Then go on to the [authorization screen](#authorization-screen).
>
> On the Free plan, Claude supports one custom connector.
>
> On the Team and Enterprise plans, an owner of the organization adds the
> connector in **Organization settings** > **Connectors**. Each member clicks
> **Connect** on the connector and signs in with their own ZapperHub account.
>
> The menu names follow the Claude documentation and change between versions.
> Claude Desktop also supports a custom connector. If the menu of your app is
> different, look for the option to add a custom connector and use the same
> URL.

> [tab] ChatGPT
>
> > [!NOTE]
> >
> > According to the OpenAI help, the Business, Enterprise, and Edu plans have
> > the full connection. On the Pro plan, the connection gives only read
> > permissions: the agent reads the conversations and does not send messages.
> > The OpenAI help does not mention the other plans.
>
> **1. Open the plugins**
>
> Go to [chatgpt.com/plugins](https://chatgpt.com/plugins) on the web.
>
> **2. Add the server**
>
> Click the plus button and **Add custom MCP server**.
>
> **3. Enter the data**
>
> Enter a name. In **Server URL**, enter `https://mcp.zapperhub.com/mcp`. For authentication, choose **OAuth**.
>
> **4. Create**
>
> Confirm the risk warning and click **Create as a plugin**.
>
> **5. Install and sign in**
>
> Install the plugin to use it in a conversation. ChatGPT opens ZapperHub. If ZapperHub asks for a login, sign in to your account. Then go on to the [authorization screen](#authorization-screen).
>
> On the Business plan, only admins and owners of the workspace create the
> plugin. ChatGPT supports a custom MCP server on the web only. If the menu is
> different, look for the option to add a custom MCP server and use the same
> URL.

> [tab] Other client
>
> Add a connector or a remote MCP server with the URL
> `https://mcp.zapperhub.com/mcp`. The client finds the account login and opens
> the ZapperHub login screen.

### Authorization screen

After the login, ZapperHub shows the authorization screen. It has the name of the
app and its address. Choose what the app accesses and click **Authorize**. To
give up, click **Cancel**. In both cases, you go back to the app.

> [!WARNING]
>
> Check the address that the screen shows next to the name. It must be the address
> of the app that you are connecting, for example `claude.ai`. If the address is
> different, click **Cancel**.

The screen has two choices.

| Choice | Option | What it allows |
| - | - | - |
| **Instances** | **All instances** | All instances of the account, also the ones that you create later |
| | **Only the selected ones** | Only the instances that you select. Select at least one |
| **Access** | **Read only** (default) | View messages and chats. The agent uses 8 tools |
| | **Read and write** | View and send messages. The agent uses all 13 tools |

The 8 tools of the **Read only** access are `list_instances`, `list_chats`,
`read_messages`, `wait_for_reply`, `check_numbers`, `get_service_window`,
`list_templates`, and `list_groups`. The **Read and write** access adds `send_text`, `send_media`,
`send_template`, `react`, and `mark_as_read`. With **Read only**, the agent does
not see the write tools.

With both options, the agent also sees the list of the authorized instances,
with name, number, status, and tags.

After you authorize, the client keeps the connection and renews the access on its
own. You do not paste a key and you do not sign in again at each use.

### Edit or revoke the connection

Each connected app appears in [Connected apps](https://docs.zapperhub.com/en/panel/connected-apps.md), in the
side menu of the panel. On this screen, you change the instances and the access
with **Edit** and remove the access with **Revoke**. The change takes effect on
the next call of the agent.

Revoking a connection does not affect the account key or the other integrations.
Rotating or deleting the account key does not affect a connection by login
either.

## Connect with the account key

The account key is the alternative for the clients that support custom headers:
Claude Code, Cursor, Hermes, and OpenClaw. The agent has the access of the key:
write access to all instances of the account.

### Preliminary requirements

* A connected instance. See [Quickstart](https://docs.zapperhub.com/en/quickstart.md).
* The global key of the account, which starts with `zsk_`.
* An MCP client that supports Streamable HTTP and custom headers.

### Generate the account key

**1. Open the key screen**

Go to [app.zapperhub.com/dash](https://app.zapperhub.com/dash) and click **Global API Key** in the side menu.

**2. Create the key**

Click **Create global key**.

**3. Copy the key**

Copy the key and store it in the MCP client. The panel shows the key only once.

The account key is the same global key of the Instance API. The screen, the
rotation, and the deletion are in [Global API key](https://docs.zapperhub.com/en/panel/global-api-key.md).

> [!WARNING]
>
> The account key gives the agent write access to all instances of the account.
> Store it as a secret. Do not put it in versioned code. If you rotate or delete
> the key, the MCP client loses access until you update the header.

### Configure the client

In all clients, the address is `https://mcp.zapperhub.com/mcp` and the header is
`Authorization: Bearer zsk_...`. Replace `zsk_...` with your key.

> [tab] Claude Code
>
> Run the command in the terminal:
>
> ```bash theme={null}
> claude mcp add --transport http zapperhub https://mcp.zapperhub.com/mcp --header "Authorization: Bearer zsk_..."
> ```

> [tab] Cursor
>
> Add the server to the `mcp.json` file:
>
> ```json mcp.json theme={null}
> {
>   "mcpServers": {
>     "zapperhub": {
>       "url": "https://mcp.zapperhub.com/mcp",
>       "headers": {
>         "Authorization": "Bearer zsk_..."
>       }
>     }
>   }
> }
> ```

> [tab] Hermes
>
> Add the server to the `mcp_servers` key of the `~/.hermes/config.yaml` file:
>
> ```yaml config.yaml theme={null}
> mcp_servers:
>   zapperhub:
>     url: "https://mcp.zapperhub.com/mcp"
>     headers:
>       Authorization: "Bearer zsk_..."
> ```

> [tab] OpenClaw
>
> Run the command in the terminal:
>
> ```bash theme={null}
> openclaw mcp set zapperhub '{"url":"https://mcp.zapperhub.com/mcp","transport":"streamable-http","headers":{"Authorization":"Bearer zsk_..."}}'
> ```

> [tab] Other client
>
> Use any MCP client that supports Streamable HTTP and custom headers. Enter
> the URL `https://mcp.zapperhub.com/mcp` and the header
> `Authorization: Bearer zsk_...`.

## Test the connection

After you connect, by login or by key, ask the agent to list the instances. The
answer confirms that the connection works.

## Tools

The server exposes 13 tools. Their names and descriptions are in English, for the
agent. In every tool, `instance` is the id or the name of an instance from
`list_instances`. `chat` is a number with the country code, a group id that ends
in `@g.us`, or a LID that ends in `@lid`.

### Read and check

| Tool | What it does |
| - | - |
| `list_instances` | Lists the instances of the account, with id, name, number, type, status, and tags. Call it first: the other tools use an id or a name from this list |
| `list_chats` | Lists the most recent conversations of an instance, newest first, with the last message. `limit` from 1 to 50 |
| `read_messages` | Reads the messages of a conversation, oldest first. `after` and `before` accept a cursor to page. `limit` from 1 to 100. The messages that the account sent show the send status |
| `wait_for_reply` | Waits for a new message from the contact or the group and returns the received messages and a new `cursor`. `after` is required: use the `cursor` of a send or of `read_messages`. `timeout_seconds` from 1 to 60, default 50. With no message in time, it returns `timedOut: true`. The returned messages can include reactions and system notices |
| `check_numbers` | Checks whether up to 50 numbers have WhatsApp and returns the JID of each |
| `get_service_window` | Tells whether the 24-hour window is open for a contact. It matters only in `cloud_api` |
| `list_templates` | Lists the templates of a `cloud_api` instance, with name, language, status, category, and components |
| `list_groups` | Lists the groups and communities of a `device` instance, by name, with the id and the `type`: `community` (the community, which does not receive messages), `announcement` (the announcement group), or `group`. `canSend` tells if the instance can send: `yes`, `no`, or `unknown`, with a `note` when it is not `yes`. `name` filters by the name, without a difference for uppercase letters and accents. Returns 200 groups at most |

### Send

| Tool | What it does |
| - | - |
| `send_text` | Sends a text message to a contact or group. Up to 4096 characters |
| `send_media` | Sends an image, video, audio, or document from a public URL, with an optional caption and file name. A document needs a name: without `filename`, the server uses the file name at the end of the URL. A URL of a private or internal address is refused with `INVALID_MEDIA_URL` |
| `send_template` | Sends an approved template on a `cloud_api` instance. Use it to start a conversation or when the 24-hour window is closed |
| `react` | Reacts to a message with an emoji. An empty text removes the reaction |
| `mark_as_read` | Marks received messages as read. In a group, also enter `sender` |

Sends are queued. The response has `status`, `jobIds`, and `cursor`. Every send
returns the `cursor`, also the first message to a new contact. Pass this `cursor`
to `wait_for_reply` to wait for the reply of the contact.

### Status of the sent messages

In `read_messages`, each message that the account sent (`fromMe: true`) has
`status`, `jobId`, and, on a failure, `error`. The `jobId` is one of the `jobIds`
of the send. If the reply of the contact does not arrive, read the conversation
and check the status of the message.

| `status` | Meaning |
| - | - |
| `pending` | The message is in the conversation, with no send confirmation |
| `sent` | The platform confirmed the send |
| `delivered` | The message arrived on the device of the contact |
| `read` | The contact read the message |
| `failed` | The send failed. `error` has `code`, `title`, and, when the provider gives it, `message` with the reason |

A message deleted for everyone has `deleted: true`, with no text and no media.

### Official API instances

On a `cloud_api` instance, `send_text` and `send_media` work only within 24 hours
of the last message of the contact. With the window closed, the tool responds
`SERVICE_WINDOW_CLOSED`. In this case, use `list_templates` and `send_template`.
See [Templates](https://docs.zapperhub.com/en/panel/templates.md).

### Limits

* Each user can make up to 120 calls per minute.
* `wait_for_reply` waits at most 60 seconds per call. To wait longer, call the
  tool again with the returned `cursor`.
* Each account can have up to 10 `wait_for_reply` calls at the same time. The
  next call responds `TOO_MANY_WAITS`.
* The tools see only the instances of the account of the connection. With a connection by login, only the authorized instances.

## Agents that run all the time

An interactive agent, such as Claude Code, uses `wait_for_reply` to wait for a
reply. An agent that answers conversations all the time receives the messages
through a webhook. The instance notifies the agent, and the agent answers with
the MCP tools.

**1. Expose a URL in the agent**

The agent needs an HTTPS URL that receives `POST` requests.

**2. Register the webhook in the instance**

Point the webhook of the instance to this URL and subscribe to the `messages.upsert` event. The procedure is in [Webhooks](https://docs.zapperhub.com/en/integrations/webhooks.md).

**3. Validate the signature**

Check the `x-webhook-signature` header of each delivery, as [Webhooks](https://docs.zapperhub.com/en/integrations/webhooks.md) describes. The signature uses the API key of the instance. Copy this key in the panel, with **Copy X-Api-Key** in [Instances](https://docs.zapperhub.com/en/panel/instances.md), and configure it only in the code that receives the webhook. Do not put this key in the MCP client.

**4. Answer through the MCP**

On each event, the agent calls the tools. Use `instanceId` as `instance` and `key.remoteJid` as `chat`. For example, call `read_messages` to read the context and `send_text` to answer.

The webhook also delivers the messages that the account itself sends. Ignore the
events with `key.fromMe` equal to `true`. Without this filter, the agent answers
its own messages.

For a ready-made support agent, with no server of your own, see
[AI agents](https://docs.zapperhub.com/en/integrations/ai-agents.md).

## Documentation MCP

The ZapperHub documentation also has an MCP server, at
`https://docs.zapperhub.com/mcp`. It lets the agent search this documentation. It
needs no key and does not access your instances. Add it to the client in the same
way, without the `Authorization` header. In Claude Code:

```bash theme={null}
claude mcp add --transport http zapperhub-docs https://docs.zapperhub.com/mcp
```

## See also

* [Connected apps](https://docs.zapperhub.com/en/panel/connected-apps.md): edit and revoke the connections by login.
* [Global API key](https://docs.zapperhub.com/en/panel/global-api-key.md): create, rotate, and delete the account key.
* [Webhooks](https://docs.zapperhub.com/en/integrations/webhooks.md): receive the events of the instance.
* [AI agents](https://docs.zapperhub.com/en/integrations/ai-agents.md): the Chatvolt agent, linked to the instance.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.