Overview
The MCP (Model Context Protocol) server mode allows AI agents and tools to interact with WhatsApp through a standardized protocol using Server-Sent Events (SSE) transport.MCP and REST modes cannot run simultaneously due to WhatsApp protocol limitations. Choose one mode based on your use case.
Getting Started
Starting the MCP Server
Server Configuration
| Flag | Default | Description |
|---|---|---|
--host | localhost | Host address for the MCP server |
--port | 8080 | Port for the MCP server |
Endpoints
Once started, the MCP server exposes two endpoints:- SSE endpoint:
http://localhost:8080/sse - Message endpoint:
http://localhost:8080/message
MCP Configuration
For AI tools that support MCP with SSE (like Cursor), add this configuration:Cursor IDE Setup
- Open Cursor settings
- Navigate to the MCP configuration section
- Add the WhatsApp MCP server configuration:
- Save and restart Cursor
- The WhatsApp tools will now be available in your AI chat
Available Tools
The WhatsApp MCP server provides comprehensive tools for AI agents to interact with WhatsApp.Connection Management
whatsapp_connection_status
Check whether the WhatsApp client is connected and logged in
whatsapp_login_qr
Initiate QR code based login flow with image output
whatsapp_login_with_code
Generate pairing code for multi-device login using phone number
whatsapp_logout
Sign out the current WhatsApp session
whatsapp_reconnect
Attempt to reconnect to WhatsApp using stored session
Messaging & Communication
whatsapp_send_text
Send text messages with reply and forwarding support, including ghost mentions
whatsapp_send_contact
Send contact cards with name and phone number
whatsapp_send_link
Send links with custom captions
whatsapp_send_location
Send location coordinates (latitude/longitude)
whatsapp_send_image
Send images with captions, compression, and view-once options
whatsapp_send_sticker
Send stickers with automatic WebP conversion (supports JPG/PNG/GIF)
Chat & Contact Management
whatsapp_list_contacts
Retrieve all contacts in your WhatsApp account
whatsapp_list_chats
Get recent chats with pagination and search filters
whatsapp_get_chat_messages
Fetch messages from specific chats with time/media filtering
whatsapp_download_message_media
Download images/videos from messages
whatsapp_archive_chat
Archive or unarchive a chat conversation
Group Management
whatsapp_group_create
Create new groups with optional initial participants
whatsapp_group_join_via_link
Join groups using invite links
whatsapp_group_leave
Leave groups by group ID
whatsapp_group_participants
List all participants in a group
whatsapp_group_manage_participants
Add, remove, promote, or demote group members
whatsapp_group_invite_link
Get or reset group invite links
whatsapp_group_info
Get detailed group information
whatsapp_group_set_name
Update group display name
whatsapp_group_set_topic
Update group description/topic
whatsapp_group_set_locked
Toggle admin-only group info editing
whatsapp_group_set_announce
Toggle announcement-only mode
whatsapp_group_join_requests
List pending join requests
whatsapp_group_manage_join_requests
Approve or reject join requests
Tool Examples
Sending a Text Message
Sending with Ghost Mentions
Ghost mentions allow you to mention users without showing@phone in the message text:
Sending an Image
Listing Chats
Creating a Group
Managing Group Participants
add, remove, promote, demote
Device Management
The MCP server automatically uses the first available device. For multi-device scenarios, the server will select the default device.Device selection in MCP mode follows the same rules as REST mode. If multiple devices are registered, ensure proper configuration.
Transport Details
Server-Sent Events (SSE)
The MCP server uses SSE transport for real-time communication with AI agents:- Keep-alive: Enabled by default
- Base URL:
http://localhost:8080 - SSE Endpoint:
/sse - Message Endpoint:
/message
Message Format
All tool responses follow the MCP protocol format with structured data and fallback text:Limitations
Use Cases
AI Assistants
Enable AI agents to send and receive WhatsApp messages on your behalf
Chatbots
Build intelligent chatbots that interact with WhatsApp contacts
Automation
Automate WhatsApp workflows through AI-driven interactions
Customer Support
Integrate AI-powered customer support via WhatsApp
Troubleshooting
MCP Server Not Starting
- Check if port 8080 is already in use
- Verify no other instance is running
- Check for WhatsApp connection issues
Tools Not Responding
- Verify the SSE connection is established
- Check server logs for errors:
--debug=true - Ensure device is connected and logged in
