play_warning_sound
Trigger a warning sound on macOS using MCP Make Sound to provide audio alerts for AI assistant interactions, ensuring timely notifications and feedback.
Instructions
Play a warning system sound
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:359-369 (handler)Direct handler for the 'play_warning_sound' tool call in the CallToolRequestSchema switch statement. Invokes playSound('warning') and returns a success response.case 'play_warning_sound': await playSound('warning'); return { content: [ { type: 'text', text: 'Warning sound played successfully', }, ], };
- src/index.ts:289-296 (registration)Tool registration in ListToolsRequestSchema response, including name, description, and empty input schema (no parameters required).name: 'play_warning_sound', description: 'Play a warning system sound', inputSchema: { type: 'object', properties: {}, required: [], }, },
- src/index.ts:96-149 (helper)Core helper function playSound that executes the logic for playing system sounds. For 'warning', it maps to 'Purr.aiff', spawns afplay with throttling and timeout handling.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); } }