check-whatsapp-status
Verify WhatsApp desktop application status on macOS to determine if it's currently running and accessible for automation tasks.
Instructions
Check if WhatsApp is currently running
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:143-180 (registration)Registration of the 'check-whatsapp-status' MCP tool, including its inline handler function that uses AppleScript to check if the WhatsApp process exists.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 to execute AppleScript code, which is called by the tool handler to check WhatsApp status.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}`); } }
- src/index.ts:27-27 (helper)Promisified exec function used by runAppleScript helper.const execPromise = promisify(exec);