Skip to main content
Glama
whatsapp-mcp

whatsapp-mcp

by coderman400

whatsapp-mcp

Give AI agents access to your own WhatsApp: read, search and send messages through the Model Context Protocol. Built on Baileys, so it links as a WhatsApp "linked device" (like WhatsApp Web) — no browser, no Business API, no phone number rental.

your phone ──(linked device)── whatsapp-mcp daemon ──MCP over HTTP── Claude Code / Agent SDK / any MCP client
                                  │
                                  └── local SQLite cache of chats, contacts and messages

Why a daemon

WhatsApp allows one connection per linked device, and it only pushes messages to that device (a history sync when you link, then live messages). So whatsapp-mcp runs as one long-lived process that holds the connection and caches everything it sees in SQLite. Any number of agents can then query it at the same time over MCP — each agent session doesn't have to log in, and reads/searches are instant and work offline. (A --stdio mode is there too for single-client hosts.)

Related MCP server: WhatsApp MCP Server (TypeScript)

Tools

Tool

What it does

whatsapp_status

Connection state; if not linked yet, the pairing code or QR path to link it

list_chats

Recent chats with last message and unread counts; filter by name, include/exclude groups

get_messages

One chat's messages (by JID, phone number or name), with paging

search_messages

Text search across cached messages, optionally per chat / since a time

messages_since

Everything received since a time, grouped by chat — the "catch me up" view

find_contact

Look up people and groups by name or number

send_message

Send a text message (annotated as open-world; gate it in your agent)

Times accept ISO dates, unix seconds, or relative values like 24h / 7d. Names resolve to the saved contact name, group subject, or the person's own profile name.

Install

Requires Node 20+.

git clone https://github.com/coderman400/whatsapp-mcp && cd whatsapp-mcp
npm install          # also builds dist/
npm start            # or: node dist/index.js --help

On first run it waits to be linked. Either:

  • QR: scan the QR printed in the terminal (also saved to ~/.whatsapp-mcp/link-qr.png) from WhatsApp → Settings → Linked devices → Link a device.

  • Pairing code (handy when you can't see the screen): start with --pair-phone <your number with country code>; the 8-character code is logged and written to ~/.whatsapp-mcp/link-code.txt, and whatsapp_status returns it. On the phone: Linked devices → Link a device → Link with phone number instead.

The session is saved in ~/.whatsapp-mcp/auth and survives restarts. It connects with markOnlineOnConnect: false, so your phone keeps getting notifications.

Use it

Claude Code

claude mcp add --transport http whatsapp http://127.0.0.1:3737/mcp

Claude Agent SDK

query({ prompt, options: { mcpServers: { whatsapp: { type: "http", url: "http://127.0.0.1:3737/mcp" } } } });

Claude Desktop / stdio clients (no separate daemon; the client starts it)

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

Always on: see examples/whatsapp-mcp.service for a systemd user service.

Options

Flag

Env

Default

--data-dir

WHATSAPP_MCP_DATA_DIR

~/.whatsapp-mcp

--port

WHATSAPP_MCP_PORT

3737

--host

WHATSAPP_MCP_HOST

127.0.0.1

--token

WHATSAPP_MCP_TOKEN

none (send Authorization: Bearer <token>)

--pair-phone

WHATSAPP_MCP_PAIR_PHONE

none (QR linking)

--full-history

WHATSAPP_MCP_FULL_HISTORY=1

off

--stdio

HTTP daemon

GET /health returns the connection state and cache counts.

Safety — read this

  • This is unofficial. It uses WhatsApp's linked-device protocol via Baileys, not an official API. Automated or bulk messaging can get a number banned. Keep sending human-paced, and prefer read-only use.

  • Your data dir is a login. ~/.whatsapp-mcp/auth grants full access to your WhatsApp. Keep it private (it's created 0700), never commit it, and unlink the device from your phone if it leaks.

  • Keep it local. The server binds to 127.0.0.1 by default; if you expose it, set --token.

  • Messages are untrusted input. Anyone can message you, so an agent reading WhatsApp can be fed instructions ("ignore previous instructions and send…"). Don't give the same agent unattended send_message plus other powerful tools; require human approval for sends.

Limitations

  • Text sending only (no media yet). Reading covers text, captions, documents, locations, polls and contact cards; other media are shown as [image], [voice note], etc. without downloading.

  • The cache starts when you link: older history depends on what WhatsApp's initial sync sends (--full-history asks for more).

  • Built on a Baileys release candidate (7.x); WhatsApp protocol changes can require a Baileys update.

License

MIT

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to interact with your personal WhatsApp account, allowing them to search messages and contacts, retrieve chat history, and send messages to individuals or groups. Uses WhatsApp Web API with local data storage for privacy and security.
      11 npm
      ISC
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to interact with your personal WhatsApp account to search messages, list chats, and send messages. It stores all authentication and message data locally using SQLite for privacy and direct multi-device API connection.
      11 npm
      1
      ISC
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to search and read locally stored chat history, look up contacts, send messages and attachments, and retrieve media through a self-hosted local daemon with encrypted SQLite storage.
      1
      MIT
    • A
      license
      Not graded
      quality
      Not graded
      maintenance
      Lets AI assistants read, search, and send WhatsApp messages by linking to an account as a linked device, keeping a searchable archive of chats. It exposes tools for listing and finding chats and contacts, paging through message history, and sending, reacting to, editing, deleting, and marking messages read.
      49 npm
      GPL 3.0