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 是公开且无需认证的,用于健康检查。

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    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.
      8 npm
      -
    • A
      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.
      31
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server that connects AI agents to WhatsApp using the multi-device API, enabling messaging, group management, and more as a regular user.
      1
      MIT