The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the WhatsApp Web MCP Server listing page.
Automation of Whatsapp Messages without Meta (Business-)API is against WhatsApp' Terms of Service! You take full responsibility for everything you do with this MCP-Server. It is possible that your account will be flagged/restricted.
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:
MCP_HTTP_PORT to additionally expose http://127.0.0.1:<port>/mcp, or run HTTP-only with --http)request_pairing_code tool, or automatically printed to stderr at startup via WHATSAPP_PAIRING_PHONE_NUMBER), and an optional OAuth flow for HTTP clients (MCP_OAUTH=true) where the browser authorization page shows the WhatsApp QR code — unlinking WhatsApp revokes tokens so clients automatically re-authenticateThis MCP server consists of:
webjs backend: Google Chrome or Microsoft Edge (auto-detected; needed for video/GIF codec support; other operations can use Puppeteer's bundled Chromium)baileys: install optional dependencies, including the native better-sqlite3 module. No Chrome, Edge, or Chromium is needed at runtime.FFmpeg is bundled automatically via the ffmpeg-static npm package — no manual installation needed. You can point the FFMPEG_PATH environment variable at your own binary to override it.
Clone this repository
Install dependencies
Build the project
Configure environment variables (optional)
Copy the example environment file and modify as needed:
You can select the backend with WHATSAPP_BACKEND, adjust logging levels, pin the WhatsApp Web version, or override the auto-detected browser (BROWSER_EXECUTABLE_PATH) and ffmpeg binary (FFMPEG_PATH). WHATSAPP_HEADLESS=false shows the web.js browser window, and WHATSAPP_SESSION_DIR relocates its persistent profile. Use an absolute session directory to keep it consistent across working directories.
WHATSAPP_BACKEND=webjs is the default and preserves existing sessions and MCP tool names. It uses a dedicated persistent LocalAuth profile, not your personal Chrome profile. It now keeps the browser's native user agent and graphics defaults, omits Puppeteer's automation banner flag, and leaves the browser sandbox enabled. Containers that require disabling the sandbox can explicitly set WHATSAPP_NO_SANDBOX=true. These settings do not guarantee that automation is undetectable.
To use the optional Baileys backend, set these variables in your MCP client configuration or .env, then restart the server:
BAILEYS_SESSION_DIR defaults to <working directory>/baileys-sessions; the example above should be replaced with your own absolute directory. Pair this backend separately with get_qr_code or request_pairing_code. The existing WHATSAPP_PAIRING_PHONE_NUMBER option also works. Baileys cannot reuse the web.js browser profile. You can switch back to webjs and resume its existing session.
Baileys and SQLite are pinned optional dependencies installed by normal npm install. If your package manager omitted them, run npm install --include=optional. SQLite uses a native addon; a supported prebuilt binary or a local native build toolchain is required. To avoid downloading Chromium when installing for Baileys or an existing system browser, use:
On macOS/Linux, the equivalent installation command is PUPPETEER_SKIP_DOWNLOAD=true npm install --include=optional. Selecting Baileys loads only its driver and never starts or cleans up browser processes. An unavailable backend produces an error; it never silently switches drivers or retries a send through another backend.
BAILEYS_SESSION_DIR/session.sqlite. Keep the whole directory private and out of version control. Only one running server may own a session directory. Use separate directories for independent accounts.BAILEYS_SESSION_DIR/oauth-store.json.get_backend_status reports the active backend, authentication, stored record counts and history synchronization state. Being connected does not mean history has finished arriving. An available history state means local data is available, not that WhatsApp supplied a complete archive.list_messages may request up to 100 additional older messages when a known chat has fewer than requested, with a bounded wait and a per-chat cooldown. Late history batches are persisted for subsequent queries. WhatsApp may still supply only part of an account's history.@c.us phone-number inputs, @s.whatsapp.net, groups and @lid identifiers are supported; known LID/phone mappings are persisted. Message IDs from web.js cannot be passed to Baileys or vice versa.The Baileys backend is opt-in and pinned to 7.0.0-rc14. Review upstream changes before upgrading, especially authentication and message-format migrations. See the Baileys documentation and release history.
FLUJO provides a streamlined installation process:
https://github.com/mario-andreschak/mcp-whatsapp-webFLUJO will automatically handle the cloning, dependency installation, and building process for you.
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_codetool and scanning the QR code with your phone. See the Authentication section for detailed instructions.
This starts the server in development mode with TypeScript watch mode and automatic server restarts.
This launches the MCP Inspector tool, which provides a web interface for testing and debugging your MCP server. The inspector allows you to:
Create a configuration file for Claude Desktop:
Replace PATH_TO with the absolute path to the repository.
Save this as claude_desktop_config.json in your Claude Desktop configuration directory:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.jsonRestart Claude Desktop
Create a configuration file for Cursor:
Replace PATH_TO with the absolute path to the repository.
Save this as mcp.json in your Cursor configuration directory:
~/.cursor/mcp.json%USERPROFILE%\.cursor\mcp.jsonRestart Cursor
The first time you run the server, you'll need to authenticate with WhatsApp:
get_qr_code tool to generate a QR code
Your 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:
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:
.chrome-pids.jsonIf you notice orphaned Chrome processes that weren't automatically cleaned up, you can use the included cleanup utility:
This utility will:
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 processesnpm test - Run the unit test suite (fast, no browser needed)npm run test:watch - Run unit tests in watch mode during developmentnpm run test:e2e - Build, then run end-to-end tests (spawns the real server incl. a headless browser)check_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.