Logo whatsapp-mcp-server

whatsapp-mcp-server

Cộng đồng
FredShred7

MCP server for WhatsApp Cloud API — send messages, read conversations, manage contacts, and handle media through AI assistants like Claude

Nhà phát hànhFredShred7
Kho mãwhatsapp-mcp-server
Ngôn ngữTypeScript
Bản fork
3
Sao
23
Công cụ có sẵn
0
Phương thức truyền tảistdio
Danh mục
Giấy phépMIT
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    whatsapp-mcp-server cung cấp các chức năng MCP cho các ứng dụng khách AI và tác nhân AI tương thích.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Mẫu cấu hình có thể sao chép ngay

    Dùng các đoạn cấu hình mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Mức độ quan tâm của cộng đồng đến kho mã

    23 sao và 3 bản fork từ kho mã được liên kết.

whatsapp-mcp-server

License: MIT Node.js TypeScript MCP Compatible Official Meta API WhatsApp Business No Ban Risk

A production-ready Model Context Protocol (MCP) server that connects AI assistants like Claude to the WhatsApp Cloud API (Meta). Send messages, manage conversations, handle media, send template messages, and receive real-time webhooks — all through natural language.


Why this MCP server?

This is the only WhatsApp MCP server built on the official Meta WhatsApp Cloud API.

Most WhatsApp tools for developers rely on unofficial browser automation libraries (whatsapp-web.js) or reverse-engineered protocols (whatsmeow, Baileys). These approaches violate WhatsApp's Terms of Service and carry a real risk of account bans. This project is different.

whatsapp-mcp-server (this project)Unofficial libraries (whatsapp-web.js, whatsmeow, Baileys)
API type✅ Official Meta WhatsApp Cloud API❌ Unofficial / reverse-engineered
Account ban risk✅ None — Meta-approved⚠️ High — violates WhatsApp ToS
Account type✅ WhatsApp Business accountPersonal account only
Uptime reliability✅ Meta SLA-backed infrastructure❌ Breaks when WhatsApp updates
Scalability✅ Business-grade, multi-agent ready❌ Limited to one session
Template messages✅ Full support❌ Not available
Media handling✅ Native Cloud API media endpoints⚠️ Workarounds required
Webhook support✅ Official Meta webhook events❌ Polling / fragile listeners
Production use✅ Built for production❌ Recommended for personal/hobby use only
Long-term viability✅ Stable, versioned API❌ Depends on reverse engineering staying current

Bottom line: if you are building anything beyond a personal experiment — customer support, automated notifications, business workflows — use the official API. This server gives you that, packaged as a drop-in MCP server.


Features

  • Send all message types — text, images, videos, audio, documents, reactions
  • Template messages — send and list approved WhatsApp Business templates with full component support
  • Media management — upload, retrieve, and delete media files
  • Conversation history — in-memory store of recent conversations via webhook
  • Real-time webhooks — receive incoming messages and delivery status updates
  • Business profile — read and update your WhatsApp Business profile
  • Contact lookup — validate phone numbers against WhatsApp
  • Rate limit handling — automatic exponential backoff retry logic
  • Type-safe — fully typed TypeScript with Zod input validation
  • Docker ready — multi-stage Dockerfile and docker-compose included
  • Works without webhook — send-only mode with no webhook server required

Architecture

┌─────────────────────────────────────────────────────────────┐
│                    AI Assistant (Claude)                      │
└──────────────────────────┬──────────────────────────────────┘
                           │ MCP Protocol (stdio)
                           │
┌──────────────────────────▼──────────────────────────────────┐
│                  whatsapp-mcp-server                         │
│                                                              │
│  ┌─────────────┐  ┌──────────────┐  ┌───────────────────┐  │
│  │  MCP Server │  │   Tools      │  │  WhatsApp Client  │  │
│  │  (stdio)    │◄─┤  messages    ├─►│  (Axios + retry)  │  │
│  │             │  │  contacts    │  └────────┬──────────┘  │
│  └─────────────┘  │  media       │           │              │
│                   │  templates   │           │ HTTPS        │
│  ┌─────────────┐  └──────────────┘           │              │
│  │  Webhook    │                             ▼              │
│  │  Server     │  ◄──── Incoming   ┌─────────────────────┐ │
│  │  (Express)  │       messages    │ WhatsApp Cloud API  │ │
│  └──────┬──────┘       & statuses  │  graph.facebook.com  │ │
└─────────│───────────────────────────┼─────────────────────┘ │
          │                           │                        │
          │ HTTP POST (Meta webhooks) │ HTTPS (send messages)  │
          │                           │                        │
     ┌────▼──────────────────────────▼──────────────┐
     │            WhatsApp Users                     │
     └────────────────────────────────────────────────┘

