Skip to main content
Glama
whatsapp-mcp

whatsapp-mcp

by anzmage

whatsapp-ai-bot

A small personal bot: it receives WhatsApp messages through Baileys, asks an LLM for an answer, and sends it back.

By default it answers as Zai, the ZaidanLab assistant from zaidanlab.dev: same knowledge (the live llms.txt) and the same free provider chain (Workers AI → Ollama Cloud → NVIDIA NIM → Requesty), with DeepSeek as the paid last resort. Unlike the website chat it has no conversation-length limit and also answers general questions.

Owner first. You keep answering from your phone. The bot only replies when a chat has waited OWNER_WAIT_MINUTES (default 30) without a reply from you; it then answers everything pending and keeps answering that chat until you write there again, or the chat is quiet for the same time. Your own replies are added to the chat history so the bot has the context.

The repo began as a fork of finereli/whatsapp-mcp, whose code has since been removed (still in git history). Only LICENSE remains from it.

Warning

Baileys is unofficial and against WhatsApp's Terms of Service. The number can be banned. Use a spare number, for personal use and experiments, not customers.

Related MCP server: WhatsApp MCP

Setup

npm install
cp .env.example .env     # fill in LLM_API_KEY and ALLOWED_NUMBERS
npm start                # pairing code (or QR if BOT_NUMBER is empty): WhatsApp > Linked devices

Needs Node 20.6+. The session is stored in auth/ (git-ignored); delete it to re-link.

Configuration (.env)

Variable

Meaning

CF_ACCOUNT_ID + CF_API_TOKEN, OLLAMA_API_KEY, NVIDIA_API_KEY, REQUESTY_API_KEY

Free providers, tried in that order; an empty key skips the provider.

LLM_BASE_URL, LLM_API_KEY, LLM_MODEL

Paid last resort, any OpenAI-compatible endpoint. Defaults to DeepSeek deepseek-flash.

KNOWLEDGE_URL

Set = answer as Zai with this llms.txt as knowledge. Empty = use SYSTEM_PROMPT.

SYSTEM_PROMPT

Persona and style when KNOWLEDGE_URL is empty.

BOT_NUMBER

The number the bot runs on (digits, country code). Set = link with a pairing code instead of a QR.

ALLOWED_NUMBERS

Comma-separated numbers (digits, with country code) the bot answers. Empty = nobody, * = anyone.

OWNER_WAIT_MINUTES

Minutes to wait for your reply before the bot answers (0 = at once). Pending waits are lost on restart.

MAX_REPLIES_PER_HOUR

Hourly cap across all chats (0 = no cap).

MAX_REPLIES_PER_SENDER_PER_HOUR

Hourly cap per sender (0 = no cap). Keeps one number from using the whole budget in * mode.

HISTORY_TURNS

How many past exchanges per chat are sent to the model (memory only, lost on restart).

REPLY_DELAY_MIN_MS / REPLY_DELAY_MAX_MS

Random "typing" delay before each reply.

Safety notes

  • Only direct chats are answered: groups, status and your own messages are ignored.

  • Senders not on ALLOWED_NUMBERS are logged, so you can copy their number into it.

  • With ALLOWED_NUMBERS=* anyone can spend your LLM budget; the per-sender and hourly caps bound that.

  • The bot has no tools, so a malicious message can at most change what it says, not what it does.

  • Message text is sent to whichever LLM provider answers (Cloudflare, Ollama, NVIDIA, Requesty or DeepSeek).

Tests

npm test covers the allowlist, rate limiter, history, reply cleaning, provider fallback and the owner-first handover (not a live WhatsApp connection or real LLM calls).

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

    • F
      license
      A
      quality
      C
      maintenance
      Enables read-only access to your own WhatsApp history and attachments via the Model Context Protocol, allowing AI assistants to enumerate chats, page history deterministically, and retrieve approved attachment bytes.
      7
      -
    • 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.
      49 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to search and read archived Telegram and WhatsApp messages and attachments through a Streamable HTTP MCP endpoint, with scoped credentials, per-account/chat permissions, full-text search, and extracted file text.
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Pairs with a personal WhatsApp account via WhatsApp Web QR linking so an MCP client can list chats, search and read cached messages, page older history, and download media locally. Sending text, images, audio, documents, or stickers is possible only through opt-in, allowlisted, rate-limited tools that stay disabled by default.
      9
      MIT