Whatsapp MCP README

The full upstream README, mirrored for reference. Install config, tool schemas, adoption signals and our own overview live on the Whatsapp MCP listing page.

WhatsApp MCP Logo

WhatsApp MCP

Human-in-the-Loop for AI Agents via WhatsApp

npm version License: ISC MCP Smithery


This is an MCP (Model Context Protocol) server that enables AI agents (like Claude or Cursor) to interact directly with you via WhatsApp. It bridges the gap between your autonomous AI and your phone, allowing for runtime confirmations, permission requests, or simple status updates while you are away from your computer.

  • AI agent messaging
  • AI agent confirmations
  • Agent interrupt system
  • AI alerts
  • MCP server
  • Cursor MCP
  • Claude Desktop MCP
  • AI notifications

Perfect for

  • Cursor
  • Claude Desktop
  • Claude Code
  • OpenCode
  • Codex
  • Autonomous AI workflows

Example

AI: Deploy to production?

WhatsApp: [YES] [NO]

You: YES

Agent continues.

How It Works

  1. Your MCP client calls a WhatsApp tool over stdio.
  2. If the server is not authenticated yet, it starts WhatsApp authentication automatically.
  3. The server either:
    • returns a QR image when no pairing env is configured, or
    • returns a phone-number pairing code when pairing-code auth is configured
  4. After authentication, the agent can:
    • send one-way notifications with send_message
    • ask blocking questions with ask_question
    • inspect status with get_status
    • poll unsolicited inbound messages with get_incoming_messages

🚀 Quick Start (NPX)

Since this package is published to NPM, you can run it directly via npx in your MCP configuration.

Cursor / Claude Configuration

Add this to your MCP configuration file:

config.json
{
  "mcpServers": {
    "whatsapp-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@mhrj/whatsapp-mcp"
      ],
      "env": {
        "WHATSAPP_TARGET_NUMBER": "1234567890@s.whatsapp.net"
      }
    }
  }
}

Required and Optional Environment Variables

  • WHATSAPP_TARGET_NUMBER

    • Required
    • Default WhatsApp chat JID used by send_message and ask_question
    • Format: 1234567890@s.whatsapp.net
  • WHATSAPP_ALLOWED_NUMBERS

    • Optional
    • Comma-separated list of users allowed to answer when the target is a group or shared chat
    • Format: 111@s.whatsapp.net,222@s.whatsapp.net
  • AGENT_WHATAPP_PHONE_NUMBER

    • Optional
    • If set, the server uses WhatsApp phone-number pairing code auth instead of QR as the default auth path
    • Format: country code plus number, digits preferred, for example 1234567890
  • WHATSAPP_PAIRING_PHONE_NUMBER

    • Optional deprecated alias for AGENT_WHATAPP_PHONE_NUMBER
    • Supported only for backward compatibility with older configs

Allowed senders: WHATSAPP_TARGET_NUMBER is the default chat. Group targets (...@g.us) require WHATSAPP_ALLOWED_NUMBERS; the server refuses to start without it. For a group, list the individual sender JIDs allowed to control agent replies.

Troubleshooting npx: executable file not found in $PATH or env: node: No such file or directory: If your IDE/Agent complains it cannot find npx or node, it's because GUI apps (like Cursor) don't inherit your terminal's $PATH. To fix this, explicitly pass your PATH in the MCP env config.

json
      "env": {
        "PATH": "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin",
        "WHATSAPP_TARGET_NUMBER": "1234567890@s.whatsapp.net"
      }

Configuration Examples

QR-based auth:

config.json
{
  "mcpServers": {
    "whatsapp-mcp": {
      "command": "npx",
      "args": ["-y", "@mhrj/whatsapp-mcp"],
      "env": {
        "PATH": "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin",
        "WHATSAPP_TARGET_NUMBER": "1234567890@s.whatsapp.net"
      }
    }
  }
}

Phone-number pairing-code auth:

config.json
{
  "mcpServers": {
    "whatsapp-mcp": {
      "command": "npx",
      "args": ["-y", "@mhrj/whatsapp-mcp"],
      "env": {
        "PATH": "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin",
        "WHATSAPP_TARGET_NUMBER": "1234567890@s.whatsapp.net",
        "AGENT_WHATAPP_PHONE_NUMBER": "1234567890"
      }
    }
  }
}

Authentication (first time only)

The very first time you use the MCP server, it needs to authenticate with WhatsApp:

QR mode:

  1. Call the connect tool via your Agent, or just use any WhatsApp tool normally. If the session is not authenticated yet, the server will trigger authentication automatically.
  2. The tool result will return the QR code image directly in MCP content so modern clients can render it inline.
  3. If your client does not render inline images, the server also tries to write a local fallback HTML page under ~/.whatsapp-mcp/qr.html.
  4. Open WhatsApp on your phone -> Linked Devices -> Link a Device, and scan the QR.
  5. The authentication session is saved to your home directory (~/.whatsapp-mcp/baileys_auth_info), so you don't need to scan it again across restarts.

Pairing-code mode:

  1. Set AGENT_WHATAPP_PHONE_NUMBER in the MCP server env.
  2. Call connect or use any WhatsApp tool normally.
  3. The tool result will return a pairing code in text.
  4. Open WhatsApp on your phone -> Linked Devices -> Link with phone number.
  5. Enter the pairing code from the MCP tool result.

