WhatsApp Business MCP Server
A security-hardened Model Context Protocol (MCP) server for the official WhatsApp Business Cloud API. Connect AI assistants like Claude, Cursor, or any MCP-compatible client to WhatsApp Business.
Features
- 50+ tools across 8 modules — messaging, templates, media, analytics, flows, webhooks, business profile, account management
- Security-first — API key auth, rate limiting, input validation, webhook signature verification, error sanitization, path traversal protection
- Official Meta API only — all calls go to
graph.facebook.com, no unofficial/third-party APIs - Two transport modes — stdio (for MCP clients like Claude Desktop) and HTTP (for REST API access)
- Production-ready — CORS controls, security headers, configurable via environment variables
Tools Overview
Quick Start
1. Clone and install
git clone https://github.com/tkhattar14/whatsapp-business-mcp.git
cd whatsapp-business-mcp
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
2. Configure
cp .env.example .env
# Edit .env with your Meta WhatsApp Business API credentials
# Get them from: https://developers.facebook.com/
3. Run (stdio mode — for MCP clients)
source .env && python main.py
4. Run (HTTP mode — for REST API)
source .env && python main_http.py
MCP Client Configuration
Claude Desktop / Cursor
{
"mcpServers": {
"whatsapp": {
"command": "python",
"args": ["/path/to/whatsapp-business-mcp/main.py"],
"env": {
"META_ACCESS_TOKEN": "your_token",
"META_PHONE_NUMBER_ID": "your_phone_id"
}
}
}
}
mcporter (OpenClaw)
mcporter add whatsapp-business --stdio "python /path/to/main.py"
Environment Variables
Security
This server is security-hardened with:
- API key authentication on HTTP endpoints (
X-API-Keyheader) - Rate limiting (10 req/sec per IP, in-memory token bucket)
- Webhook signature verification (HMAC-SHA256 via
META_APP_SECRET) - Input validation — phone number format, message length limits
- Error sanitization — tokens and sensitive URLs stripped from error responses
- Path traversal protection — media uploads restricted to allowed directory
- Security headers —
X-Content-Type-Options,X-Frame-Options,Cache-Control - No wildcard CORS — explicit origin allowlist only
See SECURITY.md for full details.
API Version
Uses WhatsApp Cloud API v22.0 (latest stable, March 2026). Configurable via WHATSAPP_API_VERSION env var.
License
MIT — see LICENSE.