Skip to main content
Glama

speak

Read text aloud on macOS using built-in text-to-speech. Supports voice selection and adjustable speech rate.

Instructions

Speak text using macOS text-to-speech

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText to speak
voiceNoVoice to use (defaults to system voice)
rateNoSpeech rate (-50 to 50, defaults to 0)

Implementation Reference

  • Main handler function 'speak' that validates params, builds the macOS 'say' command, executes it, and handles errors (command failed, permission denied, etc.).
    export async function speak(params: SpeechParams): Promise<void> {
      try {
        validateSpeechParams(params);
        const command = buildSpeechCommand(params);
        await execAsync(command);
      } catch (error) {
        if (error instanceof NotificationError) {
          throw error;
        }
    
        const err = error as Error;
        if (err.message.includes('execution error')) {
          throw new NotificationError(
            NotificationErrorType.COMMAND_FAILED,
            'Failed to execute speech command'
          );
        } else if (err.message.includes('permission')) {
          throw new NotificationError(
            NotificationErrorType.PERMISSION_DENIED,
            'Permission denied when trying to speak'
          );
        } else {
          throw new NotificationError(
            NotificationErrorType.UNKNOWN,
            `Unexpected error: ${err.message}`
          );
        }
      }
    }
  • Input schema interface 'SpeechParams' with fields: text (required), voice (optional string), rate (optional number -50 to 50).
    /**
     * Parameters for text-to-speech
     */
    export interface SpeechParams {
      /** Text to speak */
      text: string;
      /** Voice to use (defaults to system voice) */
      voice?: string;
      /** Speech rate (-50 to 50, defaults to 0) */
      rate?: number;
    }
  • src/index.ts:118-142 (registration)
    Tool registration in the MCP server: defines the 'speak' tool with description and JSON schema (inputSchema) matching SpeechParams.
    {
      name: 'speak',
      description: 'Speak text using macOS text-to-speech',
      inputSchema: {
        type: 'object',
        properties: {
          text: {
            type: 'string',
            description: 'Text to speak',
          },
          voice: {
            type: 'string',
            description: 'Voice to use (defaults to system voice)',
          },
          rate: {
            type: 'number',
            description: 'Speech rate (-50 to 50, defaults to 0)',
            minimum: -50,
            maximum: 50
          }
        },
        required: ['text'],
        additionalProperties: false,
      },
    },
  • The switch case in the CallToolRequestSchema handler that extracts params (text, voice, rate) from the request, constructs SpeechParams, and calls the speak function.
    case 'speak': {
      const { text, voice, rate } = request.params.arguments as Record<string, unknown>;
      
      const params: SpeechParams = {
        text: text as string,
        voice: typeof voice === 'string' ? voice : undefined,
        rate: typeof rate === 'number' ? rate : undefined
      };
    
      await speak(params);
      return {
        content: [
          {
            type: 'text',
            text: 'Speech completed successfully',
          },
        ],
      };
    }
  • Helper function 'buildSpeechCommand' that constructs the macOS 'say' command with optional voice (-v) and rate (-r) flags.
    function buildSpeechCommand(params: SpeechParams): string {
      let command = 'say';
      
      if (params.voice) {
        command += ` -v "${escapeString(params.voice)}"`;
      }
      
      if (params.rate !== undefined) {
        command += ` -r ${params.rate}`;
      }
      
      command += ` "${escapeString(params.text)}"`;
      
      return command;
    }
Behavior2/5

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

With no annotations, the description carries the full burden for behavioral details. It only states 'Speak text,' omitting any mention of side effects (e.g., audio output), blocking behavior, or system requirements, which is insufficient for safe invocation.

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

Conciseness4/5

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

The description is a single, concise sentence that immediately conveys the tool's function. It is appropriately front-loaded without unnecessary words, though slightly more detail could be added without harming conciseness.

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

Completeness3/5

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

Given the simplicity of the tool and the comprehensive schema, the description is minimally adequate. However, it lacks mention of return value or behavior, which would be expected for a tool with no output schema.

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?

The input schema covers 100% of parameters with descriptions, so the baseline is 3. The description adds no additional meaning beyond what the schema already provides, but it does not detract either.

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

Purpose4/5

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

The description clearly states the action ('Speak') and the resource ('text using macOS text-to-speech'), making the purpose unambiguous. It is distinct from sibling tools like prompt_user or take_screenshot, though no explicit differentiation is provided.

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 given on when to use this tool versus alternatives. There is no mention of context, prerequisites, or when not to use it, leaving the agent to infer usage from the name alone.

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