Skip to main content
Glama

whatsmcp

一个无状态的 MCP 服务器,运行在 Cloudflare Workers 上,将 Z-API WhatsApp REST API 作为工具暴露,通过 Streamable HTTP 在 https://whatsmcp.unfld.dev/mcp 提供服务。

工具在构建时从 postman.json 生成,因此工具集跟随集合更新,而非手动维护。三个元工具(zapi_list_endpoints、zapi_describe_endpoint、zapi_request)始终注册,因此即使工具集过滤缩小了暴露范围,也永远不会出现无法访问的端点。

设置

bun install

在仓库根目录下创建 .dev.vars(已加入 gitignore),填入你的 Z-API 凭据:

MCP_AUTH_TOKEN=...
ZAPI_INSTANCE_ID=...
ZAPI_INSTANCE_TOKEN=...
ZAPI_CLIENT_TOKEN=...

ZAPI_INSTANCE_ID 和 ZAPI_INSTANCE_TOKEN 用于构建实例基础 URL;ZAPI_CLIENT_TOKEN 作为 Client-Token 头发送。MCP_AUTH_TOKEN 是客户端必须提供的静态 Bearer 令牌。

Related MCP server: WA MCP

本地运行

bun run dev

Wrangler 在 http://localhost:8787 上提供 Worker 服务。MCP 端点为 http://127.0.0.1:8787/mcp。客户端必须发送以下之一:

Authorization: Bearer <MCP_AUTH_TOKEN>
Authorization: <MCP_AUTH_TOKEN>

GET /health 是公开的,返回 { "ok": true, "name": "whatsmcp" }。

脚本

脚本

功能说明

bun run generate

从 Postman 集合重新生成 src/generated/endpoints.ts

bun run dev

使用 wrangler dev 在本地运行 Worker

bun run deploy

部署到 Cloudflare

bun run typecheck

tsc --noEmit

bun test

运行测试套件

bun run cf-typegen

从 wrangler.jsonc + .dev.vars 重新生成 worker-configuration.d.ts

修改 wrangler.jsonc 中的绑定或变量后,重新运行 bun run cf-typegen。

配置

ZAPI_TOOLSETS(wrangler.jsonc 中的普通变量,默认值为 *)选择哪些 Z-API 类别注册为工具——例如 instance,messages,groups。元工具忽略此过滤器。

部署

密钥不存储在 wrangler.jsonc 中。每个环境设置一次:

wrangler secret put MCP_AUTH_TOKEN
wrangler secret put ZAPI_INSTANCE_ID
wrangler secret put ZAPI_INSTANCE_TOKEN
wrangler secret put ZAPI_CLIENT_TOKEN
wrangler deploy

whatsmcp.unfld.dev 自定义域名在 wrangler.jsonc 中声明,首次部署时由 Cloudflare 配置。

连接客户端

{
  "mcpServers": {
    "whatsmcp": {
      "url": "https://whatsmcp.unfld.dev/mcp",
      "headers": { "Authorization": "Bearer <MCP_AUTH_TOKEN>" }
    }
  }
}

Authorization: Bearer <MCP_AUTH_TOKEN> 和裸的 Authorization: <MCP_AUTH_TOKEN> 格式均被接受。GET /health 是公开且无需认证的,用于健康检查。

Related MCP Connectors

  • Hosted MCP server connecting AI assistants to 9,000+ apps and 40,000+ actions via Zapier.

  • WhatsMCP connects Claude and other MCP-compatible AI agents directly to WhatsApp. Send and receive text, images, documents, and voice notes; manage groups (create, add/remove members, promote admins); look up contacts and profiles; follow channels; and read call and message history — all through a standard MCP interface. For voice use cases, WhatsMCP offers SIP-based calling plans (inbound-only, or full inbound/outbound) so AI voice agents can answer and place WhatsApp calls, plus low-latency WebSocket integrations with voice agent providers like ElevenLabs. Multiple WhatsApp accounts can be paired and managed per workspace, with webhook support for real-time inbound message delivery to your own infrastructure.

  • Hosted MCP server for your own WhatsApp accounts: messages, contacts, groups, channels, calls.

  • Your own WhatsApp as an MCP server: read, search and send from any MCP client.

Related MCP Servers

  • F
    license
    Not graded
    quality
    Not graded
    maintenance
    A self-hosted MCP server that connects AI clients to WhatsApp via the WAHA HTTP API. It enables users to manage sessions, search contacts, and send or receive messages and media directly through natural language interfaces.
    12 npm
    -
  • F
    license
    Not graded
    quality
    B
    maintenance
    WhatsApp MCP server that exposes messaging, groups, contacts, and profile management as tools and resources for AI agents, supporting Baileys and Meta Cloud API.
    23
    -
  • A
    license
    Not graded
    quality
    C
    maintenance
    MCP server that connects AI agents to WhatsApp using the multi-device API, enabling messaging, group management, and more as a regular user.
    11 npm
    MIT