Skip to main content
Glama
PyWA MCP Server
by Jem-HR

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

Related MCP server: WAHA MCP Server

Setup

  1. Install dependencies:

    uv sync
  2. Configure WhatsApp credentials:

    cp .env.example .env
    # Edit .env with your WhatsApp Cloud API credentials
  3. 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 ID

  • WHATSAPP_TOKEN - Your WhatsApp Cloud API access token

Get these from your Meta Developer Console.

Development & Testing

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

  1. Get WhatsApp Business API credentials from Meta Developer Console

  2. Add test phone numbers in your Meta Developer Console

  3. Use the Web UI to send messages to test numbers

  4. 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

  1. Locate Claude Desktop config file:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

    • Windows: %APPDATA%\Claude\claude_desktop_config.json

  2. 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"
          }
        }
      }
    }
  3. Restart Claude Desktop

  4. 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/footers

  • send_image - Images with captions

  • send_video - Videos with captions

  • send_document - Files with custom names

  • send_audio - Audio messages

  • send_sticker - WebP stickers

  • send_location - GPS coordinates

  • request_location - Ask user for location

  • send_contact - Contact cards

  • send_reaction - Emoji reactions

  • remove_reaction - Remove reactions

  • upload_media - Upload files to WhatsApp

🎛️ Interactive (2 tools):

  • send_message_with_buttons - Up to 3 reply buttons

  • send_message_with_list - Selection lists with sections

📋 Templates (2 tools):

  • send_template - Pre-approved template messages

  • get_templates - List available templates

⚡ Status (2 tools):

  • mark_message_as_read - Mark messages as read

  • indicate_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 .env file exists with WHATSAPP_PHONE_ID and WHATSAPP_TOKEN

  • Check values are correct from Meta Developer Console

❌ "Cannot import name 'X' from pywa.types"

  • Run uv sync to update dependencies

  • PyWA version must be >=3.0.0

❌ "401 Unauthorized" from WhatsApp API

  • Verify your WHATSAPP_TOKEN is current and has proper permissions

  • Check token hasn't expired in Meta Developer Console

❌ Claude Desktop doesn't show tools

  • Check claude_desktop_config.json syntax 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_typing requires 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

License

MIT

Available Tools

18 tools
get_templatesB

Get list of available WhatsApp templates.

Args: limit: Maximum number of templates to return (default: 100) name: Optional template name filter

Returns: Dictionary with templates list

Inputs: limit, name. Returns: object

indicate_typingA

Show typing indicator to WhatsApp user.

This marks a message as read and displays a typing indicator to show the user that you are preparing a response. Best practice when it will take a few seconds to respond.

IMPORTANT NOTES:

  • Typing indicator lasts max 25 seconds or until you send a message

  • Only use if you are actually going to respond

  • Will be dismissed when you send the next message

  • Improves user experience for delayed responses

EXAMPLE: { "message_id": "wamid.HBgNMjc2NTY4NjY5MDUVAgARGBI5QTNDMEM3RjVBMzY2Q0Y4AA==" }

