WhatsApp集成工具

一个提供WhatsApp消息发送、读取和搜索功能的集成工具,支持MCP服务器和CLI工具两种使用方式。

  • by Rohit678
  • JavaScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 Rohit678/whatsapp-mcp

使用说明

WhatsApp MCP+命令行界面

WhatsApp集成有两种方式:

  • MCP服务器 --让像克劳德这样的人工智能助手直接控制WhatsApp
  • CLI工具 --从您的终端发送/阅读WhatsApp消息

建立在 whatsapp-web.js.


特性

  • 通过联系人姓名或电话号码发送WhatsApp消息
  • 阅读任何聊天中的最新消息
  • 列出所有最近的聊天记录和预览
  • 按姓名搜索联系人
  • 可作为MCP服务器(Claude等)或独立CLI使用

设置

1.安装依赖项

npm install

2.验证WhatsApp

node index.js auth

使用WhatsApp移动应用程序扫描二维码。您的会话已保存在本地,您只需执行一次。


MCP服务器(用于Claude/AI助手)

MCP服务器通过stdio公开了4个工具:

工具 说明
send_message 向联系人发送消息
read_messages 阅读聊天中的最新消息
list_chats 列出最近的聊天记录和预览
search_contacts 按姓名搜索联系人

在Claude代码中配置

添加到您的 .mcp.json 或克劳德代码MCP设置:

{
  "mcpServers": {
    "whatsapp": {
      "command": "node",
      "args": ["C:/path/to/whatsapp-cli/mcp-server.mjs"]
    }
  }
}

手动运行

node mcp-server.mjs

命令行用法

发送消息

node index.js send --to "John Doe" --message "Hey!"
# or by phone number
node index.js send --to 919876543210 --message "Hey!"

读取消息

node index.js read --from "John Doe" --count 20

列出聊天记录

node index.js list-chats --count 10

用例

  • 基于人工智能的WhatsApp助手 --插入Claude或任何兼容MCP的AI,免提阅读和发送信息
  • WhatsApp自动化 --构建机器人、自动应答器或通知系统
  • 终端消息 --无需打开手机即可发送/阅读WhatsApp消息
  • 业务通知 --从脚本或cron作业发送自动WhatsApp警报

项目结构

├── index.js              # CLI entry point
├── mcp-server.mjs        # MCP server (for AI assistants)
├── src/
│   ├── client.js         # WhatsApp client setup
│   └── commands/
│       ├── auth.js       # QR code authentication
│       ├── send.js       # Send message command
│       ├── read.js       # Read messages command
│       └── list-chats.js # List chats command
└── package.json

需求

  • Node.js 18+
  • WhatsApp帐户(个人或企业)

许可证

麻省理工学院