play_warning_sound
Play a system warning sound to alert users to important events or issues, providing audio feedback for notifications.
Instructions
Play a warning system sound
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:359-368 (handler)Handler for the 'play_warning_sound' tool. Calls playSound('warning') and returns success message.case 'play_warning_sound': await playSound('warning'); return { content: [ { type: 'text', text: 'Warning sound played successfully', }, ], };
- src/index.ts:289-296 (registration)Registration of the 'play_warning_sound' tool in the listTools response, including empty input schema.name: 'play_warning_sound', description: 'Play a warning system sound', inputSchema: { type: 'object', properties: {}, required: [], }, },
- src/index.ts:96-149 (helper)Helper function playSound that implements the logic for playing system sounds, including 'Purr' for warning.async function playSound(soundType: 'info' | 'warning' | 'error'): Promise<void> { const requestId = `${soundType}-${Date.now()}`; // Throttle requests to prevent conflicts if (activeRequests.has(soundType)) { throw new Error(`${soundType} sound already playing`); } activeRequests.add(soundType); try { return new Promise((resolve, reject) => { let soundName: string; switch (soundType) { case 'info': soundName = 'Glass'; break; case 'warning': soundName = 'Purr'; break; case 'error': soundName = 'Sosumi'; break; default: soundName = 'Glass'; } const afplay = spawn('afplay', [`/System/Library/Sounds/${soundName}.aiff`]); // Add timeout const timeout = setTimeout(() => { afplay.kill(); reject(new Error('Sound playback timed out')); }, PROCESS_TIMEOUT_MS); afplay.once('close', (code) => { clearTimeout(timeout); if (code === 0) { resolve(); } else { reject(new Error(`Sound playback failed with code ${code}`)); } }); afplay.once('error', (error) => { clearTimeout(timeout); reject(error); }); }); } finally { activeRequests.delete(soundType); } }