Webhook flow for incoming messages:
WhatsApp User → Meta Servers → POST /webhook → WhatsAppWebhook
→ in-memory conversation store → EventEmitter → MCP tools

Prerequisites

  1. Node.js 20+ — download
  2. Meta Developer Account — create one
  3. WhatsApp Business App configured in Meta App Dashboard
  4. Phone Number ID and Access Token from your WhatsApp app settings
  5. (Optional) A public HTTPS URL for receiving webhooks (use ngrok for local dev)

Quick Start

Option A — Run with npx (no clone required)

The package ships a whatsapp-mcp-server binary, so the fastest way to use it is to let your MCP client launch it via npx and pass credentials through env (see the client config blocks below):

bash
npx -y @fredshred7/whatsapp-mcp-server

npx downloads and runs the published package on demand — point your MCP client at it and you are done. Jump to Usage with Claude Desktop or Usage with Claude Code.

Option B — Clone and build from source

Step 1 — Clone and install:

bash
git clone https://github.com/FredShred7/whatsapp-mcp-server.git
cd whatsapp-mcp-server
npm install

Step 2 — Configure credentials:

bash
cp .env.example .env
# Edit .env with your WhatsApp credentials

Step 3 — Build:

bash
npm run build

Step 4 — Add to Claude Desktop or Claude Code (see sections below)

Step 5 — Test it: Ask Claude: "Send a WhatsApp message to +15551234567 saying Hello from Claude!"


Configuration

All configuration is via environment variables. Copy .env.example to .env and fill in the values.

VariableRequiredDescription
WHATSAPP_PHONE_NUMBER_IDYesYour WhatsApp phone number ID (from Meta App Dashboard > WhatsApp > API Setup)
WHATSAPP_ACCESS_TOKENYesPermanent access token for your app (generate in Meta App Dashboard)
WHATSAPP_WEBHOOK_VERIFY_TOKENWebhookRandom secret string — must match what you enter in Meta App Dashboard
WHATSAPP_APP_SECRETRecommendedMeta App Secret (App Dashboard > Settings > Basic). Used to verify the X-Hub-Signature-256 signature on incoming webhooks. Strongly recommended in production. If unset, signature verification is skipped (with a startup warning) so local dev still works.
WHATSAPP_BUSINESS_ACCOUNT_IDOptionalWhatsApp Business Account ID — required for listing phone numbers and templates
WHATSAPP_API_VERSIONOptionalWhatsApp Cloud API version (default: v21.0)
WEBHOOK_PORTOptionalPort for incoming webhook server (default: off). Set to 3000 to enable
WEBHOOK_PATHOptionalHTTP path for webhooks (default: /webhook)
LOG_LEVELOptionalLogging verbosity: info or debug (default: info)

Available Tools

ToolDescriptionKey Parameters
whatsapp_send_textSend a text messageto, text, preview_url?, reply_to_message_id?
whatsapp_send_imageSend an image with optional captionto, image_url, caption?
whatsapp_send_videoSend a video with optional captionto, video_url, caption?
whatsapp_send_audioSend an audio messageto, audio_url
whatsapp_send_documentSend a document/fileto, document_url, caption?, filename?
whatsapp_send_reactionReact to a message with emojito, message_id, emoji
whatsapp_mark_readMark a message as readmessage_id
whatsapp_list_conversationsList recent conversations (webhook required)limit?
whatsapp_get_conversationGet messages with a contact (webhook required)phone_number, limit?
whatsapp_get_message_statusGet delivery/read status (webhook required)message_id
whatsapp_get_contact⚠️ Legacy/unsupported — validate a phone number on WhatsApp (see note below)phone_number
whatsapp_get_business_profileGet your WhatsApp Business profile—
whatsapp_update_business_profileUpdate business profile infoabout?, address?, description?, email?, websites?, vertical?
whatsapp_upload_mediaUpload media from URL, get media IDmedia_url, mime_type, filename?
whatsapp_get_media_urlGet temporary download URL for mediamedia_id
whatsapp_delete_mediaDelete uploaded mediamedia_id
whatsapp_send_templateSend an approved template messageto, template_name, language_code, components?
whatsapp_list_templatesList available message templateslimit?

