WhatsApp MCP server
What is mario andreschak mcp whatsapp web
MCP WhatsApp Web (TypeScript)
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)
!image !image
Features
- TypeScript Implementation: Fully typed codebase for better developer experience and code reliability
- WhatsApp Web Integration: Uses whatsapp-web.js for direct connection to WhatsApp Web
- MCP Server: Implements the Model Context Protocol for seamless integration with AI assistants
- Media Support: Send and receive images, videos, documents, and audio messages
- Multiple Transport Options: Supports both stdio and SSE transports for flexible integration
Architecture
This MCP server consists of:
- TypeScript MCP Server: Implements the Model Context Protocol to provide standardized tools for AI assistants to interact with WhatsApp
- WhatsApp Web Service: Connects to WhatsApp Web via whatsapp-web.js, handles authentication, and manages message sending/receiving
- Tool Implementations: Provides various tools for contacts, chats, messages, media, and authentication
Prerequisites
- Node.js >= 18.0.0
- npm or yarn
- Chrome/Chromium (used by Puppeteer for WhatsApp Web connection)
- FFmpeg (optional, for audio message conversion)
Installation
Manual Installation
-
Clone this repository
git clone https://github.com/mario-andreschak/mcp-whatsapp-web.git cd mcp-whatsapp-web
-
Install dependencies
npm install
-
Build the project
npm run build
-
Configure environment variables (optional)
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.
Installation with FLUJO
FLUJO provides a streamlined installation process:
- Navigate to the MCP section in FLUJO
- Click "Add Server"
- Copy and paste this GitHub repository URL:
https://github.com/mario-andreschak/mcp-whatsapp-web
- Click "Parse", "Clone, "Install", "Build" and "Update Server"
FLUJO will automatically handle the cloning, dependency installation, and building process for you.
Usage
Starting the MCP Server
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.
Development Mode
npm run dev
This starts the server in development mode with TypeScript watch mode and automatic server restarts.
Debugging with MCP Inspector
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:
- View all available tools and their schemas
- Execute tools directly and see their responses
- Test your server without needing to connect it to an AI assistant
- Debug tool execution and inspect responses
Connecting to Claude Desktop
-
Create a configuration file for 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
claude_desktop_config.json
in your Claude Desktop configuration directory:- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
- Linux:
~/.config/Claude/claude_desktop_config.json
- macOS:
-
Restart Claude Desktop
Connecting to Cursor
-
Create a configuration file for Cursor:
{ "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%\.cursor\mcp.json
- macOS/Linux:
-
Restart Cursor
Authentication
The first time you run the server, you'll need to authenticate with WhatsApp:
- Start the MCP server
- Important: You must use the
get_qr_code
tool to generate a QR code- In Claude or other AI assistants, explicitly ask to "use the get_qr_code tool to authenticate WhatsApp"
- The assistant will call this tool and display the QR code image
- Scan the QR code with your WhatsApp mobile app
- Open WhatsApp on your phone
- Go to Settings > Linked Devices > Link a Device
- Point your phone camera at the QR code displayed
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.
Authentication Status and Logout
You can check your current authentication status and manage your session:
- Use the
check_auth_status
tool to verify if you're currently authenticated - If you need to authenticate with a different WhatsApp account or re-authenticate:
- Use the
logout
tool to log out from your current session - Then use the
get_qr_code
tool to authenticate with a new QR code
- Use the
This 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
Available MCP Tools
Authentication
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 session
Contacts
search_contacts
- Search for contacts by name or phone numberget_contact
- Get information about a specific contact
Chats
list_chats
- List available chats with metadataget_chat
- Get information about a specific chatget_direct_chat_by_contact
- Find a direct chat with a specific contact
Messages
list_messages
- Retrieve messages with optional filtersget_message
- Get a specific message by IDsend_message
- Send a text message to a chat
Media
send_file
- Send a file (image, video, document) to a chatsend_audio_message
- Send an audio message (voice note)download_media
- Download media from a message
Browser Process Management
This 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.
Automatic Browser Cleanup
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
Manual Browser Cleanup
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:
- Scan for Chrome processes that might be related to WhatsApp Web
- Display a list of potentially orphaned processes
- Ask for confirmation before terminating them
- Clean up the PID tracking file
Development
Project Structure
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 functions
Scripts
npm 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 processes
Troubleshooting
Authentication Issues
- If the QR code doesn't appear, try restarting the server
- If you're already authenticated, no QR code will be shown (use
check_auth_status
to verify) - If you need to re-authenticate, use the
logout
tool first, then request a new QR code - WhatsApp limits the number of linked devices; you may need to remove an existing device
- If you receive a message saying "No QR code is currently available," but you're already authenticated, this is normal behavior - use
check_auth_status
to confirm your authentication status
Connection Issues
- Make sure you have a stable internet connection
- If the connection fails, try restarting the server
- Check the logs for detailed error messages
Browser Process Issues
- If you notice high CPU usage or memory consumption, there might be orphaned Chrome processes
- Run
npm run cleanup-browsers
to detect and clean up orphaned processes - If the server crashes frequently, check for orphaned processes and clean them up
- On Windows, you can also use Task Manager to look for multiple Chrome processes with "headless" in the command line
- On Linux/macOS, use
ps aux | grep chrome
to check for orphaned processes
License
MIT
This project is a TypeScript port of the original whatsapp-mcp by lharries.
Leave a Comment
Frequently Asked Questions
What is MCP?
MCP (Model Context Protocol) is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications, providing a standardized way to connect AI models to different data sources and tools.
What are MCP Servers?
MCP Servers are lightweight programs that expose specific capabilities through the standardized Model Context Protocol. They act as bridges between LLMs like Claude and various data sources or services, allowing secure access to files, databases, APIs, and other resources.
How do MCP Servers work?
MCP Servers follow a client-server architecture where a host application (like Claude Desktop) connects to multiple servers. Each server provides specific functionality through standardized endpoints and protocols, enabling Claude to access data and perform actions through the standardized protocol.
Are MCP Servers secure?
Yes, MCP Servers are designed with security in mind. They run locally with explicit configuration and permissions, require user approval for actions, and include built-in security features to prevent unauthorized access and ensure data privacy.
Related MCP Servers
chrisdoc hevy mcp
sylphlab pdf reader mcp
An MCP server built with Node.js/TypeScript that allows AI agents to securely read PDF files (local or URL) and extract text, metadata, or page counts. Uses pdf-parse.
aashari mcp server atlassian bitbucket
Node.js/TypeScript MCP server for Atlassian Bitbucket. Enables AI systems (LLMs) to interact with workspaces, repositories, and pull requests via tools (list, get, comment, search). Connects AI directly to version control workflows through the standard MCP interface.
aashari mcp server atlassian confluence
Node.js/TypeScript MCP server for Atlassian Confluence. Provides tools enabling AI systems (LLMs) to list/get spaces & pages (content formatted as Markdown) and search via CQL. Connects AI seamlessly to Confluence knowledge bases using the standard MCP interface.
prisma prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
Zzzccs123 mcp sentry
mcp sentry for typescript sdk
zhuzhoulin dify mcp server
zhongmingyuan mcp my mac
zhixiaoqiang desktop image manager mcp
MCP 服务器,用于管理桌面图片、查看详情、压缩、移动等(完全让Trae实现)
zhixiaoqiang antd components mcp
An MCP service for Ant Design components query | 一个减少 Ant Design 组件代码生成幻觉的 MCP 服务,包含系统提示词、组件文档、API 文档、代码示例和更新日志查询
Submit Your MCP Server
Share your MCP server with the community
Submit Now