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.
Get the Code:
git clone [repository-url]
cd twilio-whatsapp-fastmcp
Create a Virtual Environment:
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
Install Dependencies:
pip install twilio python-dotenv pydantic-settings fastmcp
Or using FastMCP's installer:
fastmcp install whatsapp_server.py
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:
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.
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!"
}
}
You can test sending messages directly with Twilio API (without FastMCP):
twilio_test.py
script to use your recipient's numberpython twilio_test.py
This sends a test message ("Is this working?") to verify your Twilio setup works correctly.
.env
fileTo 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.
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": {
"twilio-whatsapp": {
"command": "python",
"args": [
"/home/rj/Code/mcp-generated/whatsapp_server.py"
]
}
}
}
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": {
"twilio-whatsapp": {
"command": "python",
"args": [
"/home/rj/Code/mcp-generated/whatsapp_server.py"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect