WhatsApp MCP

MCP server for Meta WhatsApp Cloud API — send free-form and template messages

Documentation

mcp-server-whatsapp

MCP server for CodeChap WhatsApp via the official Meta Cloud API.

This is the CodeChap business line (Poster 4 / +27 65 762 2206). Holiday Stays has its own Meta app and number — do not point Poster 4 at HS.

Features

  • send_message — Free-form text (only inside an active 24-hour customer service window)
  • send_document — PDF/file inside the 24h window
  • send_quote / send_invoice — PDF via quote / invoice templates (outside 24h once approved)
  • send_email_settings — mailbox IMAP/SMTP PDF via email_guide (password sent separately)
  • send_template / upload_media / list_templates
  • list_inbox / get_message / mark_read — inbound messages from the cloud inbox

Inbound messages are stored in the cloud and emailed to ai@codechap.com.

Configuration (MCP / workstation)

~/.config/mcp-server-whatsapp/config.toml:

access_token = "EAAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
phone_number_id = "123456789012345"
waba_id = "1622097682865634"
inbox_url = "https://codechap.com"
inbox_token = "inbox-api-bearer-token"

# Optional
# api_version = "v21.0"

Cloud inbox

Meta delivers webhooks to https://codechap.com/webhook/whatsapp.

HostCodeChap projects server (141.147.65.65)
Binary/home/codechap/wa-inbox/wa-inbox
Config/home/codechap/.config/mcp-server-whatsapp/inbox.toml (mode 600) — see inbox.example.toml
Unitcodechap-wa-inbox.service
SQLite/home/codechap/wa-inbox/inbox.db
Nginxlocation /webhook/whatsapp in codechap.com vhost (must sit above location /)

CloudPanel can regenerate that vhost. If inbound dies after a panel edit, re-insert the snippet from deploy/nginx-whatsapp.conf and nginx -t && systemctl reload nginx.

Rebuild/deploy the inbox binary (server is aarch64):

export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
cargo build --release --target aarch64-unknown-linux-gnu --bin wa-inbox
scp target/aarch64-unknown-linux-gnu/release/wa-inbox codechap@141.147.65.65:~/wa-inbox/wa-inbox
ssh ubuntu@141.147.65.65 'sudo systemctl restart codechap-wa-inbox'

Usage (MCP)

send_message

{ "to": "+27821234567", "body": "Hello from CodeChap!" }

send_template

{
  "to": "+27821234567",
  "template_name": "order_confirmation",
  "language_code": "en_US",
  "components": "[{\"type\":\"body\",\"parameters\":[{\"type\":\"text\",\"text\":\"John\"},{\"type\":\"text\",\"text\":\"tomorrow\"}]}]"
}

send_quote

{
  "to": "+27821234567",
  "pdf_path": "/path/to/quote.pdf",
  "customer_name": "Derrick",
  "quote_ref": "Q-1001"
}

Uses template quote (en, UTILITY) with a document header. Meta must have approved it (list_templates). Inside the 24h window you can also send_document.

list_inbox

{ "from": "+27821234567", "limit": 20 }

from and limit are optional.

Future work

  • Media upload tool (upload_media) for quote PDFs / template headers
  • Download inbound media to the cloud inbox

Development

cargo test
cargo build --release

Binaries: mcp-server-whatsapp (stdio MCP) and wa-inbox (cloud webhook).

License

MIT (or whatever you prefer)