Args: message_id: The WhatsApp message ID to respond to (from incoming message) sender: Optional phone ID (defaults to client's phone ID)

Returns: Dictionary with success status

Inputs: message_id (required), sender. Returns: object

mark_message_as_readC

Mark a message as read.

Args: message_id: The WhatsApp message ID to mark as read sender: Optional phone ID

Returns: Dictionary with success status

Inputs: message_id (required), sender. Returns: object

remove_reactionB

Remove a reaction from a message.

Args: to: Phone number or WhatsApp ID message_id: ID of message to remove reaction from sender: Optional sender phone ID

Returns: Dictionary with success status

Inputs: to (required), message_id (required), sender. Returns: object

request_locationC

Request user's location.

Args: to: Phone number or WhatsApp ID text: Message text asking for location reply_to_message_id: Message ID to reply to

Returns: Dictionary with success status and message ID

Inputs: to (required), text (required), reply_to_message_id. Returns: object

send_audioB

Send an audio message.

Args: to: Phone number or WhatsApp ID audio: Audio URL or media ID reply_to_message_id: Message ID to reply to

Returns: Dictionary with success status and message ID

Inputs: to (required), audio (required), reply_to_message_id. Returns: object

send_contactB

Send a contact card.

Args: to: Phone number or WhatsApp ID contact_name: Name of the contact contact_phone: Phone number of the contact reply_to_message_id: Message ID to reply to

Returns: Dictionary with success status and message ID

Inputs: to (required), contact_name (required), contact_phone (required), reply_to_message_id. Returns: object

send_documentC

Send a document message.

Args: to: Phone number or WhatsApp ID document: Document URL or media ID filename: Optional filename for the document caption: Optional document caption footer: Optional footer text reply_to_message_id: Message ID to reply to

Returns: Dictionary with success status and message ID

Inputs: to (required), document (required), filename, caption, +2 more. Returns: object

send_imageB

Send an image message.

Args: to: Phone number or WhatsApp ID image: Image URL or media ID caption: Optional image caption footer: Optional footer text reply_to_message_id: Message ID to reply to

Returns: Dictionary with success status and message ID

Inputs: to (required), image (required), caption, footer, +1 more. Returns: object

send_locationB

Send a location message.

Args: to: Phone number or WhatsApp ID latitude: Latitude of the location longitude: Longitude of the location name: Optional location name address: Optional location address reply_to_message_id: Message ID to reply to

Returns: Dictionary with success status and message ID

Inputs: to (required), latitude (required), longitude (required), name, +2 more. Returns: object

send_messageA

Send a text message to a WhatsApp user.

Args: to: Phone number (with country code) or WhatsApp ID text: The text message content header: Optional header text (for interactive messages) footer: Optional footer text (for interactive messages) preview_url: Whether to show URL previews (default False) reply_to_message_id: Message ID to reply to

Returns: Dictionary with success status and message ID

Inputs: to (required), text (required), header, footer, +2 more. Returns: object

send_message_with_buttonsA

Send a message with reply buttons (up to 3).

CONSTRAINTS:

  • Maximum 3 buttons per message

  • Button title: max 20 characters

  • Button ID (callback_data): max 256 characters

  • Header text: max 60 characters (if provided)

  • Footer text: max 60 characters (if provided)

EXAMPLE: { "to": "+1234567890", "text": "Choose an option:", "buttons": [ {"id": "option_1", "title": "Yes"}, {"id": "option_2", "title": "No"}, {"id": "option_3", "title": "Maybe"} ], "header": "Quick Question", "footer": "Select one option" }

Args: to: Phone number (with country code) or WhatsApp ID text: Message body text (main message content) buttons: List of buttons with 'id' and 'title' keys (max 3) header: Optional header text (appears above main text) footer: Optional footer text (appears below buttons) reply_to_message_id: Message ID to reply to

Returns: Dictionary with success status and message ID

Inputs: to (required), text (required), buttons (required), header, +2 more. Returns: object

send_message_with_listA

Send a message with a selection list.

CONSTRAINTS:

  • Maximum 10 sections per list

  • Maximum 10 rows total across all sections

  • Button text: max 20 characters

  • Section title: max 24 characters

  • Row title: max 24 characters

  • Row description: max 72 characters

  • Row ID (callback_data): max 200 characters

  • Header text: max 60 characters (if provided)

  • Footer text: max 60 characters (if provided)

EXAMPLE: { "to": "+1234567890", "text": "Choose from our menu:", "button_text": "View Menu", "sections": [ { "title": "Main Courses", "rows": [ {"id": "burger", "title": "Burger", "description": "Beef burger with fries"}, {"id": "pizza", "title": "Pizza", "description": "Margherita pizza"} ] }, { "title": "Beverages", "rows": [ {"id": "coke", "title": "Coca Cola", "description": "Cold refreshing drink"}, {"id": "water", "title": "Water", "description": "Still or sparkling"} ] } ], "header": "Restaurant Menu", "footer": "All items available today" }

Args: to: Phone number (with country code) or WhatsApp ID
text: Message body text (main message content) button_text: Text shown on the list button (triggers the list) sections: List of sections, each with 'title' and 'rows' arrays header: Optional header text (appears above main text) footer: Optional footer text (appears below list button) reply_to_message_id: Message ID to reply to

Returns: Dictionary with success status and message ID

Inputs: to (required), text (required), button_text (required), sections (required), +3 more. Returns: object

send_reactionB

Send a reaction to a message.

Args: to: Phone number or WhatsApp ID emoji: Reaction emoji message_id: ID of message to react to sender: Optional sender phone ID

Returns: Dictionary with success status

Inputs: to (required), emoji (required), message_id (required), sender. Returns: object

send_stickerB

Send a sticker message.

Args: to: Phone number or WhatsApp ID sticker: Sticker URL or media ID (must be webp format) reply_to_message_id: Message ID to reply to

Returns: Dictionary with success status and message ID

Inputs: to (required), sticker (required), reply_to_message_id. Returns: object

send_templateA

Send a WhatsApp template message.

Args: to: Phone number or WhatsApp ID name: Template name/ID language: Template language code (default: en) params: Optional template parameters (header, body, button components) reply_to_message_id: Message ID to reply to

Returns: Dictionary with success status and message ID

Inputs: to (required), name (required), language, params, +1 more. Returns: object

send_videoB

Send a video message.

Args: to: Phone number or WhatsApp ID video: Video URL or media ID caption: Optional video caption footer: Optional footer text reply_to_message_id: Message ID to reply to

Returns: Dictionary with success status and message ID

Inputs: to (required), video (required), caption, footer, +1 more. Returns: object

upload_mediaA

Upload media file to WhatsApp servers.

Args: media_path: Path to media file mime_type: Optional MIME type

Returns: Dictionary with media ID

Inputs: media_path (required), mime_type. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 18 tools

    Disambiguation4/5

    Most tools have distinct purposes, such as sending different media types (audio, image, video) or handling specific interactions (reactions, typing indicators). However, there is some potential overlap between send_message, send_message_with_buttons, and send_message_with_list, as all involve sending text-based messages with varying interactive elements, which could cause confusion if the agent doesn't carefully read descriptions.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern with snake_case, such as send_message, upload_media, and mark_message_as_read. This uniformity makes the tool set predictable and easy to navigate, with no deviations in naming conventions.

    Tool Count4/5

    With 18 tools, the count is slightly high but reasonable for a WhatsApp API server that needs to cover various message types, media uploads, and interaction features. It's well-scoped for the domain, though it could be streamlined by grouping similar send functions, but each tool earns its place for specific use cases.

    Completeness5/5

    The tool set provides comprehensive coverage for WhatsApp messaging, including sending all media types (text, audio, image, video, document, sticker, contact, location), handling templates, reactions, typing indicators, read receipts, and media uploads. There are no obvious gaps; it supports full CRUD-like operations for message interactions and user engagement.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Enables WhatsApp Business messaging through Evolution API with support for creating instances, sending messages using dynamic templates, and managing contacts and groups. Includes 10+ predefined message templates for common business scenarios like order confirmations, appointment reminders, and promotional messages.
      25
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      Enables AI assistants to interact with WhatsApp through the WAHA (WhatsApp HTTP API) platform. Supports chat management, message operations including sending/receiving messages, and marking chats as read.
      52
      11
      ISC
    • A
      license
      B
      quality
      C
      maintenance
      Bridges the WhatsApp HTTP API with AI assistants to enable full control over messaging, chat management, and interactive workflows through 63 specialized tools. It allows users to automate WhatsApp tasks and receive real-time AI feedback directly on their mobile devices.
      63
      6
      MIT