WhatsApp Read Agent MCP Server
Provides read-only tools to access WhatsApp history and attachments from a local archive, including chat enumeration, message history with deterministic pagination, and retrieval of approved attachment bytes.
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., "@WhatsApp Read Agent MCP Server Get the last 10 messages from Rajesh Aggarwal"
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.
WhatsApp Read Agent
Strictly read-only access to your own WhatsApp history and attachments, for an AI assistant (via the Model Context Protocol) or any script that reads the local archive.
It is built so that reading and writing are physically separated:
Component | Talks to WhatsApp? | What it can do |
Collector ( | Yes — links a companion device | Receives history sync + new messages, downloads attachments under a size cap. Nothing else. |
MCP server ( | No | Reads the local archive only. Enumerate chats, page history deterministically, read exact timestamps/content, return approved attachment bytes. |
The MCP server has no code path to send, reply, react, call, archive, delete, mark-read,
pay, or transfer — those tools are not registered and the WhatsApp socket is not even
imported into that process. src/server.test.ts asserts the tool surface is exactly the
seven read-only tools, so a mutating tool cannot be added without a test failing.
⚠️ Read this before linking a device
This is unofficial. It links a companion device using the multi-device protocol (via
@whiskeysockets/baileys), the same mechanism as WhatsApp Web, but programmatically. This is not an official WhatsApp API and may violate WhatsApp's Terms of Service. Automating a client can get the account banned. There is no sanctioned API that exposes personal 1:1/group history — the official WhatsApp Cloud API only handles messages to a registered business number. Use this only on your own account, understanding that risk.Everything derived from a linked account stays local and gitignored: companion-device credentials (
auth/), the message archive (data/), and downloaded media (media/). Never commit them. The device credentials grant full account access — treat them like a password.Attachment downloads are double-gated: an explicit per-message approval flag and an optional operator allowlist of chat JIDs. The MCP server only ever surfaces bytes the collector already downloaded; it never reaches out to WhatsApp to fetch anything.
Related MCP server: WhatsApp MCP Server
Install & test
cd whatsapp-agent
npm install # MCP SDK + zod (Baileys is an optional dep, see below)
npm run check # build + 31 unit/integration tests (no device or network needed)The pure read model, deterministic pagination, consent gate, and path-safety checks are all covered by tests that run offline. The collector's WhatsApp handling requires a live device and cannot be exercised in CI.
Link a device and sync (collector)
The collector needs the optional dependency:
npm install @whiskeysockets/baileys qrcode-terminal
cp .env.example .env # adjust paths / limits if desired
npm run collect # prints a QR (or a pairing code if WHATSAPP_PAIR_NUMBER is set)On your phone: WhatsApp → Settings → Linked devices → Link a device, then scan the QR
(or choose "Link with phone number" and enter the printed pairing code). The collector then
receives the history sync and writes it to data/ (and attachments to media/). Keep it
running to keep the archive current. Re-run it anytime to resume.
Wire up the MCP server
Build first (npm run build), then point your MCP host at the built entry:
{
"mcpServers": {
"whatsapp-read": {
"command": "node",
"args": ["/absolute/path/to/rs-website-firebase/whatsapp-agent/dist/index.js"],
"env": {
"WHATSAPP_DATA_DIR": "/absolute/path/to/whatsapp-agent/data",
"WHATSAPP_MEDIA_DIR": "/absolute/path/to/whatsapp-agent/media",
"WHATSAPP_ATTACHMENT_ALLOWLIST": ""
}
}
}
}The server loads the archive at startup. After a fresh sync, restart it to pick up new messages.
Tools (all read-only)
Tool | Purpose |
| Is a device linked, when it last synced, how many chats/messages archived. |
| Enumerate chats (name-ordered, paginated). |
| Locate a named contact or group. |
| Deterministic page of a chat's history; |
| A single message with exact timestamp and content. |
| Messages in a chat that carry attachments. |
| Return an approved attachment's local bytes ( |
Cursors are opaque — pass them back verbatim.
Verification / readback test
The task's acceptance test ("prove complete readback against Anuj Kapoor and Rajesh Aggarwal") requires a linked device and therefore must be run on a machine with the phone available:
npm run collectand link the device; wait forget_sync_statusto report a non-zeromessageCountand stablelastSyncAt.Start the MCP server (or use the archive directly).
find_chats_by_name→"Anuj Kapoor", then"Rajesh Aggarwal"to get each chat JID.get_historywithdirection: "forward", paging onnextCursoruntilhasMoreis false — that is the complete, ordered history with exactisoTimetimestamps.For any attachment,
list_attachmentsthenget_attachmentwithapproved: true.
The deterministic pagination and the end-to-end "locate named chat → page complete history"
flow are proven in src/read-api.test.ts and src/server.test.ts against seeded Anuj/Rajesh
fixtures. The live readback against the real account was not run here: this
environment is headless (no phone to scan the QR, no persistent host), so a device cannot be
linked from it. Run steps 1–5 on your own machine to complete the acceptance test.
Available Tools
7 toolsfind_chats_by_nameA
Find chats whose resolved name matches (case-insensitive substring). Use this to locate a named contact or group, e.g. before reading their full history.
Inputs: name (required).
get_attachmentA
Return an approved attachment's locally-archived bytes. Requires approved: true for the specific message (and passes the operator allowlist, if configured). Never fetches from WhatsApp — only surfaces bytes the collector already downloaded.
Inputs: id (required), chatId (required), approved (required), includeBase64.
get_historyA
Read a deterministic page of a chat's message history. direction "forward" reads oldest→newest; "backward" scrolls up (newest→oldest). Returned messages are always chronological; pass the cursor back to continue. Iterate until hasMore is false for complete readback.
Inputs: chatId (required), limit, cursor, direction.
get_messageA
Fetch a single archived message by chat JID and message id, with exact timestamp and content.
Inputs: id (required), chatId (required).
get_sync_statusA
Report the local archive status: whether a device is linked, when it last synced, and how many chats/messages are archived. Reads nothing from WhatsApp.
Inputs: no named parameters.
list_attachmentsA
List archived messages in a chat that carry an attachment (image/video/audio/document/sticker), with metadata and whether bytes are downloaded. Deterministic forward pagination.
Inputs: chatId (required), limit, cursor.
list_chatsA
List archived chats (1:1 and group), ordered deterministically by name. Optionally filter by a name substring. Paginate with the returned cursor.
Inputs: limit, cursor, search.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Most tools are distinct, but list_chats and find_chats_by_name overlap since list_chats already supports name-substring filtering. This could confuse an agent choosing between them, though descriptions help clarify the intended use case.
Tool names consistently follow a verb_noun pattern with lowercase and underscores. Minor deviation: list_chats vs find_chats_by_name for similar operations, but overall the pattern is readable and predictable.
Seven tools is well-scoped for a read-only WhatsApp archive agent. Each tool covers a specific aspect (sync status, chat listing, history, single messages, attachments), and none feel redundant or missing at this scale.
The tool set provides full coverage for reading archived WhatsApp data: sync status, chat discovery, full message history retrieval, individual message access, and attachment handling. No significant operations are missing for the stated purpose of a read agent.
Related MCP Connectors
Read, summarize and send your own WhatsApp messages from AI assistants (OAuth 2.1).
Your own WhatsApp in Claude and ChatGPT: read chats, draft replies, send messages you approve.
Read-only WhatsApp MCP for your AI agent: it reads the chats you choose. Try the public demo.
Ask questions across your WhatsApp inbox from Claude, ChatGPT, Cursor or any MCP client.
Related MCP Servers
- AlicenseCqualityDmaintenanceA Model Context Protocol server that connects your personal WhatsApp account to AI agents like Claude, enabling them to search messages, view contacts, retrieve chat history, and send messages via WhatsApp.776ISC
- AlicenseNot gradedqualityDmaintenanceEnables 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.ISC
- AlicenseAqualityCmaintenanceEnables Claude to interact with WhatsApp on macOS through the Model Context Protocol. It allows reading messages, searching contacts, listing chats, and sending replies via natural conversation.82MIT
- AlicenseNot gradedqualityBmaintenanceProvides Claude with read-only access to your WhatsApp chat history entirely on your local machine, enabling natural language search, summarization, and retrieval of messages without sending data to the cloud.14 npmMIT