whatsaap-mcp-server

rajtilak-2020/whatsaap-mcp-server

3.2

If you are the rightful owner of whatsaap-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

WhatsApp-MCP is a streamable messaging server that leverages FastMCP and Twilio API to facilitate real-time WhatsApp messaging.

๐Ÿ“ฌ WhatsApp-MCP: Streamable Messaging Server

A powerful, event-stream-based WhatsApp messaging server built with FastMCP and Twilio API.
Send messages programmatically or from a browser using Server-Sent Events โ€” perfect for agents, automation, or dashboards.


๐Ÿ›  Features

  • โœ… FastMCP 2.x support (streamable HTTP transport)
  • โœ… Real-time messaging using Twilio WhatsApp Sandbox
  • โœ… Dynamic phone & message input (via HTML or CLI)
  • โœ… Streaming response with text/event-stream
  • โœ… Works with AI agents, CLI, or browser UI
  • โœ… Optional: deployable to Render, Railway, Replit

๐Ÿš€ Usage Guide

๐Ÿ”ง 1. Setup

git clone https://github.com/your-username/whatsapp-mcp.git
cd whatsapp-mcp
python -m venv venv
venv\Scripts\activate  # or source venv/bin/activate
pip install -r requirements.txt

Create a .env file:

TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TWILIO_AUTH_TOKEN=your_twilio_auth_token
TWILIO_WHATSAPP_FROM=whatsapp:+14155238886

๐Ÿง  2. Start the Server

python server.py

Youโ€™ll see:

๐Ÿ”— Server URL: http://localhost:8000/mcp
๐Ÿ“ฆ Transport: Streamable-HTTP

๐ŸŒ 3. Use the Browser UI

Open index.html in your browser.

Enter:

  • ๐Ÿ“ฑ Phone number (e.g., +91xxxxxxxxxx)
  • ๐Ÿ’ฌ Message

Click Send WhatsApp Message โ€” and receive it instantly!


๐Ÿงช 4. Test with curl

curl -X POST http://localhost:8000/mcp ^
  -H "Content-Type: application/json" ^
  -H "Accept: text/event-stream" ^
  -d "{\"tool\":\"send_whatsapp_message\", \"inputs\":{\"to\":\"+91xxxxxxxxxx\", \"body\":\"Hello from curl!\"}}"

โœ… Replace +91xxxxxxxxxx with your verified WhatsApp number


๐Ÿ“Š System Flow (Mermaid Diagram)

graph TD
  A[๐Ÿง‘ User] -->|Enters message & number| B[๐ŸŒ HTML UI]
  B -->|POST /mcp| C[๐ŸŒ€ FastMCP Server]
  C -->|calls| D[๐Ÿ“ฒ Twilio API]
  D -->|sends| E[๐Ÿ“ฑ WhatsApp Message]
  C -->|streams response| B

๐Ÿงฉ Tech Stack

  • ๐Ÿง  FastMCP v2.x
  • ๐Ÿงช Twilio WhatsApp API
  • โš™๏ธ Python 3.11+
  • ๐ŸŒ HTML + JS (Fetch API)
  • ๐Ÿ” Server-Sent Events (SSE)

๐Ÿ›ก๏ธ Security Notes

  • Never commit .env secrets
  • Sandbox can only message verified users
  • Upgrade to Twilio Business for full sending capabilities

๐Ÿค– Agent-Ready Example (Python)

from fastmcp import Client
from server import mcp

async with Client(mcp) as client:
    await client.call_tool("send_whatsapp_message", {
        "to": "+91xxxxxxxxxx",
        "body": "Triggered from an agent ๐Ÿš€"
    })

๐Ÿ’– Author

Made with โค๏ธ by K Rajtilak