Deploy your own instance on Cloudflare Workers with full control over your data and credentials.
git clone https://github.com/spirit122/whatsapp-mcp-server.git cd whatsapp-mcp-server npm install
npx wrangler login
This opens your browser. Sign in and authorize Wrangler.
npx wrangler d1 create whatsapp-mcp-db
Copy the database_id from the output.
npx wrangler kv namespace create CACHE
Copy the id from the output.
Open wrangler.toml and replace the placeholder IDs:
# Replace YOUR_KV_NAMESPACE_ID with the KV id [[kv_namespaces]] binding = "CACHE" id = "YOUR_KV_NAMESPACE_ID" # Replace YOUR_D1_DATABASE_ID with the D1 database_id [[d1_databases]] binding = "DB" database_name = "whatsapp-mcp-db" database_id = "YOUR_D1_DATABASE_ID"
Go to developers.facebook.com/apps > "Create App" > Business type. Name it anything (avoid "WhatsApp" in the name — Meta blocks it). Select "Connect with customers via WhatsApp".
In your app dashboard, go to WhatsApp > API Setup. You'll see:
Go to Meta Business Settings > System Users > Create a System User (Admin) > Generate Token with whatsapp_business_messaging and whatsapp_business_management permissions.
# Required secrets npx wrangler secret put WHATSAPP_ACCESS_TOKEN npx wrangler secret put WHATSAPP_PHONE_NUMBER_ID npx wrangler secret put WHATSAPP_BUSINESS_ACCOUNT_ID # For webhook signature verification npx wrangler secret put WHATSAPP_WEBHOOK_VERIFY_TOKEN npx wrangler secret put META_APP_SECRET # For billing (optional, only if you want paid tiers) npx wrangler secret put LEMONSQUEEZY_WEBHOOK_SECRET
npx wrangler d1 execute whatsapp-mcp-db --remote --file=./schemas/d1-schema.sql
npx wrangler deploy
You'll see output like:
Uploaded whatsapp-mcp-server (5.18 sec) Deployed whatsapp-mcp-server triggers (1.08 sec) https://whatsapp-mcp-server.YOUR_SUBDOMAIN.workers.dev
To receive incoming messages, set up webhooks in Meta:
Your App > WhatsApp > Configuration > Webhooks
https://YOUR-WORKER.workers.dev/webhook
Same value you used for WHATSAPP_WEBHOOK_VERIFY_TOKEN
Check the messages field to receive incoming messages.
# Run locally npx wrangler dev # Run tests (72 tests) npm test # Type check npm run typecheck
Claude / AI Assistant
|
v
Cloudflare Worker (Edge)
- MCP Protocol (JSON-RPC)
- Auth + API Keys + Tiers
- Rate Limiting
|
+---+---+
v v
WhatsApp Durable Objects
Cloud API (webhooks storage)
|
+---+---+
v v
D1 KV
(logs) (cache)