Skip to main content
Glama

notify

Send audio notifications on macOS to alert users with spoken messages for questions, alerts, confirmations, or information updates.

Instructions

Provide audio notifications to users (macOS only)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageYesThe message to speak
typeNoType of notificationinfo
voiceNoVoice to use for speech (e.g., "Daniel", "Samantha")
rateNoSpeaking rate in words per minute

Implementation Reference

  • Core handler function executing the notification logic: platform-specific handling, pauses/resumes Spotify, and runs the TTS command.
    async execute(args: NotificationOptions): Promise<CallToolResult> {
      // For non-macOS platforms, handle differently
      if (platform() !== 'darwin') {
        const { message, type = 'info' } = args;
        console.log(`[${type.toUpperCase()}] ${message}`);
        return createSuccessResult('Notification displayed in console (audio not available on this platform)');
      }
      
      // Check if Spotify is playing and pause it
      const wasPlaying = await isSpotifyPlaying();
      if (wasPlaying) {
        await pauseSpotify();
      }
      
      // Execute the notification
      const result = await super.execute(args);
      
      // Resume Spotify if it was playing
      if (wasPlaying) {
        // Add a small delay to ensure the notification finishes speaking
        await new Promise(resolve => setTimeout(resolve, 1500));
        await resumeSpotify();
      }
      
      return result;
    }
  • Builds the shell command for macOS 'say' TTS based on notification options including voice, rate, and type-specific prefixes.
    protected buildCommand(args: NotificationOptions): string {
      const { message, type = 'info', voice, rate } = args;
      
      // Only support macOS say command for now
      if (platform() !== 'darwin') {
        // For non-macOS, we'll just log to console and return empty command
        console.log(`[${type.toUpperCase()}] ${message}`);
        return 'echo "Notification sent to console"';
      }
      
      // Build the say command with options
      const parts = ['say'];
      
      // Add voice option if specified
      if (voice) {
        parts.push('-v', voice);
      }
      
      // Add rate option if specified (words per minute)
      if (rate) {
        parts.push('-r', rate.toString());
      }
      
      // Add prefix based on notification type
      let prefix = '';
      switch (type) {
        case 'question':
          prefix = 'Question: ';
          break;
        case 'alert':
          prefix = 'Alert! ';
          break;
        case 'confirmation':
          prefix = 'Please confirm: ';
          break;
        case 'info':
        default:
          prefix = '';
      }
      
      // Add the message with proper escaping
      const fullMessage = prefix + message;
      parts.push(`"${fullMessage.replace(/"/g, '\\"')}"`);
      
      return parts.join(' ');
    }
  • src/index.ts:95-108 (registration)
    Registers the 'notify' tool with the MCP server, including Zod input schema and handler reference.
    // Register notify tool
    server.registerTool(
      'notify',
      {
        description: 'Provide audio notifications to users (macOS only)',
        inputSchema: {
          message: z.string().describe('The message to speak'),
          type: z.enum(['question', 'alert', 'confirmation', 'info']).optional().default('info').describe('Type of notification'),
          voice: z.string().optional().describe('Voice to use for speech (e.g., "Daniel", "Samantha")'),
          rate: z.number().optional().describe('Speaking rate in words per minute'),
        },
      },
      async (args) => notify(args)
    );
  • TypeScript interface defining the input shape for notify tool parameters.
    export interface NotificationOptions {
      message: string;
      type?: 'question' | 'alert' | 'confirmation' | 'info';
      voice?: string;
      rate?: number;
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jaggederest/mcp_reviewer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server