WhatsApp MCP Server provides a Model Context Protocol (MCP) interface to interact with WhatsApp Business API through GreenAPI. This server allows language models like Claude to send messages, manage groups, handle sessions, and retrieve chat history directly from WhatsApp.
Before installation, you'll need:
# Clone the repository
git clone https://github.com/yourusername/whatsapp-mcp-server.git
cd whatsapp-mcp-server
# Install dependencies
pip install -e .
# Set up environment variables
cp .env-template .env
# Edit the .env file with your GreenAPI credentials
You need to configure two essential environment variables:
GREENAPI_ID_INSTANCE
: Your GreenAPI ID instanceGREENAPI_API_TOKEN
: Your GreenAPI API tokenRun the MCP server with default settings:
# Run on default host (127.0.0.1) and port (8000)
whatsapp-mcp
Customize host and port if needed:
# Specify custom host and port
whatsapp-mcp --host 0.0.0.0 --port 9000
For troubleshooting:
# Enable debug mode for verbose logging
whatsapp-mcp --debug
The server provides these WhatsApp interaction tools:
Access the server through the FastMCP interface:
ws://localhost:8000/mcp
http://localhost:8000/mcp
Test the API with curl:
# List all available tools
curl -X POST http://localhost:8000/mcp/listTools
# Call a specific tool
curl -X POST http://localhost:8000/mcp/callTool \
-H "Content-Type: application/json" \
-d '{"name": "open_session", "arguments": {}}'
Add the WhatsApp MCP server to Claude:
# Add the server
claude mcp add whatsapp -- whatsapp-mcp
# Verify server is running
claude mcp list
# Start Claude
claude
Add the server to your Claude Desktop configuration file (claude_desktop_config.json
):
"mcpServers": {
"whatsapp": {
"command": "python",
"args": ["-m", "whatsapp_mcp"]
}
}
Alternative configurations:
"mcpServers": {
"whatsapp": {
"command": "whatsapp-mcp"
}
}
Or with Docker:
"mcpServers": {
"whatsapp": {
"command": "docker",
"args": ["run", "--rm", "-i", "-e", "GREENAPI_ID_INSTANCE=your_instance_id", "-e", "GREENAPI_API_TOKEN=your_api_token", "whatsapp-mcp-server"]
}
}
Once connected, you can ask Claude to perform WhatsApp tasks:
Login to WhatsApp
Send the "Hello" message to John Doe
If you encounter issues:
whatsapp-mcp --debug
npx @modelcontextprotocol/inspector whatsapp-mcp
http://localhost:8000
~/Library/Logs/Claude/
on macOS)To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "whatsapp" '{"command":"whatsapp-mcp","args":[]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"whatsapp": {
"command": "whatsapp-mcp",
"args": []
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"whatsapp": {
"command": "whatsapp-mcp",
"args": []
}
}
}
3. Restart Claude Desktop for the changes to take effect