whatsmcp
A stateless MCP server that exposes the Z-API WhatsApp REST API as tools, enabling AI assistants to send messages, manage groups, and interact with WhatsApp through natural language commands.
README
whatsmcp
An MCP server on Cloudflare Workers that exposes the
Z-API WhatsApp REST API as tools, served over Streamable HTTP at
https://whatsmcp.unfld.dev/mcp.
Tools are generated at build time from postman.json, so the tool surface tracks
the collection rather than being hand-maintained. Three meta-tools (zapi_list_endpoints,
zapi_describe_endpoint, zapi_request) are always registered, so no endpoint is ever unreachable
even when the toolset filter narrows what gets exposed.
Z-API does not keep message bodies. This Worker also accepts Z-API webhooks, stores events in
Cloudflare D1, and exposes whatsmcp_history_list / whatsmcp_history_get /
whatsmcp_history_search so clients can read inbound replies. Chat tags from
GET /chats (optional string etiqueta ids) are snapshotted separately; filter
history with whatsmcp_history_list tag= after whatsmcp_chats_sync or a
webhook on that chat. Image/audio/document/video links from received webhooks
are stored as mediaUrl (Z-API hosted, ~30 days; not copied to R2).
Setup
bun install
Create .dev.vars in the repo root (gitignored) with your Z-API credentials:
MCP_AUTH_TOKEN=...
WEBHOOK_AUTH_TOKEN=...
ZAPI_INSTANCE_ID=...
ZAPI_INSTANCE_TOKEN=...
ZAPI_CLIENT_TOKEN=...
ZAPI_INSTANCE_ID and ZAPI_INSTANCE_TOKEN build the instance base URL; ZAPI_CLIENT_TOKEN is sent
as the Client-Token header. MCP_AUTH_TOKEN is the static bearer token clients must present.
WEBHOOK_AUTH_TOKEN is the query token on webhook URLs (?token=).
Local run
bun run dev
Wrangler serves the Worker at http://localhost:8787. The MCP endpoint is
http://127.0.0.1:8787/mcp. Clients must send one of:
Authorization: Bearer <MCP_AUTH_TOKEN>
Authorization: <MCP_AUTH_TOKEN>
GET /health is public and returns { "ok": true, "name": "whatsmcp" }.
GET /icon.png and GET /icon.svg are also public (the MCP server advertises them
as its icons).
Webhook ingest (HTTPS only; Z-API will not call local http://):
POST /webhooks/on-message-sent?token=<WEBHOOK_AUTH_TOKEN>
POST /webhooks/on-message-received?token=<WEBHOOK_AUTH_TOKEN>
POST /webhooks/on-disconnect?token=<WEBHOOK_AUTH_TOKEN>
POST /webhooks/on-connect?token=<WEBHOOK_AUTH_TOKEN>
POST /webhooks/on-message-status-received?token=<WEBHOOK_AUTH_TOKEN>
POST /webhooks/on-chat-presence?token=<WEBHOOK_AUTH_TOKEN>
Register those six URLs separately (the whatsmcp_register_webhooks tool does this).
Also enable Notificar as enviadas por mim também on the received webhook (the register
tool turns this on) so messages you send are stored with fromMe: true and show up in
history next to inbound replies.
Do not use Z-API update-every-webhooks — it points every event type at one URL.
Scripts
| Script | What it does |
|---|---|
bun run generate |
Regenerate src/generated/endpoints.ts from the Postman collection |
bun run dev |
Run the Worker locally with wrangler dev |
bun run deploy |
Deploy to Cloudflare |
bun run typecheck |
tsc --noEmit |
bun test |
Run the test suite |
bun run cf-typegen |
Regenerate worker-configuration.d.ts from wrangler.jsonc + .dev.vars |
Rerun bun run cf-typegen after changing bindings or vars in wrangler.jsonc.
Configuration
ZAPI_TOOLSETS (a plain var in wrangler.jsonc, default *) selects which Z-API categories
register as tools — for example instance,messages,groups. The meta-tools ignore this filter.
Deploying
Secrets are not stored in wrangler.jsonc. Set them once per environment:
wrangler secret put MCP_AUTH_TOKEN
wrangler secret put WEBHOOK_AUTH_TOKEN
wrangler secret put ZAPI_INSTANCE_ID
wrangler secret put ZAPI_INSTANCE_TOKEN
wrangler secret put ZAPI_CLIENT_TOKEN
wrangler d1 migrations apply whatsmcp --remote
wrangler deploy
The whatsmcp.unfld.dev custom domain is declared in wrangler.jsonc and is provisioned by
Cloudflare on first deploy.
Connecting a client
{
"mcpServers": {
"whatsmcp": {
"url": "https://whatsmcp.unfld.dev/mcp",
"headers": { "Authorization": "Bearer <MCP_AUTH_TOKEN>" }
}
}
}
Both Authorization: Bearer <MCP_AUTH_TOKEN> and the bare
Authorization: <MCP_AUTH_TOKEN> form are accepted. GET /health is public
and unauthenticated for uptime checks. The server icon is at
https://whatsmcp.unfld.dev/icon.png (SVG at /icon.svg).
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。