check-whatsapp-status
Verify WhatsApp’s operational status programmatically using the WhatsApp MCP Server, enabling automated checks without manual UI interaction.
Instructions
Check if WhatsApp is currently running
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:143-180 (handler)The server.tool registration and inline handler implementation for 'check-whatsapp-status'. It checks if WhatsApp is running by executing an AppleScript to query System Events for the WhatsApp process, and returns a text response indicating the status.server.tool( "check-whatsapp-status", "Check if WhatsApp is currently running", {}, async () => { try { const appleScript = ` tell application "System Events" return (exists process "WhatsApp") end tell `; const result = await runAppleScript(appleScript); const isRunning = result.toLowerCase() === 'true'; return { content: [ { type: "text", text: isRunning ? "WhatsApp is currently running." : "WhatsApp is not currently running. Please start WhatsApp before trying to send messages.", } ] }; } catch (error) { return { content: [ { type: "text", text: `Error checking WhatsApp status: ${error}`, } ], isError: true }; } } );
- src/index.ts:38-46 (helper)Helper function 'runAppleScript' used by the tool handler to execute AppleScript commands via osascript, with error handling.async function runAppleScript(script: string) { try { const { stdout } = await execPromise(`osascript -e '${script.replace(/'/g, "'\\''")}'`); return stdout.trim(); } catch (error) { console.error("AppleScript execution error:", error); throw new Error(`Failed to execute AppleScript: ${error}`); } }