whatsapp-mcp-kit
A setup kit that lets an AI assistant (Claude Code, Codex or any MCP client) read your WhatsApp chats and send messages, using your own account.
Who it's for: people who want their AI assistant to work with WhatsApp.
What you get: WhatsApp linked to your AI tools through one small local service, plus ready prompts so an agent does the setup.
Account risk, read first: this uses an unofficial WhatsApp client (Baileys). WhatsApp can restrict accounts that use such clients, so a separate number is safest. Your assistant will also see the messages you let it read.
Quick start
- Open Claude Code or Codex in an empty folder on the machine that should read WhatsApp.
- Paste the block from
PROMPT.md (Russian versions: Claude Code, Codex). Read it first: the agent checks what you already have, explains the risk once, installs one shared local service and opens a QR page.
- On your phone: WhatsApp > Settings > Linked devices > Link a device, scan the page.
Done when: you send yourself a fresh test word in WhatsApp and the agent reads that exact word back.
Want an AI agent to do it for you? Paste this to Claude Code / Codex / Cursor:
"Read the 'For AI agents' section of https://github.com/tonydzi/whatsapp-mcp-kit and set it up for me."
For AI agents
Preconditions
- The ready-made prompt for you is
PROMPT.md (English); Russian: PROMPT-CLAUDE.ru.md, PROMPT-CODEX.ru.md. The full runbook is README.ru.md (Russian). Read the runbook and the prompt from the same revision before acting.
- Tools:
node (a supported LTS), npm, git, Python 3. Windows, macOS or Linux.
- Account: the human's own WhatsApp on their phone. Only they can scan the QR.
- Ask the human: which WhatsApp account to link (a separate number is recommended) and whether they accept the account-restriction risk; this is asked once.
- First do a read-only inventory: existing WhatsApp MCP definitions in both clients (
claude mcp list, codex mcp list), running processes, existing data folder, listening port. If a working install exists, use it and do not reinstall.
Install
From the runbook (README.ru.md, sections 2 to 4). Replace <KIT_DIR> with a folder you choose. The install script puts the server in a private, pinned folder, $HOME/.whatsapp-mcp-kit/server (override with WHATSAPP_MCP_KIT_SERVER), so npm update -g never touches it. Below, <SERVER_DIR> is that folder and <MCP_DIR> means <SERVER_DIR>/node_modules/@sjawhar/whatsapp-mcp (the server entry is <MCP_DIR>/dist/index.js):
git clone https://github.com/tonydzi/whatsapp-mcp-kit <KIT_DIR>
bash <KIT_DIR>/scripts/install.sh # npm install @sjawhar/[email protected], apply both patches, verify; safe to re-run
bash <KIT_DIR>/scripts/check-patches.sh # read-only: applied / MISSING / CONFLICT per patch, exit 1 unless all applied
Run check-patches.sh from cron or before starting the server; if it reports MISSING (after a reinstall), run install.sh again. The scripts are for Linux and macOS (bash); on Windows run the commands from patches/README.md by hand. Make a Python venv in <KIT_DIR>/.venv and install qrcode pillow there. Do not run npm update and do not run the server with --help: some versions connect to WhatsApp at once.
Configure
- Private env values for the pairing step:
WHATSAPP_MCP_DIR (installed package folder), XDG_DATA_HOME (private per-account data folder), WA_QR_WORK_DIR (temporary QR files).
- Pair:
python <KIT_DIR>/pair/wa_qr_live.py --check, then python <KIT_DIR>/pair/wa_qr_live.py, and show the human the local page it prints.
<ACCOUNT_PORT> is a free local port you pick (one per account). Run one owner service per account: node <MCP_DIR>/dist/index.js --http --host 127.0.0.1 --port <ACCOUNT_PORT>, with MCP_API_KEY and ALLOWED_SEND_DIR set from a protected environment (the key is generated by you and stays out of git and argv). Never bind 0.0.0.0.
- Connect both clients over HTTP to
http://127.0.0.1:<ACCOUNT_PORT>/mcp using configs/claude-http.example.json and configs/codex-http.example.toml as examples. Codex: codex mcp add whatsapp --url http://127.0.0.1:<ACCOUNT_PORT>/mcp --bearer-token-env-var WA_MCP_TOKEN (WA_MCP_TOKEN must hold the same string as MCP_API_KEY in the environment that starts Codex).