MCP server exposing the pywa WhatsApp Cloud API client as ~100 auto-discovered tools
Project description
๐ฌ pywa MCP Server
Unofficial Model Context Protocol (MCP) server that exposes the pywa WhatsApp Cloud API client as MCP tools.
โ ๏ธ Disclaimer: Unofficial, third-party integration. Not affiliated with, endorsed by, or sponsored by WhatsApp, Meta, or the pywa project.
โจ Features
- ๐ Full pywa surface โ ~100 tools auto-discovered from the pywa
WhatsAppclient - ๐ก๏ธ Type coercion โ auto-parses JSON strings, hydrates dataclasses, coerces enums
- ๐ฆ Smart serialization โ bytes โ base64, datetime โ ISO, Path โ string, enum โ value, dataclass โ dict
- ๐๏ธ Allowlist control โ restrict exposed tools via
PYWA_MCP_TOOLSenv - โ๏ธ Var-args support โ pywa methods with
*argsexposed via an_argsfield - ๐งช Unit-tested โ 37 tests covering serialization, coercion, schema, discovery
- ๐ MCP compliant โ works with Claude Code, Claude Desktop, Cursor, Cline, etc.
๐ Quick Start
Prerequisites
- Python 3.13+
uv- A Meta-approved WhatsApp Business phone number + access token
- An MCP-compatible client
1. Get pywa credentials
From the Meta Business dashboard:
- Phone Number ID โ Meta โ WhatsApp โ API Setup
- Access token โ system-user token (permanent) or temporary
- WABA ID โ required for templates / flows / QR codes
- App ID / App secret โ required for update validation + callback registration
2. Register with Claude Code
Option A โ claude mcp add (recommended, zero-install)
Runs the server directly from git via uvx โ no clone required.
Basic syntax:
claude mcp add [options] <name> -- <command> [args...]
Real example:
claude mcp add --transport stdio --scope user \
--env WHATSAPP_PHONE_ID=<phone-id> \
--env WHATSAPP_TOKEN=<token> \
--env WHATSAPP_WABA_ID=<waba-id> \
--env WHATSAPP_APP_ID=<app-id> \
--env WHATSAPP_APP_SECRET=<app-secret> \
pywa \
-- uvx --from git+https://github.com/ianaleck/pywa-mcp-server pywa-mcp-server
Scope (--scope / -s):
local(default) โ private to this projectuserโ across all your projectsprojectโ committed via.mcp.json
Verify / inspect / remove:
claude mcp list
claude mcp get pywa
claude mcp remove pywa
Option B โ .mcp.json in the project
cp .mcp.json.example .mcp.json
# edit credentials; .mcp.json is gitignored
Option C โ Claude Desktop / Cursor / Cline / other clients
Any MCP client that supports stdio works. Add:
{
"mcpServers": {
"pywa": {
"command": "uvx",
"args": ["--from", "git+https://github.com/ianaleck/pywa-mcp-server", "pywa-mcp-server"],
"env": {
"WHATSAPP_PHONE_ID": "...",
"WHATSAPP_TOKEN": "...",
"WHATSAPP_WABA_ID": "...",
"WHATSAPP_APP_ID": "...",
"WHATSAPP_APP_SECRET": "..."
}
}
}
}
Local development install
If you're modifying the server, clone and run from source:
git clone https://github.com/ianaleck/pywa-mcp-server.git
cd pywa-mcp-server
uv sync
# then point claude mcp add at:
# uv --directory /absolute/path/to/pywa-mcp-server run pywa-mcp-server
๐ฏ What You Can Do
Once connected, you can ask Claude to:
๐ฌ Messaging
- "Send a WhatsApp text to +27..., 'Order confirmed'"
- "Send the totp template to +27... with code 483921"
- "React to message wamid.xxx with ๐"
๐ Templates
- "List all my approved templates"
- "Create a UTILITY template called 'order_shipped' with one body variable"
- "Show me the totp template details"
๐ Flows
- "List all published flows"
- "Show metrics for the customer_pick flow over the last 30 days"
- "Fetch the JSON for flow 903243286082414"
๐ผ๏ธ Media
- "Upload this image URL and send it to +27..."
- "Download media wamid.xxx to /tmp"
๐ QR Codes
- "Create a QR code with the message 'Hi Orana!'"
- "Update QR code XYZ123 with a new prefilled message"
๐ฅ Health & Diagnostics
- "Check my WABA health status"
- "What's blocking my business-initiated sends?"
๐ ๏ธ Tool Catalog
Auto-discovered from pywa.WhatsApp. Full pywa docs at pywa.readthedocs.io.
๐ฌ Send messages (16 tools)
send_text/send_messagesend_image/send_video/send_audio/send_voicesend_document/send_stickersend_location/send_contactsend_reaction/remove_reactionsend_templatesend_catalog/send_product/send_productsrequest_location
๐ Templates (9 tools)
get_template/get_templatescreate_template/update_template/delete_templatecompare_templates(uses_argsfor second template ID)unpause_templateupsert_authentication_templatemigrate_templates
๐ Flows (11 tools)
get_flow/get_flows/get_flow_assets/get_flow_metricscreate_flow/update_flow_json/update_flow_metadatapublish_flow/deprecate_flow/delete_flowmigrate_flows
๐ผ๏ธ Media (5 tools)
upload_media/download_mediaget_media_url/get_media_bytes(returns base64-wrapped bytes)delete_media- โ ๏ธ
stream_mediareturns a Python generator โ unusable via MCP. Useget_media_bytesordownload_mediainstead.
๐ QR Codes (5 tools)
create_qr_codeget_qr_code/get_qr_codesupdate_qr_codedelete_qr_code
๐ข Business profile & account (5 tools)
get_business_profile/update_business_profileget_business_accountget_commerce_settings/update_commerce_settings
๐ Phone numbers (7 tools)
get_business_phone_number/get_business_phone_numbersget_business_phone_number_settings/update_business_phone_number_settingsupdate_display_nameregister_phone_number/deregister_phone_number
โ๏ธ Calling API (6 tools)
Requires SIP configuration; may be blocked if not enabled.
initiate_call/terminate_callpre_accept_call/accept_call/reject_callget_call_permissions
๐ช Webhook configuration (6 tools)
Note: this server doesn't run a webhook receiver โ registration only.
set_app_callback_urloverride_phone_callback_url/override_waba_callback_urldelete_phone_callback_url/delete_waba_callback_urlset_business_public_key
๐ซ Block users (3 tools)
block_users/unblock_usersget_blocked_users
๐ฌ Conversation utilities (3 tools)
mark_message_as_readindicate_typingupdate_conversational_automation
๐ง Misc (1 tool)
get_app_access_token
โ๏ธ Environment Variables
| Variable | Required | Notes |
|---|---|---|
WHATSAPP_PHONE_ID / WA_PHONE_ID |
โ | Phone Number ID |
WHATSAPP_TOKEN / WA_TOKEN |
โ | System-user or business access token |
WHATSAPP_WABA_ID / WA_BUSINESS_ACCOUNT_ID |
โ ๏ธ | WABA-scoped methods (templates, flows, QR codes) |
WHATSAPP_APP_ID / WA_APP_ID |
โ ๏ธ | Callback registration with APP scope |
WHATSAPP_APP_SECRET / WA_APP_SECRET |
โ ๏ธ | Update validation + APP-scoped callbacks |
PYWA_MCP_TOOLS |
โ | Comma-separated allowlist. Unset = all minus DEFAULT_SKIP. |
๐๏ธ Tool Filtering
Default: every public pywa method except listen (which blocks indefinitely).
Allowlist: set PYWA_MCP_TOOLS=send_text,get_templates,send_template to expose only those.
โ ๏ธ Caveats
- No inbound webhook. This server only sends/admin.
listen,on_*,webhook_*register handlers / wait for inbound updates, but no FastAPI/Flask is run. For inbound support, run pywa's webhook in a separate process. stream_mediareturns a Python generator โ unusable via MCP JSON transport. Useget_media_bytes(base64) ordownload_media(writes to disk, returns path).- 24-hour window. Free-form sends to a user require they messaged you in the last 24h. Otherwise use an approved template.
- WABA health. Check
get_business_account/get_business_phone_numberโ payment, calling SIP, and other issues cause silent send failures (can_send_message=BLOCKED). - Schema drops type info for unions. MCP transport may stringify complex args; this server compensates by JSON-parsing strings when target type expects list/dict/dataclass.
๐ Response Serialization
| Input | Output |
|---|---|
bytes |
{"_bytes_b64": "...", "size": N} |
pathlib.Path |
string |
datetime / date / time |
ISO 8601 |
timedelta |
seconds (float) |
enum.Enum |
.value |
| dataclass | recursive dict |
pydantic BaseModel |
model_dump(mode="json") |
| other | JSON if serializable, else repr() |
๐งช Development
git clone https://github.com/ianaleck/pywa-mcp-server.git
cd pywa-mcp-server
uv sync
# Run tests
uv run pytest tests/
# With coverage
uv run pytest tests/ --cov=main --cov-report=term-missing
37 unit tests, ~70% coverage. Remainder is async server boot (not unit-testable).
๐ API Requirements
This server requires a WhatsApp Cloud API account. You must comply with:
๐ค Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes with tests
- Ensure all tests pass (
uv run pytest tests/) - Commit your changes
- Open a Pull Request
๐ License
MIT โ see LICENSE.
๐ Acknowledgments
- pywa by David Lev โ the underlying WhatsApp Cloud API client
- Model Context Protocol โ protocol spec
- Anthropic โ Claude and the MCP SDK
- Meta โ WhatsApp Cloud API
๐ Support
- ๐ Bug Reports
- ๐ก Feature Requests
- ๐ MCP Documentation
- ๐ pywa Documentation
Made with โค๏ธ for the MCP community
โญ Star this project if you find it useful!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pywa_mcp_server-0.1.0.tar.gz.
File metadata
- Download URL: pywa_mcp_server-0.1.0.tar.gz
- Upload date:
- Size: 49.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ea04476c34479dd66aed5ecfefcb922a9ce94c5ecb226c4784c952e17d43861
|
|
| MD5 |
b1cc223a43a0e91a324d5987d58643c7
|
|
| BLAKE2b-256 |
dd35ef519c43e93dc15490d63dac7fd355348f8fa4de48200632415a08574641
|
Provenance
The following attestation bundles were made for pywa_mcp_server-0.1.0.tar.gz:
Publisher:
publish.yml on ianaleck/pywa-mcp-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pywa_mcp_server-0.1.0.tar.gz -
Subject digest:
2ea04476c34479dd66aed5ecfefcb922a9ce94c5ecb226c4784c952e17d43861 - Sigstore transparency entry: 1591448851
- Sigstore integration time:
-
Permalink:
ianaleck/pywa-mcp-server@ea75453d642d8c1397c4f4f0dbd228a849d10887 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ianaleck
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ea75453d642d8c1397c4f4f0dbd228a849d10887 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pywa_mcp_server-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pywa_mcp_server-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70d299a14c5e1028c35a0916d3819e71290084f251fb720c706a9e862c05e243
|
|
| MD5 |
b5a9dfe9c85a479dcc7d55033787666b
|
|
| BLAKE2b-256 |
bdcaa5b8eb352f4cbb822c21775b7d9e615414b12c8d8e1d4b94b992671bb234
|
Provenance
The following attestation bundles were made for pywa_mcp_server-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on ianaleck/pywa-mcp-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pywa_mcp_server-0.1.0-py3-none-any.whl -
Subject digest:
70d299a14c5e1028c35a0916d3819e71290084f251fb720c706a9e862c05e243 - Sigstore transparency entry: 1591448880
- Sigstore integration time:
-
Permalink:
ianaleck/pywa-mcp-server@ea75453d642d8c1397c4f4f0dbd228a849d10887 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ianaleck
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ea75453d642d8c1397c4f4f0dbd228a849d10887 -
Trigger Event:
release
-
Statement type: