Skip to main content
Glama
whatsapp-mcp

whatsapp-mcp

by OmarYousef95

whatsapp-mcp

An MCP server for personal WhatsApp accounts. Lets Claude (or any MCP client) send WhatsApp messages on your behalf — no browser automation, no Business API, no Meta approval process. Pairs with your phone exactly like WhatsApp Web does: scan one QR, done.

Built on Baileys, which speaks WhatsApp's WebSocket protocol directly.

Learning MCP? This repo doubles as a small, heavily-commented example server — see LEARNING.md and start reading at src/server.ts.

Tools

Tool

What it does

send_message

Send a text message, a local file (image/video/document, optionally with a caption), or both to a contact name, a phone number, or me (your self-chat)

search_contacts

Find contacts by name fragment, returns names + numbers

get_connection_status

Connection/pairing state, contact-sync count — for diagnosing before sending

Safety by design — born from a real incident where an automation picked the wrong "Omar":

  • A contact name must match exactly one saved contact (case-insensitive). Zero or several matches → the tool refuses and lists candidates instead of guessing.

  • Raw phone numbers are verified to exist on WhatsApp before anything is sent.

  • Every send confirms back exactly who received the message (name + number).

Related MCP server: personal-whatsapp-mcp

Setup

Requires Node.js ≥ 20.

git clone https://github.com/OmarYousef95/whatsapp-mcp.git
cd whatsapp-mcp
npm install && npm run build

# one-time pairing: prints a QR in your terminal
node dist/index.js login

# QR won't scan (some terminal fonts distort it)? Use a typed pairing code instead:
node dist/index.js login +962791234567   # your own number, international format

Scan the QR with your phone (WhatsApp → Settings → Linked Devices → Link a Device). The session persists in ~/.whatsapp-mcp/ — you won't need to scan again unless you unlink the device.

No terminal handy? If you skip login and just call a tool from Claude, the error response includes the QR so you can scan it straight from the chat.

Add to Claude Code

claude mcp add whatsapp -- node /path/to/whatsapp-mcp/dist/index.js

Add to Claude Desktop

// claude_desktop_config.json
{
  "mcpServers": {
    "whatsapp": {
      "command": "node",
      "args": ["/path/to/whatsapp-mcp/dist/index.js"]
    }
  }
}

Then just ask: "send a WhatsApp to +962791234567 saying I'm running late" or "message me a reminder to buy milk".

Where your data lives

Path

Contents

~/.whatsapp-mcp/auth/

Your paired session keys (treat like a password — anyone with this folder can act as your WhatsApp)

~/.whatsapp-mcp/contacts.json

Local contact-name cache used for name → number resolution

Everything stays on your machine. Nothing is sent anywhere except to WhatsApp itself. To revoke access: delete ~/.whatsapp-mcp/auth/ or remove the linked device from your phone.

Honest caveats

  • Unofficial API. Baileys reimplements the WhatsApp Web protocol and is not endorsed by Meta. Using it technically violates WhatsApp's Terms of Service, and there is a small but real risk of account suspension. Use a personal tool responsibly: low volume, real conversations, never spam. If that risk worries you, pair a secondary number for testing first.

  • Contact names come from WhatsApp's sync and may take a moment to populate after first pairing. Phone numbers always work.

  • Baileys tracks a moving target; if WhatsApp changes the protocol, update the pinned dependency.

Development

npm test        # unit tests (contact resolution — the safety-critical bit)
npm run dev     # run the server from source
npm run login   # pairing flow from source

Roadmap

  • npm publish for true npx whatsapp-mcp one-liner install

MIT © Omar Yousef

Available Tools

5 tools
get_connection_statusWhatsApp connection statusA

Check whether the WhatsApp session is connected and paired. Returns the connection state, whether a QR scan is needed, and how many contacts are synced. Call this first if a send fails unexpectedly or before a batch of sends.

Inputs: no named parameters.

list_recent_chatsList recently active WhatsApp chatsA

List 1:1 WhatsApp chats with cached message activity, newest first. Each entry shows the contact name (or phone number if unknown), when the last message arrived, and a short preview. Use this to find out what's been happening without already knowing who to ask about, then call read_messages on whichever chat matters. Only reflects activity since this feature started running.

Inputs: limit.

read_messagesRead WhatsApp message historyA

Read cached message history for a WhatsApp chat: plain text and placeholders for media (e.g. "[image: caption]", "[voice note]"). recipient accepts the same forms as send_message: a contact name (exact match), a phone number, or 'me'. Only messages sent or received since this feature started running are available — there is no historical backfill. Group chats are not supported. Returns messages oldest-first with each line labeled 'You' or the contact's name.

Inputs: recipient (required), limit.

search_contactsSearch WhatsApp contactsA

Search the user's WhatsApp contacts by name (case-insensitive substring). Returns matching names with phone numbers. Use this to resolve the exact contact name before send_message when the user gives a partial or uncertain name.

Inputs: query (required).

send_messageSend WhatsApp messageA

Send a WhatsApp message from the user's personal account: plain text, a local file (image, video, or document), or a file with a caption. recipient accepts: a contact name (must match EXACTLY one saved contact, case-insensitive — if zero or several match, the call fails and lists the candidates so you can ask the user which one they meant), a phone number in international format (e.g. +962791234567), or 'me' to message the user's own self-chat. A phone number that isn't a saved contact is refused on the first call — the error asks you to confirm with the user, then call again with confirmed: true; this exists because a saved contact's name can collide with an unrelated WhatsApp account (e.g. someone's self-set display name), so a bare number deserves the same caution. Provide message, file_path, or both — when both are given, message becomes the file's caption. Media type is auto-detected from the file's extension; unrecognized extensions are sent as a generic document. The result confirms exactly who/what was sent. Never retry a failed send blindly — read the error, it tells you what to fix. Sending is a real-world side effect: unless the user explicitly dictated both the recipient and the exact message/file, confirm with them before calling this.

Inputs: recipient (required), message, confirmed, file_path.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool maps to a distinct action on a distinct resource: resolving contacts, sending, reading a specific chat, browsing recent chats, and checking session health. The one potential overlap between list_recent_chats and read_messages is explicitly resolved in the descriptions (browse then drill in). No tool pairs appear to do the same thing.

    Naming Consistency5/5

    All five tools follow a strict snake_case verb_noun convention: search_contacts, send_message, read_messages, list_recent_chats, get_connection_status. Verbs (search/send/read/list/get) are well-differentiated and consistent with the noun's role.

    Tool Count5/5

    Five tools is a tight, well-scoped surface for a personal messaging bridge — discovery, send, read, browse, and status. Every tool earns its place; nothing is redundant and nothing feels arbitrarily split.

    Completeness3/5

    Core 1:1 messaging lifecycle is covered, but there are notable gaps: no group chat support, no historical backfill before the feature started, and no way to fetch or download media referenced by placeholders. An agent can work around these only by telling the user the capability does not exist.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables connecting a personal WhatsApp number to any MCP client, providing tools to send, search, and manage WhatsApp messages, with an optional auto-reply feature.
      5
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Send WhatsApp messages from any MCP client — text, images and files, plus session management and contact checks. Authenticate by scanning a QR code: no Meta Business approval and no WhatsApp Business account required.
      2
      9
      73 npm
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables connecting a personal or business WhatsApp account via QR pairing and then sending/reading messages, managing chats, contacts, groups, and searching message history through MCP tools.
      MIT