⚠️ whatsapp_get_contact is legacy and not expected to work on the Cloud API. It relies on the POST /{phone-number-id}/contacts "contact check", which was a feature of the legacy WhatsApp On-Premises API — not a Cloud API endpoint that was later removed. Per Meta's On-Premises API Sunset, the final On-Premises client version expired on 2025-10-23. The contact-check never existed in the WhatsApp Cloud API (the API this server uses), and the Cloud API has no contact-validation equivalent. (Even on On-Premises, Meta had degraded it to always return valid, so the result could not be trusted.) To determine whether a number can receive messages, send the message and inspect the message-status webhooks / error codes (e.g. 131026 "message undeliverable") instead. The tool is retained only for backwards compatibility.


Usage with Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows).

Recommended — run the published package via npx (no local build needed):

json
{
  "mcpServers": {
    "whatsapp": {
      "command": "npx",
      "args": ["-y", "@fredshred7/whatsapp-mcp-server"],
      "env": {
        "WHATSAPP_PHONE_NUMBER_ID": "your_phone_number_id",
        "WHATSAPP_ACCESS_TOKEN": "your_access_token",
        "WHATSAPP_WEBHOOK_VERIFY_TOKEN": "your_verify_token",
        "WHATSAPP_APP_SECRET": "your_app_secret",
        "WHATSAPP_BUSINESS_ACCOUNT_ID": "your_business_account_id",
        "WEBHOOK_PORT": "3000"
      }
    }
  }
}

Alternatively — run a local build (after cloning and npm run build):

json
{
  "mcpServers": {
    "whatsapp": {
      "command": "node",
      "args": ["/absolute/path/to/whatsapp-mcp-server/dist/index.js"],
      "env": {
        "WHATSAPP_PHONE_NUMBER_ID": "your_phone_number_id",
        "WHATSAPP_ACCESS_TOKEN": "your_access_token",
        "WHATSAPP_WEBHOOK_VERIFY_TOKEN": "your_verify_token",
        "WHATSAPP_APP_SECRET": "your_app_secret",
        "WHATSAPP_BUSINESS_ACCOUNT_ID": "your_business_account_id",
        "WEBHOOK_PORT": "3000"
      }
    }
  }
}

Restart Claude Desktop after saving. You should see the WhatsApp tools available in the tools panel.


Usage with Claude Code

Add to your Claude Code MCP settings (~/.claude/settings.json or project-level .claude/settings.json). Using the published package via npx:

json
{
  "mcpServers": {
    "whatsapp": {
      "command": "npx",
      "args": ["-y", "@fredshred7/whatsapp-mcp-server"],
      "env": {
        "WHATSAPP_PHONE_NUMBER_ID": "your_phone_number_id",
        "WHATSAPP_ACCESS_TOKEN": "your_access_token",
        "WHATSAPP_WEBHOOK_VERIFY_TOKEN": "your_verify_token",
        "WHATSAPP_APP_SECRET": "your_app_secret",
        "WHATSAPP_BUSINESS_ACCOUNT_ID": "your_business_account_id",
        "WEBHOOK_PORT": "3000"
      }
    }
  }
}

Or use the CLI to add it:

bash
claude mcp add whatsapp npx -y @fredshred7/whatsapp-mcp-server

Webhook Setup

Webhooks allow you to receive incoming messages and delivery status updates. They are optional — the MCP server works without them for sending messages only.

Local development with ngrok

bash
# 1. Install ngrok: https://ngrok.com/download
# 2. Start your webhook server
WEBHOOK_PORT=3000 npm run dev

# 3. In another terminal, expose it publicly
ngrok http 3000

# 4. Copy the HTTPS URL (e.g. https://abc123.ngrok.io)

