guarded-whatsapp-mcp
Governs and automates WhatsApp messaging for AI agents with security controls such as recipient allowlisting, secret scanning, file validation, rate limiting, confirmation gate, and audit logging.
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., "@guarded-whatsapp-mcp Send 'Meeting at 3pm' to the engineering team."
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.
guarded-whatsapp-mcp
Govern & automate WhatsApp safely for AI agents.
An MCP server that lets an AI agent (or any MCP client) send WhatsApp messages and files — but only through a security gate you control: a recipient allowlist, secret scanning, file validation, rate limiting, a confirmation gate, and an append-only audit log.
Most WhatsApp bridges send anything, anywhere, with no record. That is fine for a human clicking send. It is not fine for an autonomous agent. guarded-whatsapp-mcp is the governance layer that makes agent-driven WhatsApp safe enough to trust.
This is not a Slack replacement. No channels, no threads, no workspace UI. It makes the WhatsApp you already use safe to automate.
See it in action
Related MCP server: whatsapp-triage
How it works
⚠️ Read this first — unofficial transport & WhatsApp Terms
This server governs access to a transport; by default that transport is the unofficial
whatsmeow-based bridge (e.g.
whatsapp-mcp), which speaks WhatsApp Web's
private protocol.
An unofficial client violates WhatsApp's Terms of Service and can get a number banned. A reverse-engineered client cannot avoid this.
Use a secondary / non-critical number. Never your primary or business-critical one.
Not for production customer messaging — use the official WhatsApp Business Cloud API. An official Cloud-API backend is on the roadmap; the guard layer is built to front either transport.
The guardrails here reduce operational risk (wrong recipient, leaked secret, spam). They do not change the Terms-of-Service risk of the underlying bridge. We are loud about this on purpose so you can choose with eyes open.
Why teams use it
Without a guard | With guarded-whatsapp-mcp |
Agent can message any number it generates | Fail-closed allowlist — strangers are refused |
A leaked API key sails out in a message | Secret scan blocks it before it sends |
A runaway loop spams the team 200× | Rate limit caps it |
Files arrive as | ASCII-safe filenames + type/size checks |
No idea what the agent sent | Append-only audit log of every attempt |
Accidental sends | Confirmation gate — risky sends must be previewed |
Security controls
Control | What it does |
Recipient allowlist | Fail-closed. With |
Secret / PII scan | Text + captions scanned for API keys, private keys, cloud/Slack/GitHub/OpenAI tokens, JWTs, credit cards (Luhn), national IDs. |
File validation | Extension allowlist + size cap. Filenames sanitized to ASCII (no |
Rate limiting | Sliding window (per-minute + per-hour) stops runaway loops. |
Confirmation gate | Risky sends (unlisted / files / all) need a |
Audit log | Every attempt (sent / blocked / failed) appended to |
Tools
Tool | Gated? | Purpose |
| read-only | Show the allowlist (numbers masked). |
| read-only | Dry-run a send: run every check, return a verdict + |
| send | Send text to an allowlisted recipient through the full gate. |
| send | Send a file (auto ASCII-safe name, type/size checked, caption scanned). |
| read-only | Recent audit records. |
Quickstart
git clone https://github.com/peter-tnc-453/guarded-whatsapp-mcp
cd guarded-whatsapp-mcp
uv venv --python 3.11 && source .venv/bin/activate # Python 3.10+
uv pip install -e .
cp config/allowlist.example.yaml config/allowlist.yaml # edit your allowlist (git-ignored)
# a WhatsApp bridge exposing POST /api/send must be running (the authenticated session).
# whatsmeow bridge: https://github.com/lharries/whatsapp-mcp (first run = QR scan)
python -m wa_guard # run the MCP server (stdio)Register with Claude Code / any MCP client
{
"mcpServers": {
"guarded-whatsapp-mcp": {
"command": "/ABSOLUTE/PATH/guarded-whatsapp-mcp/.venv/bin/python",
"args": ["-m", "wa_guard"],
"env": {
"PYTHONPATH": "/ABSOLUTE/PATH/guarded-whatsapp-mcp/src",
"WA_GUARD_CONFIG": "/ABSOLUTE/PATH/guarded-whatsapp-mcp/config/allowlist.yaml"
}
}
}
}Example — a safe agent flow
// 1) The agent previews first (read-only, sends nothing)
wa_preview(recipient="Alex", file_path="report.pdf")
// → { ok:false, needs_confirm:true, confirm_token:"a1b2c3d4e5",
// display_filename:"report.pdf", recipient:{ name:"Alex", allowlisted:true } }
// 2) It sends, passing the token back to prove the preview happened
wa_send_file(recipient="Alex", file_path="report.pdf", confirm_token="a1b2c3d4e5")
// → { sent:true, ... } (and one line is appended to the audit log)
// A blocked attempt is explicit and recorded:
wa_send_message(recipient="+66999999999", message="hi")
// → { sent:false, blocked_reason:"recipient is not allowlisted and allow_unlisted=false" }Configuration
See config/allowlist.example.yaml. Key knobs:
allow_unlisted (the fail-closed switch), require_confirm_for, rate_limit, files,
secrets.on_detect, and the recipients allowlist. Edits hot-reload on each call.
Roadmap
Pluggable backend — same guard layer in front of the unofficial bridge or the official WhatsApp Business Cloud API (compliant path).
Inbound routing — surface incoming messages to agents (read · classify · route).
Scheduled / templated sends through the same gate.
Per-recipient policy (rate limits / confirm rules per contact or group).
Tests
uv pip install pytest && PYTHONPATH=src python -m pytest -q # 19 passingContributing
PRs welcome — see CONTRIBUTING.md. The one rule: keep the fail-closed posture, and add a test for every new check.
License
MIT — see LICENSE. Security model & honest limitations in SECURITY.md.
Available Tools
5 toolswa_audit_tailA
Return the most recent send-attempt audit records (allowed, blocked, or failed). Read-only. Message bodies are stored as a short preview + hash only.
Inputs: limit. Returns: result
wa_list_recipientsA
List the allowlisted WhatsApp recipients this engine is permitted to message.
Read-only. Numbers are masked. Use the returned name as the recipient
argument to wa_preview / wa_send_message / wa_send_file.
Inputs: no named parameters. Returns: object
wa_previewA
Dry-run a send: run every security check and report exactly what WOULD
happen, WITHOUT sending. Returns a verdict and, when the send needs
confirmation, a confirm_token to pass back to the send tool.
Use this before any send you are unsure about.
Inputs: recipient (required), message, file_path. Returns: object
wa_send_fileA
Send a file to an allowlisted recipient. The filename is auto-sanitized to an ASCII-safe name (so WhatsApp shows a real name, not 'Untitled', and no path traversal is possible), the type/size are validated, and the caption is secret-scanned. Sending files may require a confirm_token (see wa_preview).
Inputs: file_path (required), recipient (required), caption, confirm_token. Returns: object
wa_send_messageA
Send a WhatsApp text message to an allowlisted recipient. Passes through the full security gate (allowlist, secret scan, rate limit, confirmation). If the result has needs_confirm=true, re-call with the returned confirm_token.
Inputs: message (required), recipient (required), confirm_token. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a clearly distinct purpose: listing recipients, dry-running a send, viewing audit records, sending messages, and sending files. The preview tool is explicitly read-only, so there is no confusion with the actual send tools.
All tools share the wa_ prefix and use snake_case with verb-oriented names like wa_list_recipients and wa_send_message. wa_preview is a minor deviation because it lacks a noun object, and wa_audit_tail is slightly awkward, but the overall pattern is predictable.
Five tools is well-scoped for a guarded WhatsApp messaging server: recipient discovery, preview/checking, audit history, text sending, and file sending. Each tool fills a necessary role with no redundancy.
The core secure-send lifecycle is fully covered: identify allowed recipients, preview outcomes, send text or files, and review audit records. The confirmation flow is built into the send tools, so there are no dead ends, and external allowlist management appears intentionally out of scope.
Maintenance
Related MCP Connectors
WhatsApp for your AI agent, sent from your own number. Source-available (Elastic License 2.0).
WhatsApp and Telegram for AI agents, behind a policy gateway. OAuth or access key.
WhatsApp for AI agents — your own number or the official Cloud API: messages, media, templates.
Security gateway for AI agents: policy, approval, and audited execution, no secrets shared.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceCompliance intelligence layer for AI agents sending WhatsApp Business messages. Prevents account suspensions by validating Meta's rules (care windows, opt-outs, rate limits) in real-time before every send.1-
- FlicenseNot gradedqualityBmaintenanceEnables AI assistants to interact with WhatsApp by sending messages, triaging urgent conversations, scheduling messages, and managing automated replies with safety controls and human approval.-
- AlicenseBqualityCmaintenanceEnables AI clients to read and send WhatsApp chats, messages, contacts, groups, polls, reactions and media through two isolated adapters — a personal linked-device runtime and the official Meta Business Graph API — each with per-profile credentials, audit/history storage and managed media. Writes are gated behind prepare/confirm workflows, and inbound media or history is restricted to verified provider IDs and bounded, allowlisted downloads.1MIT
- AlicenseNot gradedqualityBmaintenanceGives AI agents safe access to a single WhatsApp account so they can read and search chats, receive new messages in real time, reply with quotes and typing indicators, send and download media, and react with emojis. Phone numbers stay on the server — agents only see random IDs and names — while sessions, messages and media are encrypted at rest and sending is rate-limited to protect the account.3MIT