Notes:

  • connect also accepts optional phoneNumber / phone_number arguments for clients that want to request a one-off pairing code explicitly.
  • For broad AI-agent compatibility, using AGENT_WHATAPP_PHONE_NUMBER in server env is the preferred setup.
  • If AGENT_WHATAPP_PHONE_NUMBER is not configured, the server falls back to QR-based linking automatically.

Remote "Auto-Pilot" Workflow (Skip IDE Prompts)

To make your AI agent run fully autonomously and only ask for permissions/guidance via WhatsApp (allowing you to step away from your computer):

  1. Remove IDE Security Blockers: When your agent (like Cursor or Claude) asks for permission to run a command or read a file, select Always Allow (or enable "yolo" mode in settings). This gives the agent the mechanical freedom to operate without pausing indefinitely for a UI click.
  2. Add a .cursorrules (or system prompt) file: You must explicitly instruct the AI to use WhatsApp whenever it reaches a logical decision point. Create a .cursorrules file in your project root with this exact prompt:
markdown
# Human-in-the-Loop via WhatsApp
You are connected to the user via the `whatsapp-mcp` server. 
Whenever you are about to make significant/destructive changes, run a deployment, or whenever you need the user's permission/opinion to proceed with a plan, you MUST use the `ask_question` tool to ask the user on WhatsApp. 
DO NOT simply ask for confirmation in the IDE chat interface. You must wait for the `ask_question` tool to return the user's WhatsApp reply before proceeding with your task.

With these two steps, the AI will proactively proactively use the ask_question tool to beam its logical permission requests directly to your phone instead of freezing in the IDE.

Features & Tools

  • connect: Connects to the WhatsApp network. If not logged in, returns either:
    • a native QR image in the tool result, with optional local HTML fallback, or
    • a phone-number pairing code when pairing auth is configured
  • disconnect: Completely logs out of WhatsApp and invalidates the session credentials.
  • send_message: Sends a one-way notification. Supports optional WhatsApp markdown mapping (*bold*). If the server is not connected yet, it auto-triggers authentication first.
  • ask_question: Sends a prompt and blocks execution until a reply is received (with a timeout). Concurrent questions are smartly queued and tagged with references. If the server is not connected yet, it auto-triggers authentication first.
  • get_incoming_messages: Polls unsolicited inbound WhatsApp messages so agents that do not support server-side sampling can still retrieve them.
  • get_status: Provides agent connection state monitoring, including auth state such as connected, connecting, qr_pending, or pairing_pending.
  • Server instructions + prompt: The server exports built-in workflow instructions and a whatsapp-autopilot prompt so clients can guide agents toward connect-first and WhatsApp-first behavior.

Replies match by WhatsApp's quoted-message reference or an initial [Qn] label. Unquoted replies fall back to FIFO order, so quote or include the label when multiple questions are pending or after a timeout.

Recommended Agent Usage

For best results, instruct your agent to follow these rules:

  1. Use ask_question for confirmations, approvals, and missing input.
  2. Use send_message for one-way updates.
  3. Use get_status when the connection state is unclear.
  4. If connect returns auth guidance, complete auth first and retry the original tool.
  5. Do not ask the user in IDE chat if the question should go to WhatsApp.

Local Development

Install and build:

Terminal
npm install
npm run build

Run from source:

Terminal
npm run dev

Run built server:

Terminal
npm run start

Run unit tests:

Terminal
npm test

Run local MCP smoke test:

Terminal
npm run test:mcp:local

Run end-to-end MCP test:

Terminal
npm run test:mcp:e2e

Local MCP Config Example

config.json
{
  "mcpServers": {
    "whatsapp-mcp-local": {
      "command": "node",
      "args": ["/path/to/whatsapp-mcp/build/index.js"],
      "env": {
        "PATH": "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin",
        "WHATSAPP_TARGET_NUMBER": "1234567890@s.whatsapp.net",
        "AGENT_WHATAPP_PHONE_NUMBER": "1234567890"
      }
    }
  }
}

Operational Notes

  • The server keeps stdout clean for MCP protocol traffic. Logs go to stderr.
  • Auth session files are stored under ~/.whatsapp-mcp/baileys_auth_info.
  • QR fallback file is written to ~/.whatsapp-mcp/qr.html.
  • disconnect clears the saved auth session so the next auth requires a fresh QR or pairing flow.
  • Unsolicited inbound messages can be polled with get_incoming_messages for clients that do not handle passive MCP messages well.

Known Limitations

  • First-time WhatsApp auth can still fail due to WhatsApp-side or Baileys-side conditions outside this repo.
  • Real device delivery receipts are best-effort and depend on WhatsApp network behavior.
  • Pairing-code auth depends on current Baileys support and WhatsApp’s current linked-device behavior.

License

This project is licensed under the ISC License.

Third-Party Licenses

This project utilizes the following open-source libraries:


Discoverability keywords

  • Human in the loop AI
  • AI approvals
  • Runtime approvals
  • Agent notifications
  • Agent approval workflow
  • Cursor WhatsApp integration
  • Claude WhatsApp integration
  • Autonomous agents
  • Cursor power users
  • Remote workers

What problem does this solve?

  • AI agents often get blocked waiting for approvals/questions when you step away from the IDE.
  • WhatsApp MCP notifies you and collects confirmations from your phone so agents can continue safely.

Who it's for

  • Cursor agent / Claude Desktop users
  • Solo builders shipping agentic workflows
  • DevOps & automation teams needing runtime approvals