Skip to main content
Glama

send_notification

Send macOS notifications with custom title, message, subtitle, and sound using osascript.

Instructions

Send a notification on macOS using osascript

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesTitle of the notification
messageYesMain message content
subtitleNoOptional subtitle
soundNoWhether to play the default notification sound

Implementation Reference

  • src/index.ts:54-85 (registration)
    Tool registration: The 'send_notification' tool is registered in the ListToolsRequestSchema handler with name, description, and inputSchema (title, message, subtitle, sound).
    private setupToolHandlers() {
      // List available tools
      this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
        tools: [
          {
            name: 'send_notification',
            description: 'Send a notification on macOS using osascript',
            inputSchema: {
              type: 'object',
              properties: {
                title: {
                  type: 'string',
                  description: 'Title of the notification',
                },
                message: {
                  type: 'string',
                  description: 'Main message content',
                },
                subtitle: {
                  type: 'string',
                  description: 'Optional subtitle',
                },
                sound: {
                  type: 'boolean',
                  description: 'Whether to play the default notification sound',
                  default: true,
                },
              },
              required: ['title', 'message'],
              additionalProperties: false,
            },
          },
  • Handler/router case: The CallToolRequestSchema routes 'send_notification' to extract params (title, message, subtitle, sound) and calls the imported sendNotification function.
    switch (request.params.name) {
      case 'send_notification': {
        const { title, message, subtitle, sound } = request.params.arguments as Record<string, unknown>;
        
        if (typeof title !== 'string' || typeof message !== 'string') {
          throw new McpError(ErrorCode.InvalidParams, 'Title and message must be strings');
        }
    
        const params: NotificationParams = {
          title,
          message,
          subtitle: typeof subtitle === 'string' ? subtitle : undefined,
          sound: typeof sound === 'boolean' ? sound : undefined
        };
    
        await sendNotification(params);
        return {
          content: [
            {
              type: 'text',
              text: 'Notification sent successfully',
            },
          ],
        };
      }
  • NotificationParams interface defines the type schema for the tool: title, message, subtitle (optional), sound (optional).
    /**
     * Parameters for sending a notification
     */
    export interface NotificationParams {
      /** Title of the notification */
      title: string;
      /** Main message content */
      message: string;
      /** Optional subtitle */
      subtitle?: string;
      /** Whether to play the default notification sound */
      sound?: boolean;
    }
  • Core handler function: sendNotification validates params, builds AppleScript command, executes it via osascript, with error handling for command failures and permission errors.
    export async function sendNotification(params: NotificationParams): Promise<void> {
      try {
        validateParams(params);
        const command = buildNotificationCommand(params);
        await execAsync(command);
      } catch (error) {
        if (error instanceof NotificationError) {
          throw error;
        }
    
        // Handle different types of system errors
        const err = error as Error;
        if (err.message.includes('execution error')) {
          throw new NotificationError(
            NotificationErrorType.COMMAND_FAILED,
            'Failed to execute notification command'
          );
        } else if (err.message.includes('permission')) {
          throw new NotificationError(
            NotificationErrorType.PERMISSION_DENIED,
            'Permission denied when trying to send notification'
          );
        } else {
          throw new NotificationError(
            NotificationErrorType.UNKNOWN,
            `Unexpected error: ${err.message}`
          );
        }
      }
    }
  • Helper utility: escapeString escapes special characters for AppleScript/shell usage within the notification command.
    export function escapeString(str: string): string {
      // Escape for both AppleScript and shell
      return str
        .replace(/'/g, "'\\''")
        .replace(/"/g, '\\"');
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries full burden. It specifies the platform ('macOS') but fails to describe the tool's behavior such as whether it is blocking, what it returns, or error conditions (e.g., if osascript is unavailable). Minimal disclosure beyond the platform.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no unnecessary words. It is appropriately front-loaded and efficient for its purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has 4 parameters (2 required) and no output schema or annotations. The description does not address return values, errors, or platform dependencies beyond mentioning macOS. This is insufficient for reliable agent invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds no additional meaning beyond the schema's param descriptions, which already cover title, message, subtitle, and sound.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('send a notification') and the resource ('macOS' via 'osascript'), and it is distinct from sibling tools which involve user prompts, file selection, speech output, and screenshots.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. There is no mention of scenarios or exclusion criteria, leaving the agent to infer based solely on the tool name and sibling context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/turlockmike/apple-notifier-mcp'

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