WhatsApp (GreenAPI) MCP server

Provides a bridge to the WhatsApp Business API through GreenAPI, enabling message sending, chat retrieval, and group management directly from conversations.
Back to servers
Setup instructions
Provider
Manuel Saelices
Release date
Mar 18, 2025
Language
Python
Stats
14 stars

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.

Prerequisites

Before installation, you'll need:

  • A GreenAPI account
  • Your GreenAPI ID instance and API token
  • Python installed on your system

Installation

# 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 instance
  • GREENAPI_API_TOKEN: Your GreenAPI API token

Starting the Server

Run 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

Available Tools

The server provides these WhatsApp interaction tools:

  • open_session: Start a new WhatsApp session
  • send_message: Send a message to a contact
  • get_chats: Retrieve your chat list
  • create_group: Create a new WhatsApp group
  • get_group_participants: List members in a group

API Access

Access the server through the FastMCP interface:

  • WebSocket: ws://localhost:8000/mcp
  • HTTP: 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": {}}'

Integrating with Claude

Using Claude CLI

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

Using Claude Desktop

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"]
  }
}

Using WhatsApp Functions with Claude

Once connected, you can ask Claude to perform WhatsApp tasks:

Authentication

Login to WhatsApp

Messaging

Send the "Hello" message to John Doe

Debugging

If you encounter issues:

  • Increase verbosity: whatsapp-mcp --debug
  • Use the MCP inspector: npx @modelcontextprotocol/inspector whatsapp-mcp
  • Access FastMCP web interface: http://localhost:8000
  • Check Claude Desktop logs (typically in ~/Library/Logs/Claude/ on macOS)

How to install this MCP server

For Claude Code

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.

For Cursor

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.

Adding an MCP server to Cursor globally

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": []
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.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

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later