check_auth_status
Verify whether your WhatsApp client is authenticated and ready. This status check enables you to confirm connection before sending messages or managing contacts, ensuring operations proceed only when authenticated.
Instructions
Check if the WhatsApp client is authenticated and ready
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/auth.ts:166-203 (handler)The `checkAuthStatus` function is the actual handler for the 'check_auth_status' tool. It calls `whatsappService.isAuthenticated()` and `whatsappService.isReady()` to determine the current authentication state, then returns a human-readable text result indicating whether the user is authenticated, ready, or needs to authenticate via QR code.
async function checkAuthStatus( whatsappService: WhatsAppService, ): Promise<CallToolResult> { try { const isAuthenticated = whatsappService.isAuthenticated(); const isReady = whatsappService.isReady(); log.info( `Auth status checked: ${isAuthenticated ? "authenticated" : "not authenticated"}, ` + `ready: ${isReady ? "yes" : "no"}`, ); return { content: [ { type: "text", text: !isAuthenticated ? "You are not authenticated. Use get_qr_code to authenticate." : isReady ? "Authenticated and ready." : "Authenticated, but not ready yet. Please wait a few seconds and try again.", }, ], isError: false, }; } catch (error) { log.error("Error checking authentication status:", error); return { content: [ { type: "text", text: `Error checking authentication status: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } } - src/tools/auth.ts:29-36 (registration)The tool is registered with the MCP server via `server.tool('check_auth_status', ...)` inside the `registerAuthTools` function. It has no input schema and delegates to the `checkAuthStatus` handler.
server.tool( "check_auth_status", "Check if the WhatsApp client is authenticated and ready", {}, async (): Promise<CallToolResult> => { return await checkAuthStatus(whatsappService); }, );