play_error_sound
Trigger a system error sound on macOS to provide immediate audio feedback for errors, enhancing user interaction and debugging.
Instructions
Play an error system sound
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:370-379 (handler)Handler for the 'play_error_sound' tool. Calls the playSound helper with 'error' type to play the Sosumi system sound via afplay, then returns a success message.case 'play_error_sound': await playSound('error'); return { content: [ { type: 'text', text: 'Error sound played successfully', }, ], };
- src/index.ts:297-305 (registration)Registration of the 'play_error_sound' tool in the list of tools, including name, description, and schema.{ name: 'play_error_sound', description: 'Play an error system sound', inputSchema: { type: 'object', properties: {}, required: [], }, },
- src/index.ts:300-304 (schema)Input schema for 'play_error_sound' tool, which takes no parameters.inputSchema: { type: 'object', properties: {}, required: [], },
- src/index.ts:96-149 (helper)Helper function playSound that implements the core logic. For 'error' soundType, sets soundName to 'Sosumi' and spawns 'afplay' to play /System/Library/Sounds/Sosumi.aiff.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); } }