Configure in Meta App Dashboard

  1. Go to Meta App Dashboard > Your App > WhatsApp > Configuration
  2. Set Callback URL to: https://your-ngrok-url.ngrok.io/webhook
  3. Set Verify Token to match your WHATSAPP_WEBHOOK_VERIFY_TOKEN
  4. Click Verify and Save
  5. Subscribe to the messages webhook field

Production

For production, deploy this server behind a reverse proxy (nginx, Caddy, etc.) with a valid TLS certificate. Set WEBHOOK_PORT to your internal port and expose it via HTTPS on port 443.


Docker Deployment

Build and run with docker-compose

bash
# Copy and fill in your credentials
cp .env.example .env

# Build and start
docker-compose up -d

# View logs
docker-compose logs -f

# Stop
docker-compose down

Build manually

bash
# Build image
docker build -t whatsapp-mcp-server .

# Run (send-only, no webhook)
docker run --rm -i \
  -e WHATSAPP_PHONE_NUMBER_ID=xxx \
  -e WHATSAPP_ACCESS_TOKEN=xxx \
  whatsapp-mcp-server

# Run with webhook server
docker run --rm -i \
  -p 3000:3000 \
  --env-file .env \
  whatsapp-mcp-server

Note: When using Docker with Claude Desktop/Code, the MCP transport uses stdio. Make sure to pass -i (interactive) so stdin/stdout remain connected. The webhook port is separate from the MCP transport.


Development

bash
# Install dependencies
npm install

# Run with auto-reload
npm run dev

# Type-check only (no build)
npm run typecheck

# Build
npm run build

# Lint
npm run lint

# Run the test suite
npm test

# Re-run tests on change
npm run test:watch

Project structure

src/
├── index.ts              # Entry point — loads env, wires up components
├── server.ts             # MCP server — registers tools, handles requests
├── whatsapp/
│   ├── client.ts         # WhatsApp Cloud API client with retry logic
│   ├── types.ts          # TypeScript types and interfaces
│   └── webhook.ts        # Express webhook server + in-memory store
└── tools/
    ├── shared.ts         # Shared helpers: formatError + Zod->JSON Schema
    ├── messages.ts       # Send/receive message tools
    ├── contacts.ts       # Contact and business profile tools
    ├── media.ts          # Media upload/download/delete tools
    └── templates.ts      # Template message tools

test/                     # Vitest unit tests (schema, errors, webhook)

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for guidelines on reporting bugs, suggesting features, and submitting pull requests.


License

MIT — Copyright (c) 2025 FredShred7

Cài đặt

TypingMind
{
  "mcpServers": {
    "fredshred7-whatsapp-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "@fredshred7/whatsapp-mcp-server"
      ],
      "env": {
        "WHATSAPP_PHONE_NUMBER_ID": "<WHATSAPP_PHONE_NUMBER_ID>",
        "WHATSAPP_ACCESS_TOKEN": "<WHATSAPP_ACCESS_TOKEN>"
      }
    }
  }
}

Dùng MCP whatsapp-mcp-server với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối whatsapp-mcp-server, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Thiết lập trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Thiết lập trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh thiết lập trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Để tiến trình tiếp tục chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Để tiến trình tiếp tục chạy trong cửa sổ Terminal khi bạn dùng các công cụ MCP.
3

Thêm whatsapp-mcp-server làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của whatsapp-mcp-server.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "fredshred7-whatsapp-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "@fredshred7/whatsapp-mcp-server"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của whatsapp-mcp-server, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của whatsapp-mcp-server.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện trên TypingMind dùng các công cụ MCP đã bật với mô hình AI đã chọn
Bạn có thể dùng whatsapp-mcp-server giúp tôi làm việc này không?
whatsapp-mcp-server
Được. Tôi đọc rồi.
Đây là kết quả tôi tìm được bằng whatsapp-mcp-server.

Câu hỏi thường gặp

Máy chủ MCP whatsapp-mcp-server dùng để làm gì?

whatsapp-mcp-server là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP whatsapp-mcp-server với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng whatsapp-mcp-server với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP whatsapp-mcp-server với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối whatsapp-mcp-server, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP whatsapp-mcp-server với TypingMind?

whatsapp-mcp-server hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP whatsapp-mcp-server cung cấp những công cụ nào trong TypingMind?

whatsapp-mcp-server cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP whatsapp-mcp-server không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu whatsapp-mcp-server yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