whats-mcp
Provides tools for interacting with WhatsApp, including sending and receiving messages, managing contacts, reading chats and unread messages, sending media, and monitoring incoming calls.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@whats-mcp Send a WhatsApp message to John: see you at 5"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
whats-mcp
MCP server that turns your WhatsApp into agent-callable tools.
Link your WhatsApp account once by scanning a QR code (the official "Linked Devices" flow — your phone keeps working normally), and the server keeps the session alive across restarts. Then any MCP-capable agent (Claude Desktop, Hermes, Cursor, …) can search your contacts, send messages, read chats, read unread messages, mark things read, send media, and monitor incoming calls.
Built on Baileys 6.7.24 (the WhatsApp Web multi-device protocol) — a pure Node.js implementation. No browser, no Puppeteer, no Chromium.
⚠️ Unofficial client disclaimer: this uses WhatsApp's Web protocol via an unofficial library. WhatsApp/Meta can ban accounts that abuse unofficial clients. Use it for your own account, at normal human volumes, and avoid bulk/spammy automation. No warranty — use at your own risk.
Features
Area | Tools |
Linking |
|
Contacts |
|
Sending |
|
Reading |
|
Calls |
|
Key properties:
Persistent session — auth lives in
auth_info/(git-ignored). Restart the server → reconnects with no re-scan.Persistent indexes — contacts (
contacts.json) and unread messages (unread.json) are saved to the auth dir, so a daemon restart loses nothing.Auto-reconnect — exponential backoff on drops; only a logout stops it.
No browser — pure WebSocket protocol implementation.
Stdio-safe — QR codes are returned as tool results (raw + ASCII), never printed to stdout; all logs go to stderr so the JSON-RPC stream stays clean.
Related MCP server: WA MCP
Quick start
Full step-by-step install guide for Windows, macOS and Linux (Node setup, QR linking, 24/7 service for each OS): docs/INSTALL.md.
# 1. install
npm install
# 2. run the server (or: npm start)
node src/index.js
# 3. ask your MCP client to link the device:
# call whatsapp_get_qr → scan the QR in WhatsApp → Settings →
# Linked devices → Link a device
# (or call whatsapp_get_pairing_code with your number and type the code)The server connects to WhatsApp immediately on boot. While unlinked it keeps
a fresh QR ready. Once linked, creds.json is persisted — every later start
reconnects automatically.
Registering in an MCP client
Standard mcpServers config (Claude Desktop / Cursor / etc.):
{
"mcpServers": {
"whatsapp": {
"command": "node",
"args": ["/absolute/path/to/whats-mcp/src/index.js"],
"env": {
"WHATSAPP_AUTH_DIR": "/absolute/path/to/whats-mcp/auth_info"
}
}
}
}Hermes Agent
Connect Hermes to the daemon over HTTP (recommended — the systemd service owns the WhatsApp connection, see below):
hermes config set mcp_servers.whatsapp.url http://127.0.0.1:8787/mcpor spawn the server per Hermes session (stdio):
hermes config set mcp_servers.whatsapp.command node
hermes config set mcp_servers.whatsapp.args '["/absolute/path/to/whats-mcp/src/index.js"]'
hermes config set mcp_servers.whatsapp.env.WHATSAPP_AUTH_DIR /absolute/path/to/whats-mcp/auth_infoThen restart Hermes — tools appear as mcp_whatsapp_whatsapp_get_qr, etc.
(One instance per auth dir: either the daemon or a spawned child, never
both — the single-instance lock enforces this.)
24/7 daemon (systemd)
Keep the WhatsApp connection alive across reboots and logins:
# 1. install the unit (see ~/.config/systemd/user/whats-mcp.service in this repo's setup)
systemctl --user daemon-reload
systemctl --user enable --now whats-mcp
loginctl enable-linger "$USER" # start at boot, even before loginThe daemon serves MCP on http://127.0.0.1:8787/mcp (plus GET /health),
logs to journald (journalctl --user -u whats-mcp -f), and never unlinks the
device on shutdown. Contacts and unread-message state are persisted inside the
auth dir, so restarts lose nothing.
Environment variables
Variable | Default | Purpose |
|
| Where the linked-device credentials live (keep private!) |
|
|
|
|
|
|
| (unset) | Set to run as a daemon: StreamableHTTP on |
|
| Seconds send/read tools wait for the connection to be open |
Tool reference
whatsapp_get_qr
Returns the current linking QR as a raw string and an ASCII rendering, plus seconds until it rotates. Scan with WhatsApp → Settings → Linked devices → Link a device. QR rotates every ~20–60s — scan promptly.
whatsapp_get_pairing_code
phone (digits with country code, e.g. 919876543210) → returns an 8-digit
code. On the phone: Link a device → Link with phone number instead, then
enter the code. Fails gracefully if the account doesn't support pairing.
whatsapp_get_status
Connection state, linked flag, QR availability, contact/chat/unread counts, last disconnect reason. Use this first whenever something seems off.
whatsapp_search_contacts
query (name substring or number digits, empty = list all) + limit →
matches with jid, name, notify, number. The jid can be passed to any
tool that takes a contact.
whatsapp_send_message
contact + text, optional quoted_message_id (reply). contact is
resolved in order: full JID → phone number (verified via onWhatsApp) →
saved contact name.
whatsapp_send_media
contact + media_type (image | audio | document) + source (local
path or http(s) URL), optional caption, file_name, as_voice_note.
whatsapp_read_chat
contact + limit → most recent messages seen for that chat (since server
start), plus its unread count.
whatsapp_read_unread
per_chat + max_chats → chats with unreadCount > 0, sorted by unread
count, with the newest incoming messages for each.
whatsapp_mark_read
contact → sends read receipts for that chat's tracked messages (respects
the account's read-receipt privacy setting).
whatsapp_recent_calls / whatsapp_reject_call
Incoming call events (offer/ringing/accept/reject/timeout, with
video flag) since server start; reject a live call by id.
whatsapp_logout
Removes the linked device from your account (like tapping "Log out" on the phone). The auth folder is kept; scan a fresh QR to re-link.
Limitations (read this — it's honest)
Voice/video calls cannot be placed. This is a hard WhatsApp protocol limitation: call media flows over a separate signaling path that the linked-device (Web) protocol does not expose. Verified against the Baileys 6.7.24 API surface — there is no send-side call content; missed-call "bubbles" are inbound-only server constructs.
whatsapp_callexists to explain exactly this. What IS possible: monitor incoming calls (whatsapp_recent_calls) and reject them (whatsapp_reject_call). (Future: Baileys v7 addscreateCallLink— sending a tappable call link — tracked indocs/ARCHITECTURE.md.)History is event-based. Chats/messages received after the server connects are available immediately; older history arrives via WhatsApp's
messaging-history.setsync (contacts + chat metadata, unread counts).Message content: text, captions and file names are extracted; media blobs are not downloaded (yet).
4 linked devices max (phone + 3). Scanning a 5th bumps the oldest.
The phone must keep WhatsApp installed; uninstalling or renaming the number kills the linked session.
Project layout
whats-mcp/
├── src/
│ ├── index.js # entry: boot client, expose over MCP stdio
│ ├── server.js # MCP tool definitions (zod schemas)
│ └── whatsapp.js # Baileys wrapper: QR, auth, reconnect, indexes
├── scripts/
│ └── smoke-test.mjs # stdio end-to-end test (npm run smoke)
├── docs/
│ ├── ARCHITECTURE.md # design decisions + upgrade paths
│ └── AGENTS.md # conventions for agent contributors
├── .env.example
├── package.json
└── LICENSE (MIT)Testing
npm run smoke # spawns the real server over stdio, asserts handshake+toolsLicense
MIT — see LICENSE. Baileys is MIT; the MCP SDK is MIT.
Available Tools
15 toolswhatsapp_callVoice/video call — protocol limitation explainerB
IMPORTANT: the WhatsApp linked-device (Web) protocol used here CANNOT place real voice/video calls — that is a hard WhatsApp protocol limitation (call media flows over a separate, unsupported signaling path). This tool explains the situation and lists incoming call events so you can see who called. Use whatsapp_reject_call to decline an incoming call. Send a call link if the contact has WhatsApp call-links enabled (v7 of the underlying library adds createCallLink; tracked in docs).
Inputs: mode.
whatsapp_get_pairing_codeLink WhatsApp via pairing code (no QR)A
Requests an 8-digit pairing code from WhatsApp for the given phone number. Enter it on the phone under Linked Devices → Link with phone number instead. Falls back gracefully if the account does not support pairing codes.
Inputs: phone (required).
whatsapp_get_qrGet WhatsApp linking QR codeA
Returns the QR code to scan in WhatsApp → Linked Devices → Link a Device. Also returns an ASCII rendering for terminals and a pairing-code alternative hint. The QR rotates every ~20-60s — scan promptly.
Inputs: no named parameters.
whatsapp_get_statusWhatsApp connection statusC
Connection state, whether the device is linked, QR availability, contact/chat counts, unread count, and last disconnect reason.
Inputs: no named parameters.
whatsapp_list_chatsList chatsA
List chats known to the daemon (history sync + live events): jid, contact name, unread count, last message.
Inputs: limit.
whatsapp_logoutLog out this linked deviceA
Removes the device from your WhatsApp account (like tapping "Log out" on the phone) and clears the local credential files so a fresh QR is offered on the next restart.
Inputs: no named parameters.
whatsapp_mark_all_readMark all chats as readA
Send read receipts for the latest message of every tracked chat and clear all unread state. Read state is server-side and propagates to every linked device, clearing phone badges.
Inputs: no named parameters.
whatsapp_mark_readMark a chat as readA
Mark all tracked messages in a chat as read (sends read receipts, respects the account read-receipt privacy setting).
Inputs: contact (required).
whatsapp_read_chatRead recent messages in a chatA
Recent messages (since server start) from a chat, resolved by contact name, number, or JID. Includes unread count for the chat.
Inputs: contact (required), limit.
whatsapp_read_unreadRead unread chats and messagesA
List chats with unread messages (unreadCount from WhatsApp) plus the most recent incoming messages seen for each.
Inputs: per_chat, max_chats.
whatsapp_recent_callsRecent incoming call eventsB
Incoming call events seen since server start: offer/ringing/accept/reject/timeout/terminate, with video flag.
Inputs: limit.
whatsapp_reject_callReject an incoming callA
Reject an incoming WhatsApp call by its id (see whatsapp_recent_calls). Only works for calls still in offer/ringing state.
Inputs: call_id (required).
whatsapp_search_contactsSearch WhatsApp contactsA
Search saved contacts by name or phone number. Returns jid, name, notify name and number so you can send messages.
Inputs: limit, query.
whatsapp_send_mediaSend WhatsApp media (image/audio/document)C
Send an image, audio, or document from a local path or http(s) URL to a contact.
Inputs: source (required), contact (required), media_type (required), caption, +2 more.
whatsapp_send_messageSend WhatsApp messageB
Send a text message to a contact (by saved name, phone number with country code, or JID). Connection must be linked and open.
Inputs: text (required), contact (required), quoted_message_id.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 15 tools
Most tools target clearly distinct actions (send vs read vs mark vs link). There is some overlap between read_unread and list_chats (both surface chats with unread counts) and read_chat (which also returns unread count), and the whatsapp_call tool is essentially a non-actionable explainer that overlaps conceptually with recent_calls.
All tools share the whatsapp_ prefix in snake_case with a verb_noun pattern (get_status, send_message, mark_read, reject_call). Minor deviations: recent_calls omits a verb, and call/logout are bare verbs without a noun.
15 tools is well within a reasonable range for a WhatsApp bridge covering linking, messaging, reading, and calls. Slightly inflated by whatsapp_call, which is a placeholder explaining a protocol limitation rather than a functional operation.
Core lifecycle is covered: status/QR/pairing, contacts, send text/media, read chats/unread, mark read, call events, and logout. Gaps remain around group/participant management, message deletion or forwarding, and reactions, but the common messaging workflows are well supported.
Maintenance
Related MCP Connectors
Hosted WhatsApp MCP server for AI agents — read, search, send messages, media, polls, and groups.
Your own WhatsApp as an MCP server: read, search and send from any MCP client.
WhatsApp MCP on your own number: read chats, search contacts, send messages.
Free WhatsApp MCP server for ChatGPT and Claude: read and search chats, every send you approve.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn MCP (Multi-Agent Conversation Protocol) Server that enables interaction with the WhatsApp Business API, allowing agents to send messages, manage media, and perform other WhatsApp business operations through natural language.1-
- AlicenseNot gradedqualityBmaintenanceWhatsApp MCP server that exposes messaging, groups, contacts, and profile management as tools and resources for AI agents, supporting Baileys and Meta Cloud API.31MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that connects AI agents to WhatsApp using the multi-device API, enabling messaging, group management, and more as a regular user.1MIT
- AlicenseNot gradedqualityBmaintenanceMCP server exposing WhatsApp Cloud API operations as tools for AI agents like Claude Code, Cursor, and Codex.MIT