LW

lharries/whatsapp-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

6776 stars 1462 forks 质量 64 趋势 44MIT

WhatsApp MCP 服务器

概览

这是一个用于 WhatsApp 的模型上下文协议(MCP)服务器。 通过它,你可以搜索和阅读个人的Whatsapp消息(包括图片、视频、文档和音频消息),搜索联系人,并向个人或群组发送消息。你还可以发送包括图片、视频、文档和音频消息在内的媒体文件。 它通过 WhatsApp 网页多设备 API(使用whatsmeow库)直接连接到你。你所有的消息都存储在本地的 SQLite 数据库中,只有当代理通过你控制的工具访问时才发送给大型语言模型(如 Claude)。 这里有一个连接Claude时可以做的示例。 想获取我参与的其他项目的最新消息,请在这里输入您的邮箱 注意:与许多MCP服务器一样,WhatsApp的MCP也面临致命三重一案的影响。这意味着项目注入可能导致私人数据泄露。 - 开始 - Python 3。

概述(AI 翻译)

这是一个用于 WhatsApp 的模型上下文协议(MCP)服务器。

通过它,你可以搜索和阅读个人的Whatsapp消息(包括图片、视频、文档和音频消息),搜索联系人,并向个人或群组发送消息。你还可以发送包括图片、视频、文档和音频消息在内的媒体文件。

它通过 WhatsApp 网页多设备 API(使用whatsmeow库)直接连接到你的个人 WhatsApp 账户。你所有的消息都存储在本地的 SQLite 数据库中,只有当代理通过你控制的工具访问时才发送给大型语言模型(如 Claude)。

这里有一个连接Claude时可以做的示例。

想了解我参与的其他项目的最新消息,请在此输入您的邮箱

注意: 和许多MCP服务器一样,WhatsApp的MCP也受到致命三重打击的影响。这意味着项目注入可能导致私人数据被窃取。

安装

先决条件

  • 走
  • Python 3.6+
  • Anthropic Claude桌面应用(或光标)
  • UV(Python 包管理器),使用 curl -LsSf https://astral.sh/uv/install.sh | sh 安装
  • FFmpeg(optional)- 仅用于音频消息。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

WhatsApp MCP Server

This is a Model Context Protocol (MCP) server for WhatsApp.

With this you can search and read your personal Whatsapp messages (including images, videos, documents, and audio messages), search your contacts and send messages to either individuals or groups. You can also send media files including images, videos, documents, and audio messages.

It connects to your personal WhatsApp account directly via the Whatsapp web multidevice API (using the whatsmeow library). All your messages are stored locally in a SQLite database and only sent to an LLM (such as Claude) when the agent accesses them through tools (which you control).

Here’s an example of what you can do when it’s connected to Claude.

To get updates on this and other projects I work on enter your email here

Caution: as with many MCP servers, the WhatsApp MCP is subject to the lethal trifecta. This means that project injection could lead to private data exfiltration.

Installation

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

    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:

    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:

    {
      "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:

    ~/Library/Application Support/Claude/claude_desktop_config.json
    
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "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" ] } } }