whatsapp_get_qr_code
Generate a QR code to authenticate and log into a WhatsApp account through the WSAPI service, enabling AI assistants to establish WhatsApp sessions for messaging and management tasks.
Instructions
Get QR code for WhatsApp login.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- src/tools/session.ts:19-28 (handler)The main handler implementation for the 'whatsapp_get_qr_code' tool. It fetches the QR code data from the WSAPI endpoint '/session/login/qr/code' and returns it in a success response.export const getQRCode: ToolHandler = { name: 'whatsapp_get_qr_code', description: 'Get QR code for WhatsApp login.', inputSchema: { type: 'object', properties: {} }, handler: async () => { logger.info('Getting QR code'); const result = await wsapiClient.get('/session/login/qr/code'); return { success: true, qrCode: result, message: 'QR code retrieved successfully' }; }, };
- src/tools/session.ts:68-68 (registration)Groups the session-related tools, including the whatsapp_get_qr_code handler (as getQRCode), for registration in the MCP server.export const sessionTools = { getSessionStatus, getQRCode, getQRCodeImage, getPairCode, logout };
- src/server.ts:19-19 (registration)Imports the sessionTools object containing the whatsapp_get_qr_code tool handler.import { sessionTools } from './tools/session.js';
- src/server.ts:62-62 (registration)Includes sessionTools in the toolCategories array used for registering all tools.sessionTools,
- src/server.ts:56-76 (registration)The registration logic that iterates over tool categories (including sessionTools) and adds each tool to the server's tools Map using its name.// Register all tool categories const toolCategories = [ messagingTools, contactTools, groupTools, chatTools, sessionTools, instanceTools, accountTools, ]; toolCategories.forEach(category => { Object.values(category).forEach(tool => { if (this.tools.has(tool.name)) { logger.warn(`Tool ${tool.name} already registered, skipping`); return; } this.tools.set(tool.name, tool); logger.debug(`Registered tool: ${tool.name}`); }); });