
whatsapp mcp server
A WhatsApp MCP (Message Control Protocol) Server implementation
Repository Info
About This Server
A WhatsApp MCP (Message Control Protocol) Server implementation
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
WhatsApp MCP Server
A Multi-Channel Platform server for WhatsApp integration that allows you to send and receive messages programmatically through a REST API.
Features
- WhatsApp connection management with QR code authentication
- Send and receive text messages
- Send media messages (images, documents, etc.)
- Contact management
- Chat history
- Session persistence
- REST API for integration with other applications
Prerequisites
- Node.js (v14 or higher)
- MongoDB (optional but recommended for message storage)
- A WhatsApp account
Installation
- Clone the repository:
git clone https://github.com/krusleung/whatsapp-mcp-server.git
cd whatsapp-mcp-server
- Install dependencies:
npm install
- Create a
.envfile from the example:
cp .env.example .env
- Edit the
.envfile with your configuration
Running the Server
Start the development server:
npm run dev
For production:
npm start
API Documentation
Authentication
The server uses WhatsApp Web's QR code for authentication. When you start the server for the first time, a QR code will be displayed in the console. Scan this with your WhatsApp mobile app:
- Open WhatsApp on your phone
- Tap Menu or Settings and select WhatsApp Web
- Scan the QR code displayed in the terminal
API Endpoints
Auth Routes
GET /api/auth/status- Check authentication statusPOST /api/auth/logout- Logout from WhatsAppPOST /api/auth/restart- Restart the WhatsApp client
Message Routes
POST /api/messages/send- Send a text messagePOST /api/messages/send-media- Send a media messageGET /api/messages/history/:contact- Get chat history with a contact
Contact Routes
GET /api/contacts- Get all contactsGET /api/contacts/:id- Get a contact by IDGET /api/contacts/chats- Get all chats
Example Usage
Sending a Message
curl -X POST http://localhost:3000/api/messages/send \
-H "Content-Type: application/json" \
-d '{"to": "1234567890", "message": "Hello from WhatsApp MCP Server!"}'
Getting Contacts
curl -X GET http://localhost:3000/api/contacts
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
- whatsapp-web.js - WhatsApp Web API
- Express - Web framework
- Mongoose - MongoDB ODM
Quick Start
Clone the repository
git clone https://github.com/krusleung/whatsapp-mcp-serverInstall dependencies
cd whatsapp-mcp-server
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.