WhatsApp MCP Server
Enables sending WhatsApp text messages, audio files, voice notes, TTS messages, task completion notifications, and listing contacts through WhatsApp Web, with session authentication and media support.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
WhatsApp MCP Server
A Model Context Protocol (MCP) server that enables WhatsApp integration with text-to-speech and audio notification capabilities. Send text messages, audio files, and voice notes via WhatsApp, with built-in TTS support for automated task completion notifications.
Features
📱 WhatsApp Integration: Send and receive messages via WhatsApp Web
🎵 Audio Messages: Send audio files and voice notes
🗣️ Text-to-Speech: Convert text to speech using ElevenLabs or system TTS
🔔 Task Notifications: Automated notifications when tasks are completed
📋 Contact Management: List and manage WhatsApp contacts
🔄 Session Persistence: Maintain WhatsApp sessions across restarts
🌐 Media Support: Send images, videos, and other media from URLs
🔒 Secure: Environment-based configuration with no hard-coded credentials
🛡️ Advanced Auth System: Intelligent authentication with multiple strategies
📊 Auth State Management: Real-time authentication status monitoring
⚡ Auto-Strategy Selection: Automatic selection of best auth method
🔧 Comprehensive Error Handling: Detailed error messages with recovery suggestions
Related MCP server: MCP WhatsApp
Requirements
Node.js 18.0.0 or higher
WhatsApp account for QR code authentication
Optional: ElevenLabs API key for premium TTS
Optional: ffmpeg for audio format conversion
Installation
From npm (Recommended)
npm install -g whatsapp-mcp-serverFrom Source
Clone the repository:
git clone https://github.com/your-username/whatsapp-mcp-server.git
cd whatsapp-mcp-serverInstall dependencies:
npm installBuild the project:
npm run buildQuick Start
1. First-Time Authentication
Before using the MCP server, you need to authenticate with WhatsApp using a QR code:
# Run the initialization script
npm run auth
# Or with a custom session name
npm run auth my-sessionThis will:
Display a QR code in your terminal
Wait for you to scan it with your WhatsApp mobile app
Save the authentication session for future use
Exit once authentication is complete
Important: You only need to do this once. The session will persist across restarts.
2. Using with MCP Clients
Once authenticated, configure your MCP client (like Claude Desktop) to use the server:
{
"mcpServers": {
"whatsapp": {
"command": "whatsapp-mcp-server",
"env": {
"ELEVENLABS_API_KEY": "your-api-key-here"
}
}
}
}3. Test the Connection
You can now test sending a message:
cp .env.example .env
# Edit .env with your settingsRun the server:
whatsapp-mcp-serverConfiguration
Environment Variables
Create a .env file based on .env.example:
# Optional ElevenLabs API key for premium TTS
ELEVENLABS_API_KEY=your_api_key_here
# WhatsApp session configuration
WHATSAPP_SESSION_NAME=whatsapp-mcp-session
WHATSAPP_AUTH_TIMEOUT_MS=60000
# Audio settings
AUDIO_OUTPUT_DIR=./audio
TTS_DEFAULT_VOICE=RachelWhatsApp Authentication System
The server features an advanced authentication system with multiple strategies:
Authentication Strategies
Session Restore Strategy: Automatically uses existing authenticated sessions
QR Code Strategy: Fallback method requiring QR code scanning
Configuration Options
# WhatsApp session configuration
WHATSAPP_SESSION_NAME=whatsapp-mcp-session
WHATSAPP_SESSION_DIR=./whatsapp_session
WHATSAPP_SESSION_PREFIX=session-
WHATSAPP_AUTH_TIMEOUT_MS=30000
WHATSAPP_QR_TIMEOUT_MS=60000
WHATSAPP_MAX_RETRIES=3
WHATSAPP_RETRY_DELAY_MS=5000Authentication Flow
The system automatically:
Detects existing sessions and validates them
Selects the optimal authentication strategy
Monitors authentication state with real-time updates
Provides detailed error messages with recovery suggestions
Maintains session persistence across restarts
Auth State Monitoring
You can monitor authentication states:
UNINITIALIZED: Client not yet startedINITIALIZING: Client starting upWAITING_FOR_QR: QR code required for authenticationAUTHENTICATING: Authentication in progressAUTHENTICATED: Successfully authenticatedREADY: Client ready for useFAILED: Authentication failedDISCONNECTED: Client disconnectedDESTROYED: Client destroyed/cleaned up
Usage
Running the MCP Server
npm startThe server will start and wait for MCP client connections via stdio.
Integrating with Claude Code
To use this server with Claude Code, add it to your MCP configuration:
{
"mcpServers": {
"whatsapp": {
"command": "whatsapp-mcp-server"
}
}
}Or if installed locally:
{
"mcpServers": {
"whatsapp": {
"command": "node",
"args": ["/path/to/whatsapp-mcp-server/dist/index.js"]
}
}
}Available Tools
get_whatsapp_status
Get current WhatsApp client connection and authentication status.
Returns:
Connection status, authentication state, session name, phone number
Auth state information and error details if any
Timestamp of last connection
Note: Authentication now happens automatically when any WhatsApp operation is attempted. No manual initialization required!
send_text_message
Send a text message to a WhatsApp contact or group.
Parameters:
chatId: WhatsApp chat ID (e.g., "5511999999999@c.us")text: Message text to send
send_audio_message
Send an audio file or voice note.
Parameters:
chatId: WhatsApp chat IDfilePath: Absolute path to the audio filecaption(optional): Caption for the audio messagesendAsVoiceNote(optional): Send as voice note (default: true)
send_tts_message
Generate text-to-speech audio and send as voice note.
Parameters:
chatId: WhatsApp chat IDtext: Text to convert to speechvoiceName(optional): Voice name for TTSspeed(optional): Speech speed (0.5-2.0)
send_task_completion_notification
Send a comprehensive task completion notification with optional audio.
Parameters:
chatId: WhatsApp chat IDtaskName: Name of the completed tasksummary: Brief summary of what was accomplishedincludeAudio(optional): Include audio notification (default: true)
list_contacts
Get list of WhatsApp contacts.
Parameters:
includeGroups(optional): Include group chats (default: false)
get_whatsapp_status
Check the current connection status of the WhatsApp client.
Chat ID Format
WhatsApp chat IDs follow this format:
Individual contacts:
[country_code][phone_number]@c.usExample:
5511999999999@c.us(Brazilian number)
Groups:
[group_id]@g.usExample:
120363023456789012@g.us
Text-to-Speech Integration
The server supports multiple TTS providers:
ElevenLabs (Premium): Requires API key, high-quality voices
System TTS (Fallback): Uses macOS
saycommand or similar
ElevenLabs Integration
If you have an ElevenLabs API key:
Set
ELEVENLABS_API_KEYin your.envfileThe server will automatically use ElevenLabs for TTS generation
Fallback to system TTS if ElevenLabs fails
Examples
Basic Task Completion Notification
// This would be called by Claude when a task is completed
{
"tool": "send_task_completion_notification",
"arguments": {
"chatId": "5511999999999@c.us",
"taskName": "Database Migration",
"summary": "Successfully migrated 10,000 records to the new schema",
"includeAudio": true
}
}Send Custom Audio Message
{
"tool": "send_audio_message",
"arguments": {
"chatId": "5511999999999@c.us",
"filePath": "/path/to/audio/notification.mp3",
"sendAsVoiceNote": true
}
}Troubleshooting
Authentication System
The new authentication system provides detailed error messages with recovery suggestions:
Common Auth Errors
SESSION_NOT_FOUND: Runnpm run authto create a new sessionSESSION_EXPIRED: Runnpm run authto re-authenticate with QR codeQR_CODE_REQUIRED: Runnpm run authand scan the displayed QR codeINITIALIZATION_TIMEOUT: Check network connection or increase timeoutAUTHENTICATION_FAILED: Clear session data and re-authenticate
Auth Recovery Steps
Check auth status:
# The system will show detailed status information # including current state and suggested actionsClear problematic sessions:
rm -rf ./whatsapp_session npm run authUse environment variables for custom configuration:
export WHATSAPP_AUTH_TIMEOUT_MS=60000 export WHATSAPP_SESSION_DIR=/custom/path
For detailed authentication troubleshooting, see AUTHENTICATION.md.
Legacy Issues
Audio Issues
Check that audio files exist and are readable
Supported formats: MP3, WAV, OGG, M4A
For system TTS on macOS, ensure
saycommand worksInstall ffmpeg for audio format conversion
Other Common Errors
"TTS generation failed": Check ElevenLabs API key or system TTS availability
"Client not ready": Wait for authentication to complete automatically
Development
Building from Source
npm run buildDevelopment Mode
npm run devRunning Tests
npm testLinting
npm run lintSecurity Considerations
WhatsApp sessions are stored locally in
./whatsapp_session/Never commit session data to version control
ElevenLabs API keys should be kept secure
This uses an unofficial WhatsApp API - use at your own risk
Consider rate limiting to avoid WhatsApp spam detection
License
MIT License - see LICENSE file for details.
Contributing
Fork the repository
Create a feature branch
Make your changes
Add tests if applicable
Submit a pull request
Support
For issues and questions:
Check the troubleshooting section
Review WhatsApp Web.js documentation
Open an issue on the repository
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Drive WhatsApp from any MCP client: pair devices, send text and media, manage contacts and groups.
WhatsMCP connects Claude and other MCP-compatible AI agents directly to WhatsApp. Send and receive text, images, documents, and voice notes; manage groups (create, add/remove members, promote admins); look up contacts and profiles; follow channels; and read call and message history — all through a standard MCP interface. For voice use cases, WhatsMCP offers SIP-based calling plans (inbound-only, or full inbound/outbound) so AI voice agents can answer and place WhatsApp calls, plus low-latency WebSocket integrations with voice agent providers like ElevenLabs. Multiple WhatsApp accounts can be paired and managed per workspace, with webhook support for real-time inbound message delivery to your own infrastructure.
WhatsApp MCP for chats you choose: read/write by default, no daily send quota, voice notes as text.
WhatsApp (Web + Business API), SMS, contacts, and call records via 2Chat's MCP server.
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceEnables WhatsApp automation through MCP protocol, allowing users to manage sessions, send messages, handle groups/communities, and access contacts through natural language interactions with AI agents.5 npm-
- AlicenseBqualityBmaintenanceEnables sending messages, images, documents and more on WhatsApp directly from any MCP-compatible AI, with tools for chat management, groups, and webhooks.371MIT
- AlicenseNot gradedqualityCmaintenanceEnables programmatic WhatsApp automation through MCP, including sending messages, managing chats and contacts, searching conversation history, and exchanging media files.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to send and receive WhatsApp messages, search chats, share media, manage approvals, and get activity summaries through MCP.Apache 2.0