Skip to main content
Glama
WhatsApp MCP Server

WhatsApp MCP Server

WhatsApp MCP Server

A local stdio-only MCP server for a personal WhatsApp account using WhatsApp Web QR pairing. It provides chat and media reading plus safe opt-in text and media sending. Outbound tools are disabled unless explicitly enabled and limited to an allowlisted set of chats.

Risk: this uses an unofficial WhatsApp Web library. WhatsApp may change its protocol or restrict accounts that use unofficial clients. Use only with your own account, keep session state private, and prefer a separate account for experimentation.

Install

npm install
cp .env.example .env
npm run build

Set WHATSAPP_ALLOWLIST in .env to comma-separated WhatsApp JIDs. It is required for send_message and send_media; read tools remain available with an empty allowlist. Keep outbound files in WHATSAPP_OUTBOUND_MEDIA_DIRS (default: ./outbox).

Related MCP server: whatsapp-mcp

Pair

npm start

On first launch the server writes whatsapp-qr.png locally with mode 0600. Scan it from WhatsApp: Linked devices → Link a device. The local auth directory and media directories are created with mode 0700.

The process speaks MCP over stdin/stdout. Status and errors use stderr only. Do not expose this process behind HTTP or a network socket.

MCP tools

  • connection_status — pairing/connection state and local QR location

  • list_chats — cached chats

  • search_messages — text search over the local session cache

  • read_messages — recent cached messages for an allowlisted chat

  • download_media — save a cached allowlisted message attachment locally

  • fetch_all_chats — list every chat in the local session cache

  • fetch_message_history — page older messages for an allowlisted chat via Baileys fetchMessageHistory

  • send_message — send text to an allowlisted chat (requires WHATSAPP_SENDING_ENABLED=true)

  • send_media — send an image, video, audio, document, or sticker from an approved local file (requires WHATSAPP_SENDING_ENABLED=true)

The cache starts filling after WhatsApp history/message events arrive. It is intentionally not a full archive. fetch_message_history can pull older messages on demand, but only while the WhatsApp socket is connected.

MCP client configuration

{
  "mcpServers": {
    "whatsapp-local": {
      "command": "node",
      "args": ["/absolute/path/to/whatsapp-mcp-server/dist/index.js"],
      "env": {
        "WHATSAPP_ALLOWLIST": "1234567890@s.whatsapp.net",
        "WHATSAPP_SENDING_ENABLED": "true",
        "WHATSAPP_OUTBOUND_MEDIA_DIRS": "/absolute/path/to/whatsapp-mcp-server/outbox"
      }
    }
  }
}

Safety controls

  • Stdio transport only; no HTTP listener.

  • Sending is disabled by default. send_message and send_media require WHATSAPP_SENDING_ENABLED=true and a non-empty WHATSAPP_ALLOWLIST.

  • Send tools are gated at call time, so a config typo cannot silently enable them.

  • Outbound media must resolve to a regular file within WHATSAPP_OUTBOUND_MEDIA_DIRS and stay below WHATSAPP_MAX_OUTBOUND_MEDIA_BYTES (64 MiB default).

  • Outbound sends have a separate rate limit (default: 10/minute) independent of read limits.

  • Input validation via Zod on every tool.

  • Per-process read rate limit (default: 30 tool calls/minute).

  • Result caps (default: 50) and local allowlist support.

  • Auth files, QR image, downloaded media, outbound files, .env, build output, and logs are gitignored.

  • Sensitive files/directories are written with 0600/0700 modes where created by this service.

Verify

npm run check
npm test

License

MIT. See LICENSE.

Viewing the QR code

The QR image is written to the local whatsapp-qr.png path. Attach or upload that image in your MCP client UI after launching the server. The QR expires quickly; call connection_status after scanning to confirm the connection state is connected.

Whatsapp-Mcp

Available Tools

9 tools
connection_statusB

Show local pairing and connection state. QR is written to the configured local file.

Inputs: no named parameters.

download_mediaB

Download media from a locally cached allowlisted message to the configured local directory.

Inputs: chatId (required), messageId (required).

fetch_all_chatsB

List ALL chats visible in the local session cache (not capped by the default list).

Inputs: limit.

fetch_message_historyA

Pull older messages for an allowlisted chat using Baileys fetchMessageHistory. Use beforeMessageId to page backward.

Inputs: chatId (required), limit, beforeMessageId.

list_chatsC

List chats visible in this local session cache.

Inputs: limit.

read_messagesB

Read recent locally cached messages from one allowlisted chat.

Inputs: chatId (required), limit.

search_messagesB

Search locally cached message text. This never sends messages.

Inputs: query (required), limit, chatId.

send_mediaA

Send an image, video, audio, document, or sticker from a regular file inside WHATSAPP_OUTBOUND_MEDIA_DIRS to an allowlisted chat. Requires WHATSAPP_SENDING_ENABLED=true.

Inputs: chatId (required), filePath (required), mediaType (required), caption.

send_messageB

Send a text message to an allowlisted chat. Requires WHATSAPP_SENDING_ENABLED=true.

Inputs: text (required), chatId (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 9 tools

    Disambiguation4/5

    Most tools target distinct operations, but list_chats vs fetch_all_chats and read_messages vs fetch_message_history have overlapping purposes. Their descriptions clarify the differences (default-capped vs all chats, recent vs older history), so misselection is possible but manageable.

    Naming Consistency4/5

    Nearly all tools follow a consistent snake_case verb_noun pattern: list_chats, search_messages, read_messages, send_message, etc. Minor deviations are fetch_all_chats vs list_chats for similar listing actions and connection_status lacking a clear verb.

    Tool Count5/5

    Nine tools is well-scoped for a local WhatsApp MCP server. Each tool covers a distinct capability such as connection status, chat listing, message reading/searching, media handling, and sending.

    Completeness4/5

    The server covers core messaging workflows: connection state, chat discovery, message reading/searching/history, media download, and guarded sending. Some gaps remain, such as contact/group metadata, message reactions, or chat creation, but the essential read/send surface is present.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • 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
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables agents and MCP clients to read and send WhatsApp messages and media, search chats, and manage contacts and groups after a one-time QR pairing.
      37 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP clients to read, search, and send personal WhatsApp messages and files through a locally linked device.
      37 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Runs locally and pairs an existing WhatsApp account as a linked device, enabling Claude Code, Codex, and other MCP clients to read chats, retrieve media, draft replies, and send messages only after client-enforced human approval.
      37 npm
      1
      MIT