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 v
Add this skill
npx mdskills install lharries/whatsapp-mcpComprehensive WhatsApp integration with rich media support and excellent setup documentation
1# WhatsApp MCP Server23This is a Model Context Protocol (MCP) server for WhatsApp.45With 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.67It connects to your **personal WhatsApp account** directly via the Whatsapp web multidevice API (using the [whatsmeow](https://github.com/tulir/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).89Here's an example of what you can do when it's connected to Claude.10111213> To get updates on this and other projects I work on [enter your email here](https://docs.google.com/forms/d/1rTF9wMBTN0vPfzWuQa2BjfGKdKIpTbyeKxhPMcEzgyI/preview)1415> *Caution:* as with many MCP servers, the WhatsApp MCP is subject to [the lethal trifecta](https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/). This means that project injection could lead to private data exfiltration.1617## Installation1819### Prerequisites2021- Go22- Python 3.6+23- Anthropic Claude Desktop app (or Cursor)24- UV (Python package manager), install with `curl -LsSf https://astral.sh/uv/install.sh | sh`25- 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.2627### Steps28291. **Clone this repository**3031 ```bash32 git clone https://github.com/lharries/whatsapp-mcp.git33 cd whatsapp-mcp34 ```35362. **Run the WhatsApp bridge**3738 Navigate to the whatsapp-bridge directory and run the Go application:3940 ```bash41 cd whatsapp-bridge42 go run main.go43 ```4445 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.4647 After approximately 20 days, you will might need to re-authenticate.48493. **Connect to the MCP server**5051 Copy the below json with the appropriate {{PATH}} values:5253 ```json54 {55 "mcpServers": {56 "whatsapp": {57 "command": "{{PATH_TO_UV}}", // Run `which uv` and place the output here58 "args": [59 "--directory",60 "{{PATH_TO_SRC}}/whatsapp-mcp/whatsapp-mcp-server", // cd into the repo, run `pwd` and enter the output here + "/whatsapp-mcp-server"61 "run",62 "main.py"63 ]64 }65 }66 }67 ```6869 For **Claude**, save this as `claude_desktop_config.json` in your Claude Desktop configuration directory at:7071 ```72 ~/Library/Application Support/Claude/claude_desktop_config.json73 ```7475 For **Cursor**, save this as `mcp.json` in your Cursor configuration directory at:7677 ```78 ~/.cursor/mcp.json79 ```80814. **Restart Claude Desktop / Cursor**8283 Open Claude Desktop and you should now see WhatsApp as an available integration.8485 Or restart Cursor.8687### Windows Compatibility8889If 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.9091#### Steps to get it working:92931. **Install a C compiler**94 We recommend using [MSYS2](https://www.msys2.org/) to install a C compiler for Windows. After installing MSYS2, make sure to add the `ucrt64\bin` folder to your `PATH`.95 → A step-by-step guide is available [here](https://code.visualstudio.com/docs/cpp/config-mingw).96972. **Enable CGO and run the app**9899 ```bash100 cd whatsapp-bridge101 go env -w CGO_ENABLED=1102 go run main.go103 ```104105Without this setup, you'll likely run into errors like:106107> `Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work.`108109## Architecture Overview110111This application consists of two main components:1121131. **Go WhatsApp Bridge** (`whatsapp-bridge/`): A Go application that connects to WhatsApp's web API, handles authentication via QR code, and stores message history in SQLite. It serves as the bridge between WhatsApp and the MCP server.1141152. **Python MCP Server** (`whatsapp-mcp-server/`): A Python server implementing the Model Context Protocol (MCP), which provides standardized tools for Claude to interact with WhatsApp data and send/receive messages.116117### Data Storage118119- All message history is stored in a SQLite database within the `whatsapp-bridge/store/` directory120- The database maintains tables for chats and messages121- Messages are indexed for efficient searching and retrieval122123## Usage124125Once connected, you can interact with your WhatsApp contacts through Claude, leveraging Claude's AI capabilities in your WhatsApp conversations.126127### MCP Tools128129Claude can access the following tools to interact with WhatsApp:130131- **search_contacts**: Search for contacts by name or phone number132- **list_messages**: Retrieve messages with optional filters and context133- **list_chats**: List available chats with metadata134- **get_chat**: Get information about a specific chat135- **get_direct_chat_by_contact**: Find a direct chat with a specific contact136- **get_contact_chats**: List all chats involving a specific contact137- **get_last_interaction**: Get the most recent message with a contact138- **get_message_context**: Retrieve context around a specific message139- **send_message**: Send a WhatsApp message to a specified phone number or group JID140- **send_file**: Send a file (image, video, raw audio, document) to a specified recipient141- **send_audio_message**: Send an audio file as a WhatsApp voice message (requires the file to be an .ogg opus file or ffmpeg must be installed)142- **download_media**: Download media from a WhatsApp message and get the local file path143144### Media Handling Features145146The MCP server supports both sending and receiving various media types:147148#### Media Sending149150You can send various media types to your WhatsApp contacts:151152- **Images, Videos, Documents**: Use the `send_file` tool to share any supported media type.153- **Voice Messages**: Use the `send_audio_message` tool to send audio files as playable WhatsApp voice messages.154 - For optimal compatibility, audio files should be in `.ogg` Opus format.155 - With FFmpeg installed, the system will automatically convert other audio formats (MP3, WAV, etc.) to the required format.156 - Without FFmpeg, you can still send raw audio files using the `send_file` tool, but they won't appear as playable voice messages.157158#### Media Downloading159160By default, just the metadata of the media is stored in the local database. The message will indicate that media was sent. To access this media you need to use the download_media tool which takes the `message_id` and `chat_jid` (which are shown when printing messages containing the meda), this downloads the media and then returns the file path which can be then opened or passed to another tool.161162## Technical Details1631641. Claude sends requests to the Python MCP server1652. The MCP server queries the Go bridge for WhatsApp data or directly to the SQLite database1663. The Go accesses the WhatsApp API and keeps the SQLite database up to date1674. Data flows back through the chain to Claude1685. When sending messages, the request flows from Claude through the MCP server to the Go bridge and to WhatsApp169170## Troubleshooting171172- If you encounter permission issues when running uv, you may need to add it to your PATH or use the full path to the executable.173- Make sure both the Go application and the Python server are running for the integration to work properly.174175### Authentication Issues176177- **QR Code Not Displaying**: If the QR code doesn't appear, try restarting the authentication script. If issues persist, check if your terminal supports displaying QR codes.178- **WhatsApp Already Logged In**: If your session is already active, the Go bridge will automatically reconnect without showing a QR code.179- **Device Limit Reached**: WhatsApp limits the number of linked devices. If you reach this limit, you'll need to remove an existing device from WhatsApp on your phone (Settings > Linked Devices).180- **No Messages Loading**: After initial authentication, it can take several minutes for your message history to load, especially if you have many chats.181- **WhatsApp Out of Sync**: If your WhatsApp messages get out of sync with the bridge, delete both database files (`whatsapp-bridge/store/messages.db` and `whatsapp-bridge/store/whatsapp.db`) and restart the bridge to re-authenticate.182183For additional Claude Desktop integration troubleshooting, see the [MCP documentation](https://modelcontextprotocol.io/quickstart/server#claude-for-desktop-integration-issues). The documentation includes helpful tips for checking logs and resolving common issues.184
Full transparency — inspect the skill content before installing.