Skip to main content
Glama
WhatsApp MCP Server
by ekaksher

WhatsApp MCP Server

A local Python MCP server that automates WhatsApp Web through Playwright and exposes a small set of WhatsApp tools over stdio.

What this project does

  • Runs as an MCP server over stdio.

  • Uses Python instead of Node.

  • Uses Playwright with Chromium.

  • Persists the WhatsApp Web session under ./data/profile.

Related MCP server: MCP Playwright Server

Current tools

  • get_auth_status

  • wait_until_ready

  • list_recent_chats

  • send_message

  • get_recent_messages

  • shutdown_browser

send_message and get_recent_messages accept either phone_number or chat_name. chat_name works by searching the existing WhatsApp sidebar/chat list. For larger get_recent_messages requests, the server attempts to scroll upward and load older visible history before extracting messages.

Important limitations

  • This project automates WhatsApp Web, not the official WhatsApp Business API.

  • WhatsApp Web markup changes regularly, so selectors may need maintenance.

  • You should use a dedicated account and review WhatsApp's terms before production use.

  • The repository is initialized as a Git repository on the main branch.

  1. Copy the environment file:

cp .env.example .env
  1. Create a virtual environment:

python3 -m venv .venv
source .venv/bin/activate
  1. Install dependencies:

pip install -r requirements.txt
python3 -m playwright install chromium
  1. For local login, set WHATSAPP_HEADLESS=false in .env.

  2. Start the server locally:

PYTHONPATH=src python3 -m whatsapp_mcp.main
  1. From your MCP client, call get_auth_status.

  2. If a browser window opens, scan the QR code directly in that window.

  3. Call wait_until_ready.

Example MCP client configuration

For Claude Desktop or another MCP client, local Python execution is the recommended configuration.

{
  "mcpServers": {
    "whatsapp": {
      "command": "/absolute/path/to/project/.venv/bin/python3",
      "args": [
        "-m",
        "whatsapp_mcp.main"
      ],
      "cwd": "/absolute/path/to/project",
      "env": {
        "PYTHONPATH": "/absolute/path/to/project/src",
        "WHATSAPP_HEADLESS": "false",
        "WHATSAPP_PROFILE_DIR": "/absolute/path/to/project/data/profile"
      }
    }
  }
}

Tool examples

get_auth_status

{
  "name": "get_auth_status",
  "arguments": {}
}

send_message

{
  "name": "send_message",
  "arguments": {
    "chat_name": "John Appleseed",
    "text": "Hello from the WhatsApp MCP server"
  }
}

get_recent_messages

{
  "name": "get_recent_messages",
  "arguments": {
    "chat_name": "John Appleseed",
    "count": 10
  }
}

Project structure

.
├── docs/
├── src/whatsapp_mcp/
├── .env.example
└── pyproject.toml

Documentation

Available Tools

6 tools
get_auth_statusB

Open WhatsApp Web if needed and report whether login is complete.

Inputs: no named parameters.

get_recent_messagesC

Read recent messages from a chat identified by either a phone number or a chat name.

Inputs: phone_number, chat_name, limit, count.

list_recent_chatsC

List the most recent chats visible in WhatsApp Web.

Inputs: limit.

send_messageC

Send a WhatsApp message using either a phone number or an existing chat name.

Inputs: text (required), phone_number, chat_name.

shutdown_browserA

Close the browser context and stop the WhatsApp automation session.

Inputs: no named parameters.

wait_until_readyB

Wait until WhatsApp Web is fully authenticated and ready for use.

Inputs: timeout_seconds.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no overlap: authentication status, message retrieval, chat listing, message sending, session shutdown, and readiness waiting. The descriptions make it unambiguous which tool to use for each task.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern (e.g., get_auth_status, send_message, shutdown_browser) with snake_case throughout. The naming is predictable and readable across all six tools.

    Tool Count5/5

    Six tools is well-scoped for a WhatsApp automation server, covering core operations like authentication, messaging, chat management, and session control without being too sparse or bloated. Each tool earns its place in the workflow.

    Completeness4/5

    The toolset covers essential WhatsApp Web operations (authentication, messaging, chat listing) and session lifecycle (shutdown, readiness). Minor gaps might include advanced features like media handling or group management, but core workflows are well-supported.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that enables AI-powered browser automation, web scraping, and testing using Playwright across Chromium, Firefox, and WebKit. It allows users to perform actions like navigation, clicking, typing, and taking screenshots through natural language interfaces.
      24 npm
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      An MCP server that enables interaction with WhatsApp using the Baileys library and Streamable HTTP transport. It supports managing contacts, chats, and messages, while providing a web admin UI for QR code authentication and media handling.
      4
      28
      5
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      An MCP server that enables AI to control WhatsApp Web via Puppeteer Stealth for reading and sending messages. It features human-like interaction patterns and anti-ban protections to securely manage chats and communications through natural language.
      3
      13 npm
      MIT