WhatsApp MCP Server

io.github.nakulben由 GitHub 帳號 nakulben 發布v0.1.0更新於 Oct 24, 2026

Manage WhatsApp Business templates and send messages via Meta Cloud API

已驗證STDIO僅桌面溝通與協作商業與電商

概覽

AI 產生的概覽

透過 Meta Cloud API 管理 WhatsApp Business 訊息範本並傳送範本訊息,可由 MCP 用戶端驅動。

可以做什麼
  • 驗證、建立、列出、檢視詳細資料、查詢狀態與刪除 WhatsApp Business 範本
  • 將已核准的範本訊息傳送給單一電話號碼,或批次傳送給多個號碼
  • 建立範本時自動辨識輪播、目錄、優惠碼、訂單詳情、商品訊息等範本變體
  • 可作為本機 stdio 程序執行,也可作為託管 HTTP 服務供遠端用戶端連線
適用情境
適合擁有 WhatsApp Business 帳號、想讓助理草擬、驗證並提交訊息範本,或直接在對話中向客戶傳送已核准範本的情境。
執行需求
需要 Python 3.10+ 並在本機安裝此套件,或自行架設 HTTP 端點。需要 Meta WhatsApp Business 帳號,以及具備 whatsapp_business_messaging 與 whatsapp_business_management 權限的系統使用者存取權杖,另需電話號碼 ID 與 WABA ID。憑證透過環境變數提供(META_ACCESS_TOKEN、META_PHONE_NUMBER_ID、META_WABA_ID,選用 META_APP_ID、META_API_VERSION),也可依請求以 Bearer 權杖或 X-Meta-* 標頭傳入。需要連線至 Meta Graph API 的網路。
安裝前請注意
Meta 存取權杖權限很大,可執行訊息傳送與業務管理操作,請勿寫入共用設定或日誌。相關工具會建立、刪除範本並向真實電話號碼傳送訊息,包含批次傳送,可能產生 Meta 訊息費用且無法撤回。託管 HTTP 模式可能未啟用驗證且僅服務一個 WhatsApp Business 帳號,任何能存取該網址的人都能操作。依請求傳入的憑證會以標頭或 base64 權杖形式交給伺服器,使用雲端用戶端時還會經過第三方服務。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 WhatsApp MCP Server,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

WhatsApp MCP Server

Manage WhatsApp Business templates and send messages from Claude, ChatGPT, Cursor, VS Code Copilot, or any MCP-compatible client — powered by the Meta Cloud API.

[MCP Compatible] [Meta API v24.0] [MIT License] [Python 3.10+]

What It Does

ToolDescription
validate_templateValidate a template payload before submitting to Meta
create_templateSubmit a template for Meta approval
list_templatesList templates with optional filters (status, category, name)
get_template_detailGet full details of a template by ID
check_template_statusQuick status check for a template
delete_templateDelete a template by name
send_template_messageSend an approved template to a phone number
send_bulk_template_messagesSend an approved template to multiple phone numbers

8 tools covering the full template lifecycle: create → validate → approve → send.

Quick Start

1. Clone & Install

bash
git clone https://github.com/nakulben/whatsapp-mcp.gitcd whatsapp-mcppython -m venv venvsource venv/bin/activate   # Windows: venv\Scripts\activatepip install -r requirements.txt

2. Configure Credentials

bash
cp .env.example .env
env
META_ACCESS_TOKEN=your_access_tokenMETA_WABA_ID=your_whatsapp_business_account_idMETA_PHONE_NUMBER_ID=your_phone_number_idMETA_APP_ID=your_app_id              # Optional, for media uploadsMETA_API_VERSION=v24.0               # Optional, defaults to v24.0

Environment variables are used by all modes — local stdio and hosted remote.

How to get these? Go to Meta for Developers, create or select your app, navigate to WhatsApp > API Setup.

3. Connect to Your MCP Client

The server supports 3 transport modes:

TransportCommandUsed By
stdio (default)python -m whatsapp_mcpClaude Desktop, Cursor, VS Code, Windsurf
ssepython -m whatsapp_mcp --transport sseLegacy remote clients
streamable-httppython -m whatsapp_mcp --transport streamable-httpClaude.ai, ChatGPT, newer MCP clients

For HTTP transports, you can customize host/port:

