PyWA MCP Server
Provides comprehensive WhatsApp Business API functionality with 18 tools for sending messages, media, interactive buttons/lists, templates, reactions, and managing message status through the PyWA library.
README
PyWA MCP Server
A comprehensive Model Context Protocol (MCP) server that exposes full WhatsApp Business API functionality using the PyWA library.
Features
This MCP server provides 18 WhatsApp tools organized into four categories:
Messaging Tools (12)
- Text & Media:
send_message,send_image,send_video,send_document,send_audio,send_sticker - Location & Contacts:
send_location,request_location,send_contact - Interactions:
send_reaction,remove_reaction,upload_media
Interactive Tools (2)
- Interactive Messages:
send_message_with_buttons,send_message_with_list
Template Tools (2)
- Template Messaging:
send_template,get_templates
Status Tools (2)
- Message Status:
mark_message_as_read,indicate_typing
Setup
-
Install dependencies:
uv sync -
Configure WhatsApp credentials:
cp .env.example .env # Edit .env with your WhatsApp Cloud API credentials -
Run the server:
# Production mode uv run python server.py # Development mode with Web UI (recommended for testing) uv run fastmcp dev --ui-port 6275 server.py
Configuration
Set these environment variables:
WHATSAPP_PHONE_ID- Your WhatsApp Business phone number IDWHATSAPP_TOKEN- Your WhatsApp Cloud API access token
Get these from your Meta Developer Console.
Development & Testing
Web UI (Recommended for Development)
Test your WhatsApp tools interactively with the FastMCP Inspector:
uv run fastmcp dev --ui-port 6275 server.py
Open http://localhost:6275 in your browser to:
- View all 15+ WhatsApp tools
- Test messaging, buttons, lists, templates
- See real-time API calls and responses
- Debug with comprehensive error messages
Testing with Real WhatsApp
- Get WhatsApp Business API credentials from Meta Developer Console
- Add test phone numbers in your Meta Developer Console
- Use the Web UI to send messages to test numbers
- Verify messages appear in WhatsApp
Claude Desktop Integration
Quick Setup (One Command)
Install directly in Claude Desktop config:
{
"mcpServers": {
"pywa-whatsapp": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/Jem-HR/pywa-mcp-server.git",
"pywa-mcp-server"
],
"env": {
"WHATSAPP_PHONE_ID": "your_phone_id",
"WHATSAPP_TOKEN": "your_token"
}
}
}
}
This automatically downloads and runs the server without manual installation.
Manual Configuration
-
Locate Claude Desktop config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
-
Add server configuration:
{ "mcpServers": { "pywa-whatsapp": { "command": "uv", "args": [ "run", "python", "/path/to/pywa-mcp-server/server.py" ], "env": { "WHATSAPP_PHONE_ID": "your_phone_number_id", "WHATSAPP_TOKEN": "your_whatsapp_cloud_api_token" } } } } -
Restart Claude Desktop
-
Verify connection: Look for the 🔨 hammer icon in Claude Desktop
Using WhatsApp Tools in Claude Desktop
Once connected, you can ask Claude to:
Send Messages:
Send a WhatsApp message to +1234567890 saying "Hello from Claude!"
Create Interactive Buttons:
Send a WhatsApp message with buttons asking "Are you available?"
with Yes/No options to +1234567890
Build Menu Lists:
Create a WhatsApp menu for a restaurant with sections for Main Courses
and Beverages, send to +1234567890
Show Typing Indicators:
Show typing indicator for WhatsApp message ID wamid.XXX to let the user
know I'm preparing a response
Send Media:
Send an image from URL https://example.com/image.jpg with caption
"Check this out!" to +1234567890
Use Templates:
Send the "welcome_message" template in English to +1234567890
Available WhatsApp Tools in Claude
Claude has access to these WhatsApp capabilities:
📝 Messaging (12 tools):
send_message- Text messages with headers/footerssend_image- Images with captionssend_video- Videos with captionssend_document- Files with custom namessend_audio- Audio messagessend_sticker- WebP stickerssend_location- GPS coordinatesrequest_location- Ask user for locationsend_contact- Contact cardssend_reaction- Emoji reactionsremove_reaction- Remove reactionsupload_media- Upload files to WhatsApp
🎛️ Interactive (2 tools):
send_message_with_buttons- Up to 3 reply buttonssend_message_with_list- Selection lists with sections
📋 Templates (2 tools):
send_template- Pre-approved template messagesget_templates- List available templates
⚡ Status (2 tools):
mark_message_as_read- Mark messages as readindicate_typing- Show typing indicator
Architecture
The server uses a modular architecture:
- server.py - Main MCP server using FastMCP framework
- tools/messaging.py - Text, media, location, contact, and reaction tools
- tools/interactive.py - Button, list, catalog, and flow message tools
- tools/templates.py - Template messaging and authentication tools
All tools follow consistent patterns:
- Async implementation for optimal performance
- Comprehensive error handling with success/error responses
- Direct mapping to PyWA library methods
- Full type safety and parameter validation
Tool Examples
send_message
Send a text message to a WhatsApp user.
{
"to": "+1234567890",
"text": "Hello from PyWA MCP Server!",
"preview_url": true,
"reply_to_message_id": "optional_message_id"
}
send_button_message
Send an interactive message with reply buttons.
{
"to": "+1234567890",
"text": "Choose an option:",
"buttons": [
{"id": "option1", "title": "Option 1"},
{"id": "option2", "title": "Option 2"}
],
"header": "Quick Actions",
"footer": "Select one option"
}
send_template
Send a pre-approved template message.
{
"to": "+1234567890",
"template": "hello_world",
"language": "en",
"components": [
{
"type": "body",
"parameters": [
{"type": "text", "text": "John Doe"}
]
}
]
}
Troubleshooting
Common Issues
❌ "Missing required environment variables"
- Ensure
.envfile exists withWHATSAPP_PHONE_IDandWHATSAPP_TOKEN - Check values are correct from Meta Developer Console
❌ "Cannot import name 'X' from pywa.types"
- Run
uv syncto update dependencies - PyWA version must be >=3.0.0
❌ "401 Unauthorized" from WhatsApp API
- Verify your
WHATSAPP_TOKENis current and has proper permissions - Check token hasn't expired in Meta Developer Console
❌ Claude Desktop doesn't show tools
- Check
claude_desktop_config.jsonsyntax is valid JSON - Ensure file paths are absolute, not relative
- Restart Claude Desktop after config changes
- Look for 🔨 hammer icon to confirm connection
❌ "Typing indicator failed"
indicate_typingrequires a valid message ID from an incoming message- Cannot use with arbitrary message IDs - must be from actual WhatsApp messages received
Debug Mode
Enable detailed logging by setting environment variable:
export PYTHONPATH=/path/to/pywa-mcp-server
LOGLEVEL=DEBUG uv run python server.py
Getting Help
- Check the PyWA Documentation for WhatsApp API details
- Review Meta Developer Console for API setup
- Test tools individually using the Web UI before Claude Desktop integration
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。