Overview
Connection management tools handle WhatsApp authentication, session management, and connection status. These are typically the first tools you’ll use when setting up the MCP server.All connection tools operate on the default device (first registered device in multi-device setups).
whatsapp_connection_status
Check whether the WhatsApp client is connected and logged in.Parameters
None. This tool takes no arguments.Returns
| Field | Type | Description |
|---|---|---|
is_connected | boolean | Whether the WebSocket connection to WhatsApp is active |
is_logged_in | boolean | Whether the device is authenticated with WhatsApp |
device_id | string | The WhatsApp JID of the authenticated device |
Hints
- Read-only:
true(does not modify state) - Destructive:
false - Idempotent:
true(safe to call repeatedly)
Example Usage
- Cursor
- Claude
- Direct MCP
Implementation Reference
Source:src/ui/mcp/app.go:31-61
whatsapp_login_qr
Initiate QR code based login flow with image output.Parameters
None.Returns
| Field | Type | Description |
|---|---|---|
device_id | string | Device that will be authenticated |
qr_image_path | string | Local filesystem path to QR code PNG |
qr_code | string | Raw QR code data |
expires_in | integer | Seconds until QR code expires |
Image Response
The tool returns a base64-encoded PNG image in MCP image format, allowing AI clients to display the QR code directly.Hints
- Read-only:
false - Destructive:
true(starts new login session) - Idempotent:
false(generates new QR each time)
Usage
Scan with WhatsApp mobile
Open WhatsApp on your phone > Settings > Linked Devices > Link a Device > Scan the QR code.
Implementation Reference
Source:src/ui/mcp/app.go:64-102
whatsapp_login_with_code
Generate a pairing code for multi-device login using a phone number.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
phone | string | Yes | Phone number in international format (e.g., +628123456789) |
Returns
| Field | Type | Description |
|---|---|---|
device_id | string | Device that will be authenticated |
phone | string | Phone number used for pairing |
pair_code | string | 8-character pairing code (format: XXXX-XXXX) |
Hints
- Read-only:
false - Destructive:
true(starts new login session) - Idempotent:
false(generates new code each time)
Usage
Enter code in WhatsApp mobile
- Open WhatsApp on your phone
- Go to Settings > Linked Devices
- Tap “Link a Device”
- Tap “Link with phone number instead”
- Enter the 8-character pairing code
Example
Implementation Reference
Source:src/ui/mcp/app.go:104-144
whatsapp_logout
Sign out the current WhatsApp session and clear stored credentials.Parameters
None.Returns
Hints
- Read-only:
false - Destructive:
true(terminates session) - Idempotent:
false
Usage
Implementation Reference
Source:src/ui/mcp/app.go:146-168
whatsapp_reconnect
Attempt to reconnect to WhatsApp using the stored session.Parameters
None.Returns
Hints
- Read-only:
false - Destructive:
false - Idempotent:
true(safe to call multiple times)
When to Use
Use this tool when:- The connection is dropped (network issues)
whatsapp_connection_statusshowsis_connected: falsebutis_logged_in: true- You want to force a reconnection attempt
Usage
Reconnect only works if the device was previously authenticated. If the session has expired, you must use
whatsapp_login_qr or whatsapp_login_with_code to re-authenticate.Implementation Reference
Source:src/ui/mcp/app.go:170-192
Device Resolution
Single Device Setup
If only one device is registered, all connection tools automatically use it:src/ui/mcp/app.go:194-203
Multi-Device Setup
Error Handling
Common Errors
| Error | Cause | Solution |
|---|---|---|
no devices registered | No authenticated devices | Login using whatsapp_login_qr or whatsapp_login_with_code |
device manager not initialized | Server startup issue | Restart the MCP server |
device identification required | Multi-device ambiguity | Ensure at least one device is registered |
context deadline exceeded | Network timeout | Check internet connection, retry with whatsapp_reconnect |
Best Practices
- Check status first: Always call
whatsapp_connection_statusbefore attempting other operations - Handle QR expiration: QR codes expire in ~60 seconds; regenerate if login fails
- Use pairing codes for automation: Pairing codes are easier to integrate into automated workflows
- Reconnect on failure: If tools fail with connection errors, try
whatsapp_reconnectbefore re-authenticating - Logout when done: Logout to free server resources if the session is no longer needed
Next Steps
Messaging Tools
Send text, images, stickers, and more
Contacts & Chats
Query contacts and messages