bash
python -m whatsapp_mcp --transport streamable-http --host 0.0.0.0 --port 8000

Claude Desktop (stdio — local)

Add to claude_desktop_config.json:

json
{  "mcpServers": {    "whatsapp": {      "command": "/path/to/whatsapp-mcp/venv/bin/python",      "args": ["-m", "whatsapp_mcp"],      "env": {        "META_ACCESS_TOKEN": "your_access_token",        "META_WABA_ID": "your_waba_id",        "META_PHONE_NUMBER_ID": "your_phone_number_id",        "META_APP_ID": "your_app_id"      }    }  }}
Claude.ai Web (remote — streamable-http)

Claude.ai connects to remote MCP servers as custom connectors. The connection originates from Anthropic's cloud servers, not from your machine.

  1. Host the server with env vars configured, behind HTTPS:
    bash
    python -m whatsapp_mcp --transport streamable-http --host 0.0.0.0 --port 8001
  2. Put it behind HTTPS using nginx, Caddy, or a tunnel (ngrok, Cloudflare Tunnel)
  3. In Claude.ai: go to Customize > Connectors → Add custom connector
  4. Enter your server URL (e.g. https://your-domain.com/mcp/)
  5. Claude supports authless or OAuth-based servers. For simplest setup, leave auth blank — the server will use the env vars you configured in step 1.

Note: Claude.ai does not support custom request headers. The server must be pre-configured with Meta credentials via environment variables. Each hosted server serves one WhatsApp Business Account.

Example nginx config
nginx
location /mcp/ {    proxy_pass http://127.0.0.1:8001/;    proxy_http_version 1.1;    proxy_set_header Upgrade $http_upgrade;    proxy_set_header Connection "upgrade";    proxy_set_header Host $host;    proxy_set_header X-Real-IP $remote_addr;    proxy_read_timeout 86400;}
ChatGPT (remote — Responses API)

ChatGPT supports remote MCP servers via the Responses API. It supports both Streamable HTTP and SSE transports.

Option 1 — Server pre-configured with env vars (simplest):

python
from openai import OpenAIclient = OpenAI()resp = client.responses.create(    model="gpt-4.1",    tools=[{        "type": "mcp",        "server_label": "whatsapp",        "server_url": "https://your-domain.com/mcp/",        "require_approval": "never",    }],    input="List all my approved templates",)

Option 2 — Per-request credentials via Bearer token:

Encode your Meta credentials as base64 JSON and pass them in the authorization field. OpenAI forwards this value as the Authorization header to your MCP server:

bash
# Create the tokenecho -n '{"access_token":"EAA...","phone_number_id":"123","waba_id":"456"}' | base64# Output: eyJhY2Nlc3NfdG9rZW4iOiJFQUEuLi4iLCJwaG9uZV9udW1iZXJfaWQiOiIxMjMiLCJ3YWJhX2lkIjoiNDU2In0=
python
resp = client.responses.create(    model="gpt-4.1",    tools=[{        "type": "mcp",        "server_label": "whatsapp",        "server_url": "https://your-domain.com/mcp/",        "authorization": "eyJhY2Nlc3NfdG9rZW4iOiJFQUEuLi4iLCJwaG9uZV9udW1iZXJfaWQiOiIxMjMiLCJ3YWJhX2lkIjoiNDU2In0=",        "require_approval": "never",    }],    input="List all my approved templates",)

Note: ChatGPT only supports remote MCP servers (no local stdio). Your server must be publicly accessible over HTTPS.

Cursor (stdio)

Add to .cursor/mcp.json in your project:

json
{  "mcpServers": {    "whatsapp": {      "command": "/path/to/whatsapp-mcp/venv/bin/python",      "args": ["-m", "whatsapp_mcp"]    }  }}
VS Code Copilot (stdio)

Add to .vscode/mcp.json:

json
{  "servers": {    "whatsapp": {      "type": "stdio",      "command": "/path/to/whatsapp-mcp/venv/bin/python",      "args": ["-m", "whatsapp_mcp"]    }  }}
Per-Request Credentials (direct HTTP / curl / scripts)

For programmatic access or custom MCP clients, you can pass per-request credentials instead of relying on server env vars. Two methods are supported:

Method 1 — Bearer token (recommended):

Base64-encode a JSON object with your Meta credentials:

bash
# Create the tokenTOKEN=$(echo -n '{"access_token":"EAA...","phone_number_id":"123","waba_id":"456"}' | base64)
# Use itcurl -H "Authorization: Bearer $TOKEN" https://your-server.com/mcp/ ...

Required fields: access_token, phone_number_id, waba_id. Optional: app_id, api_version.

Method 2 — X-Meta- headers:*

HeaderRequiredDescription
X-Meta-Access-TokenYesYour Meta access token
X-Meta-Phone-Number-IdYesYour WhatsApp phone number ID
X-Meta-Business-Account-IdYesYour WhatsApp Business Account ID
X-Meta-App-IdNoYour Meta app ID (for media uploads)
X-Meta-Api-VersionNoAPI version (defaults to v24.0)

If neither Bearer token nor X-Meta-* headers are present, the server falls back to environment variables.

Usage Examples

Once connected, just talk to your AI assistant:

"Create a marketing template called summer_sale with a header image, body text about 50% off, and a Shop Now button"

"List all my approved templates"

"Send the order_confirmation template to +919876543210 with order number ORD-456"

"Validate this template before I submit it: ..."

"Check the status of template ID 123456789"

Supported Template Types

Meta's API has 2 template categories(excluding Authentication). Within each category, templates can have different structural variants — each with its own component layout and validation rules.

Marketing Templates

Structural VariantCreateSendKey Components
Text / Image / Video / Document✅✅Header (optional) + Body + Footer + Buttons
Carousel✅✅Cards with per-card header, body, buttons
Catalog✅✅Body + CATALOG button
Limited-Time Offer (LTO)✅✅Body + limited_time_offer component + copy code button
Coupon Code✅✅Body + copy_code button
Multi-Product Message (MPM)✅✅Body + product_list action with sections
Single-Product Message (SPM)✅✅Body + product action
Product Card Carousel✅✅Body + product cards with buttons
Call Permission✅—Body + call_permission button

Utility Templates

Structural VariantCreateSendKey Components
Text / Image / Video / Document✅✅Header (optional) + Body + Footer + Buttons
Order Details✅✅Body + order_details button with payment payload
Order Status✅✅Body + order status parameters

How routing works: When you call create_template, the server inspects the components to auto-detect the structural variant (e.g., presence of cards[] → Carousel, CATALOG button → Catalog) and applies the correct validator. You just pass category: "MARKETING" or "UTILITY" — the variant is determined from the component structure.

Running Tests

bash
pip install pytest pytest-asynciopython -m pytest tests/ -v

Project Structure

whatsapp-mcp/├── whatsapp_mcp/│   ├── __init__.py          # Package version│   ├── __main__.py          # Entry point (python -m whatsapp_mcp)│   ├── config.py            # Environment config loader│   ├── meta_api.py          # Async Meta Graph API client│   ├── middleware.py         # ASGI middleware for per-request credentials│   ├── server.py            # MCP server with 8 tools│   ├── models/              # Pydantic data models│   │   ├── body.py          # Body component│   │   ├── header.py        # Header component (text/image/video/document)│   │   ├── footer.py        # Footer component│   │   ├── buttons.py       # Button types (URL, phone, quick reply, etc.)│   │   ├── buttons_component.py│   │   ├── enums.py         # Template categories, types, formats│   │   └── order_models.py  # Order-related models (checkout templates)│   └── validators/│       ├── create/          # 12 template creation validators│       └── send/            # 11 template send validators├── tests/│   ├── test_validators.py   # Validator tests│   ├── test_meta_api.py     # API client tests (mocked HTTP)│   └── test_tools.py        # MCP tool registration & helper tests├── .env.example├── requirements.txt├── LICENSE                  # MIT└── ROADMAP.md

Requirements

  • Python 3.10+
  • Meta WhatsApp Business Account
  • System User access token with whatsapp_business_messaging and whatsapp_business_management permissions

Dependencies

PackagePurpose
mcpModel Context Protocol SDK
httpxAsync HTTP client for Meta API
pydanticPayload validation
python-dotenvEnvironment config

Roadmap

See ROADMAP.md for planned features.

License

MIT — see LICENSE.


Built by Jina Connect — the WhatsApp Business CX platform.

來源:README.md,提交 412460d

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分