WhatsApp MCP

WhatsApp MCP

通讯协作
Lukas Harries
claudecursorvscodegeneric
FreeOpen Source

关于此服务器

让 AI 智能体收发 WhatsApp 消息的 MCP 服务器。通过 WhatsApp Web 接口连接,支持发送文本消息、读取消息历史、管理联系人,实现 AI 驱动的 WhatsApp 自动化。

安装方式

npx -y whatsapp-mcp
官方 README 安装指南(英文原文)

Prerequisites

  • Go
  • Python 3.6+
  • Anthropic Claude Desktop app (or Cursor)
  • UV (Python package manager), install with curl -LsSf https://astral.sh/uv/install.sh | sh
  • FFmpeg (_optional_) - Only needed for audio messages. If you want to send audio files as playable WhatsApp voice messages, they must be in .ogg Opus format. With FFmpeg installed, the MCP server will automatically convert non-Opus audio files. Without FFmpeg, you can still send raw audio files using the send_file tool.

Steps

1. Clone this repository

bash
git clone https://github.com/lharries/whatsapp-mcp.git
cd whatsapp-mcp

2. Run the WhatsApp bridge

Navigate to the whatsapp-bridge directory and run the Go application:

bash
cd whatsapp-bridge
go run main.go

The first time you run it, you will be prompted to scan a QR code. Scan the QR code with your WhatsApp mobile app to authenticate.

After approximately 20 days, you will might need to re-authenticate.

3. Connect to the MCP server

Copy the below json with the appropriate {{PATH}} values:

json
{
  "mcpServers": {
    "whatsapp": {
      "command": "{{PATH_TO_UV}}", // Run `which uv` and place the output here
      "args": [
        "--directory",
        "{{PATH_TO_SRC}}/whatsapp-mcp/whatsapp-mcp-server", // cd into the repo, run `pwd` and enter the output here + "/whatsapp-mcp-server"
        "run",
        "main.py"
      ]
    }
  }
}

For Claude, save this as claude_desktop_config.json in your Claude Desktop configuration directory at:

text
~/Library/Application Support/Claude/claude_desktop_config.json

For Cursor, save this as mcp.json in your Cursor configuration directory at:

text
~/.cursor/mcp.json

4. Restart Claude Desktop / Cursor

Open Claude Desktop and you should now see WhatsApp as an available integration.

Or restart Cursor.

Windows Compatibility

If you're running this project on Windows, be aware that go-sqlite3 requires CGO to be enabled in order to compile and work properly. By default, CGO is disabled on Windows, so you need to explicitly enable it and have a C compiler installed.

Steps to get it working:

1. Install a C compiler

We recommend using MSYS2 to install a C compiler for Windows. After installing MSYS2, make sure to add the ucrt64\bin folder to your PATH.

→ A step-by-step guide is available here.

2. Enable CGO and run the app

bash
cd whatsapp-bridge
go env -w CGO_ENABLED=1
go run main.go

Without this setup, you'll likely run into errors like:

> Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work.

常见问题

WhatsApp MCP 怎么工作的?安全吗?

它通过 WhatsApp Web 协议连接,首次启动时需扫描二维码登录你的 WhatsApp。MCP 服务器在本地运行,消息不会通过第三方服务器中转。建议使用专用 WhatsApp 账号,避免个人账号被自动化操作影响。

WhatsApp MCP 能批量发消息吗?

支持向多个联系人依次发送个性化消息,但需注意 WhatsApp 有反垃圾机制,短时间内大量发送可能导致账号被限制。建议合理控制发送频率,避免触发风控。

WhatsApp MCP 能读聊天记录吗?

能。它可以读取最近的聊天消息列表和指定对话的消息内容,方便 AI 智能体理解上下文后进行回复或分析。但只读取你 WhatsApp 中已有的消息,不会访问端到端加密的云端备份。