# Whatsapp Cloud API MCP (`mdbm/whatsapp-cloud-api-mcp`) Actor

Give your AI agents a phone number! The easiest way to integrate WhatsApp Business API with Claude and other MCP-compliant tools. Supports text, media, and interactive buttons.

- **URL**: https://apify.com/mdbm/whatsapp-cloud-api-mcp.md
- **Developed by:** [Mouhamed Bakhoum](https://apify.com/mdbm) (community)
- **Categories:** Integrations, MCP servers, Developer tools
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 14 total users, 0 monthly users, 0.0% runs succeeded, 3 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## WhatsApp MCP Server

**Model Context Protocol (MCP) Server for WhatsApp Business API**

This Apify Actor runs a full MCP Server that enables AI agents (like Claude, Cursor, etc.) to interact with WhatsApp. It supports sending messages, handling webhooks, and managing conversations.

### Features

- **MCP Protocol Support**: Implements the Model Context Protocol (JSON-RPC 2.0) for seamless integration with AI agents.
- **WhatsApp Integration**: Send and receive text, media, and interactive messages.
- **Webhook Handling**: Validates and processes WhatsApp Cloud API webhooks.
- **Message History**: Stores messages in Apify Dataset and provides tools to search and retrieve conversation history.
- **Reliability**: Built-in retry logic, rate limiting, and message deduplication.

### Tools Available to Agents

The server exposes the following MCP tools:

1. `send_whatsapp_message`: Send text or media messages.
2. `send_interactive_message`: Send buttons or list messages.
3. `get_recent_messages`: Retrieve recent messages (inbound/outbound).
4. `get_conversation`: Get full conversation history with a specific number.
5. `search_messages`: Search message content.

### Configuration

#### Required Settings

1. **WHATSAPP_PHONE_NUMBER_ID**: Your Phone Number ID from the [Meta for Developers Console](https://developers.facebook.com/).
2. **WHATSAPP_ACCESS_TOKEN**: A valid system user access token with `whatsapp_business_messaging` permission.

#### Optional Settings

- **VERIFY_TOKEN**: The verification token you set in the Meta App Dashboard > WhatsApp > Configuration.
- **WEBHOOK_SECRET**: The App Secret for validating webhook signatures (highly recommended for security).

### Usage

#### 1. Deploy the Actor

Deploy this actor to your Apify account.

#### 2. Configure Meta Webhook

In your Meta App Dashboard:

1. Go to **WhatsApp** > **Configuration**.
2. Click **Edit** under **Webhook**.
3. **Callback URL**: Use the Apify Actor Container URL + `/webhook`.
   - Start the actor in Apify.
   - Copy the **Container URL** from the "Live View" or logs (e.g., `https://unique-container-url.apify.actor`).
   - Append `/webhook` (e.g., `https://unique-container-url.apify.actor/webhook`).
4. **Verify Token**: Enter the `VERIFY_TOKEN` you configured in the Actor input.

#### 3. Connect Your AI Agent

Your AI agent (e.g., Claude Desktop, Cursor) needs to connect to this MCP server.
The server exposes the MCP endpoint at `/mcp`.

**Endpoint**: `https://unique-container-url.apify.actor/mcp`

**Endpoint**: `https://unique-container-url.apify.actor/mcp`

### How to Use with LLMs

Since your actor runs on Apify (remote HTTP), you need a way to bridge it to your local MCP client.

#### Option 1: Using with Claude Desktop

Claude Desktop typically communicates with MCP servers via standard input/output (stdio). To connect to your remote Apify Actor, you can use a generic HTTP client adapter or a simple local script.

##### 1. Get your Apify Actor URL

1. Go to your Actor in the Apify Console.
2. Copy the **Container URL** (e.g., `https://whatsapp-mcp-actor-xyz.apify.actor`).

##### 2. Configure Claude Desktop

Open your Claude Desktop configuration file:

- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
- **Mac**: `~/Library/Application Support/Claude/claude_desktop_config.json`

Add the following configuration. We'll use `npx` to run a lightweight bridge that forwards requests to your Apify Actor.

```json
{
  "mcpServers": {
    "whatsapp": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-http-client",
        "https://<YOUR-ACTOR-URL>.apify.actor/mcp"
      ],
      "env": {
        "APIFY_TOKEN": "<YOUR_APIFY_TOKEN>" 
      }
    }
  }
}
```

*Note: Replace `<YOUR-ACTOR-URL>` with your actual actor URL and `<YOUR_APIFY_TOKEN>` with your Apify API token.*

##### 3. Restart Claude Desktop

Restart the application. You should now see the WhatsApp tools (e.g., `send_whatsapp_message`) available in the chat interface.

#### Option 2: Testing with MCP Inspector

You can use the official MCP Inspector to test your server directly from the command line without configuring Claude Desktop yet.

Run this command in your terminal:

```bash
npx @modelcontextprotocol/inspector https://<YOUR-ACTOR-URL>.apify.actor/mcp
```

This will open a web interface where you can:

1. See the list of available tools.
2. Test sending messages.
3. View the JSON-RPC responses.

#### Option 3: Using with Cursor

Cursor currently has built-in MCP support (beta).

1. Open Cursor Settings (`Ctrl/Cmd + ,`).
2. Navigate to **Features** > **MCP**.
3. Click **Add New MCP Server**.
4. **Name**: `whatsapp`
5. **Type**: `HTTP` (if available) or `Command`.
   - If `HTTP` is supported: Enter your Actor URL + `/mcp`.
   - If only `Command` is supported: Use the same `npx` command as above:
     `npx -y @modelcontextprotocol/server-http-client https://<YOUR-ACTOR-URL>.apify.actor/mcp`

#### Troubleshooting

- **Connection Refused**: Ensure your Actor is **RUNNING** in the Apify Console. It must be active to receive requests.
- **Authentication**: If your actor requires an Apify Token for access (likely), ensure you pass it in the headers or environment variables if using a custom client. The `@modelcontextprotocol/server-http-client` might need specific configuration for headers.

### Output

All messages (sent and received) are stored in the **Apify Dataset**. You can view them in the "Output" tab or download them in JSON/CSV format.

### Pricing

This Actor is paid per event. For detailed pricing information, please visit the [Pricing Page](https://apify.com/mdbm/whatsapp-cloud-api-mcp/pricing).

# Actor input Schema

## `WHATSAPP_PHONE_NUMBER_ID` (type: `string`):

Phone number ID from Meta/WhatsApp Cloud console (e.g., 123456789012345)

## `WHATSAPP_ACCESS_TOKEN` (type: `string`):

Bearer token for WhatsApp Cloud API. Use a permanent (not test) token.

## `VERIFY_TOKEN` (type: `string`):

Optional: Token configured in Meta console to verify webhook. Leave empty to skip verification.

## `WEBHOOK_SECRET` (type: `string`):

Optional: Secret for HMAC-SHA256 signature validation. Leave empty to skip validation.

## `MAX_RETRIES` (type: `integer`):

Number of retry attempts for failed API calls

## `RATE_LIMIT_WINDOW` (type: `integer`):

Time window for rate limiting in seconds

## `RATE_LIMIT_MAX` (type: `integer`):

Maximum messages per window per phone number

## `LOG_LEVEL` (type: `string`):

Logging verbosity level

## Actor input object example

```json
{
  "WHATSAPP_PHONE_NUMBER_ID": "123456789012345",
  "MAX_RETRIES": 3,
  "RATE_LIMIT_WINDOW": 3600,
  "RATE_LIMIT_MAX": 100,
  "LOG_LEVEL": "info"
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("mdbm/whatsapp-cloud-api-mcp").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("mdbm/whatsapp-cloud-api-mcp").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call mdbm/whatsapp-cloud-api-mcp --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,mdbm/whatsapp-cloud-api-mcp"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/eA8I2GzN0UNsyShNc/builds/ldfuM7QTjut5aoCrG/openapi.json
