WhatsApp Messenger MCP server

Enables sending formatted WhatsApp messages to specified recipients through Twilio's API for automated notifications and customer service workflows.
Back to servers
Setup instructions
Provider
wubbyweb
Release date
May 07, 2025
Language
Python
Stats
1 star

The Twilio WhatsApp FastMCP Server provides a simple way to send WhatsApp messages using the Twilio API through a Model Context Protocol (MCP) interface. This allows AI systems and other clients to send WhatsApp messages programmatically via a standardized tool interface.

Setup and Installation

Prerequisites

  • A Twilio account with WhatsApp capabilities (Sandbox or purchased number)
  • Python 3.6+

Installation Steps

  1. Get the Code:

    git clone [repository-url]
    cd twilio-whatsapp-fastmcp
    
  2. Create a Virtual Environment:

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
    
  3. Install Dependencies:

    pip install twilio python-dotenv pydantic-settings fastmcp
    

    Or using FastMCP's installer:

    fastmcp install whatsapp_server.py
    
  4. Configure Environment Variables: Create a .env file in the project root:

    TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    TWILIO_AUTH_TOKEN=your_auth_token_here
    TWILIO_WHATSAPP_NUMBER=+14155238886
    

    Important notes:

    • Replace placeholders with your actual Twilio credentials
    • Make sure the WhatsApp number is in E.164 format (with country code)
    • For trial accounts, you must register recipient numbers in the Twilio Sandbox

Usage

Running the FastMCP Server

Start the server to make the send_whatsapp tool available:

python whatsapp_server.py

The server listens for requests (by default via stdio) and processes tool calls from FastMCP clients.

Tool Interface

FastMCP clients can call the send_whatsapp tool with these parameters:

{
  "tool_name": "send_whatsapp",
  "arguments": {
    "to_number": "whatsapp:+15551234567",
    "message": "Hello from the FastMCP server!"
  }
}

Testing Direct Twilio Integration

You can test sending messages directly with Twilio API (without FastMCP):

  1. Modify the twilio_test.py script to use your recipient's number
  2. Run the test script:
    python twilio_test.py
    

This sends a test message ("Is this working?") to verify your Twilio setup works correctly.

Troubleshooting

  • Message not delivered: Ensure recipient numbers are registered in your Twilio Sandbox
  • Authentication errors: Double-check your Account SID and Auth Token in the .env file
  • Format errors: Ensure phone numbers use the correct format (E.164 with country code)

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 "twilio-whatsapp" '{"command":"python","args":["/home/rj/Code/mcp-generated/whatsapp_server.py"]}'

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": {
        "twilio-whatsapp": {
            "command": "python",
            "args": [
                "/home/rj/Code/mcp-generated/whatsapp_server.py"
            ]
        }
    }
}

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": {
        "twilio-whatsapp": {
            "command": "python",
            "args": [
                "/home/rj/Code/mcp-generated/whatsapp_server.py"
            ]
        }
    }
}

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