mcp whatsapp web
Whatsapp-Web MCP
Whatsapp-Web MCP
A Model Context Protocol (MCP) server for WhatsApp Web, implemented in TypeScript. This project is a TypeScript port of the original whatsapp-mcp repository.
With this MCP server, you can: - Search and read your personal WhatsApp messages (including media) - Search your contacts - Send messages to individuals or groups - Send and receive media files (images, videos, documents, audio)
This MCP server consists of:
git clone https://github.com/mario-andreschak/mcp-whatsapp-web.git
cd mcp-whatsapp-web
npm install
npm run build
Copy the example environment file and modify as needed:
cp .env.example .env
You can adjust logging levels and specify paths to FFmpeg if needed.
FLUJO provides a streamlined installation process:
https://github.com/mario-andreschak/mcp-whatsapp-web
FLUJO will automatically handle the cloning, dependency installation, and building process for you.
npm start
This will start the MCP server using stdio transport by default, which is suitable for integration with Claude Desktop or similar applications.
Important: After starting the server for the first time, you must authenticate with WhatsApp by using the
get_qr_code
tool and scanning the QR code with your phone. See the Authentication section for detailed instructions.
npm run dev
This starts the server in development mode with TypeScript watch mode and automatic server restarts.
npm run debug
This launches the MCP Inspector tool, which provides a web interface for testing and debugging your MCP server. The inspector allows you to:
{
"mcpServers": {
"whatsapp": {
"command": "node",
"args": [
"PATH_TO/dist/index.js"
]
}
}
}
Replace PATH_TO
with the absolute path to the repository.
Save this as claude_desktop_config.json
in your Claude Desktop configuration directory:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%Claudeclaude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
Restart Claude Desktop
{
"mcpServers": {
"whatsapp": {
"command": "node",
"args": [
"PATH_TO/dist/index.js"
]
}
}
}
Replace PATH_TO
with the absolute path to the repository.
Save this as mcp.json
in your Cursor configuration directory:
macOS/Linux: ~/.cursor/mcp.json
Windows: %USERPROFILE%.cursormcp.json
Restart Cursor
The first time you run the server, you'll need to authenticate with WhatsApp:
get_qr_code
tool to generate a QR codeYour session will be saved locally in the whatsapp-sessions
directory and will be reused automatically on subsequent runs. If you don't authenticate using the QR code, you won't be able to use any WhatsApp functionality.
You can check your current authentication status and manage your session:
check_auth_status
tool to verify if you're currently authenticatedlogout
tool to log out from your current sessionget_qr_code
tool to authenticate with a new QR codeThis is particularly useful when: - You want to switch between different WhatsApp accounts - Your session has expired or been invalidated - You're experiencing connection issues and need to re-authenticate
get_qr_code
- Get the QR code for WhatsApp Web authenticationcheck_auth_status
- Check if you're currently authenticated with WhatsApplogout
- Log out from WhatsApp and clear the current sessionsearch_contacts
- Search for contacts by name or phone numberget_contact
- Get information about a specific contactlist_chats
- List available chats with metadataget_chat
- Get information about a specific chatget_direct_chat_by_contact
- Find a direct chat with a specific contactlist_messages
- Retrieve messages with optional filtersget_message
- Get a specific message by IDsend_message
- Send a text message to a chatsend_file
- Send a file (image, video, document) to a chatsend_audio_message
- Send an audio message (voice note)download_media
- Download media from a messageThis MCP server uses Puppeteer to control Chrome browsers for WhatsApp Web connectivity. The server includes a robust browser process management system to prevent orphaned Chrome processes.
The server automatically:
- Tracks Chrome browser processes using a PID tracking system
- Cleans up orphaned processes on startup
- Properly closes browser processes during shutdown
- Maintains a record of browser PIDs in .chrome-pids.json
If you notice orphaned Chrome processes that weren't automatically cleaned up, you can use the included cleanup utility:
npm run cleanup-browsers
This utility will: 1. Scan for Chrome processes that might be related to WhatsApp Web 2. Display a list of potentially orphaned processes 3. Ask for confirmation before terminating them 4. Clean up the PID tracking file
src/index.ts
- Entry pointsrc/server.ts
- MCP server implementationsrc/services/whatsapp.ts
- WhatsApp Web servicesrc/tools/
- Tool implementations for various WhatsApp featuressrc/types/
- TypeScript type definitionssrc/utils/
- Utility functionsnpm run build
- Build the TypeScript codenpm run dev
- Run in development mode with watchnpm run lint
- Run ESLintnpm run format
- Format code with Prettiernpm run cleanup-browsers
- Detect and clean up orphaned Chrome browser processescheck_auth_status
to verify)logout
tool first, then request a new QR codecheck_auth_status
to confirm your authentication statusnpm run cleanup-browsers
to detect and clean up orphaned processesps aux | grep chrome
to check for orphaned processesMIT
This project is a TypeScript port of the original whatsapp-mcp by lharries.