Running the MCP Server
Prerequisites
Before running the MCP server, ensure you have:- Go 1.24.0 or higher (for building from source)
- FFmpeg installed (for media processing)
- libwebp installed (for sticker support)
Starting the Server
- From Source
- Binary
- Docker
Server Options
Customize the MCP server host and port:| Flag | Description | Default |
|---|---|---|
--host | Host address to bind the MCP server | localhost |
--port | Port for the SSE MCP server | 8080 |
For security, the MCP server defaults to
localhost and should only be exposed to trusted networks.MCP Endpoints
Once started, the MCP server exposes two primary endpoints:SSE Endpoint
- Real-time bidirectional communication
- Tool discovery and invocation
- Streaming responses
Message Endpoint
Verifying Server Status
When the server starts successfully, you should see:Connecting from AI Tools
After the server is running, configure your AI tool to connect to the MCP server:Cursor
Add the SSE URL to your Cursor MCP configuration
Claude Desktop
Configure via claude_desktop_config.json
Other MCP Clients
Any MCP-compatible tool can connect via SSE
Device Management
Single Device Setup
If you have only one WhatsApp device registered, the MCP server will automatically use it for all operations. No additional configuration is needed.Multi-Device Setup
For multi-device deployments, the MCP server uses the first registered device by default. This is determined by:- Fetching all registered devices via the device manager
- Selecting
devices[0].Deviceas the default - Injecting this device into the context for all tool calls
src/ui/mcp/helpers/context.go:10-25:
WhatsApp Authentication
Before you can send messages via MCP, you must authenticate your WhatsApp account:Login via QR Code
Use thewhatsapp_login_qr tool from your AI client:
- QR code image (base64 encoded)
- Pairing code
- Expiration time
Login via Pairing Code
Use thewhatsapp_login_with_code tool:
Check Connection Status
Verify authentication with:Troubleshooting
Server Won’t Start
Error:address already in use
Solution: Another process is using port 8080. Either:
- Stop the other process
- Use a different port:
./whatsapp mcp --port 9000
MCP Client Can’t Connect
Error:connection refused
Solution:
- Verify the server is running
- Check firewall settings
- Ensure the host/port match your client configuration
No Devices Registered
Error:no devices registered
Solution: You must authenticate at least one WhatsApp account before using MCP tools. Use whatsapp_login_qr or whatsapp_login_with_code.
Next Steps
Configuration Examples
See detailed client configuration for Cursor, Claude Desktop, and more
Connection Tools
Learn about login, logout, and reconnect tools
