Skip to main content
Glama

prompt_user

Display a dialog box to prompt users for input. Customize the message, provide a default answer, add up to three custom buttons, and select an icon.

Instructions

Display a dialog prompt to get user input

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageYesText to display in the prompt dialog
defaultAnswerNoOptional default text to pre-fill
buttonsNoOptional custom button labels (max 3)
iconNoOptional icon to display

Implementation Reference

  • Main handler function that executes the prompt_user tool logic. It validates params via validatePromptParams, builds an AppleScript command via buildPromptCommand, executes it using osascript, parses the result to extract the button clicked and user text input, and returns a PromptResult. It also handles errors like user cancellation, command failures, and permission denied.
    export async function promptUser(params: PromptParams): Promise<PromptResult> {
      try {
        validatePromptParams(params);
        const command = buildPromptCommand(params);
        const { stdout } = await execAsync(command);
        
        // Parse the AppleScript result
        // Format: button returned:OK, text returned:user input
        const match = stdout.match(/button returned:([^,]+)(?:, text returned:(.+))?/);
        if (!match) {
          throw new Error('Failed to parse dialog result');
        }
        
        const buttonText = match[1];
        const text = match[2];
        
        // Find the index of the clicked button
        const buttons = params.buttons || ['Cancel', 'OK'];
        const buttonIndex = buttons.findIndex(b => b === buttonText);
        
        return {
          text: text,
          buttonIndex: buttonIndex !== -1 ? buttonIndex : 0
        };
      } catch (error) {
        if (error instanceof NotificationError) {
          throw error;
        }
    
        const err = error as Error;
        if (err.message.includes('User canceled')) {
          throw new NotificationError(
            NotificationErrorType.PROMPT_CANCELLED,
            'User cancelled the prompt'
          );
        } else if (err.message.includes('execution error')) {
          throw new NotificationError(
            NotificationErrorType.COMMAND_FAILED,
            'Failed to execute prompt command'
          );
        } else if (err.message.includes('permission')) {
          throw new NotificationError(
            NotificationErrorType.PERMISSION_DENIED,
            'Permission denied when trying to show prompt'
          );
        } else {
          throw new NotificationError(
            NotificationErrorType.UNKNOWN,
            `Unexpected error: ${err.message}`
          );
        }
      }
    }
  • PromptParams interface defining the input schema for the prompt_user tool: message (required string), defaultAnswer (optional string), buttons (optional array of strings, max 3), and icon (optional enum: 'note', 'stop', 'caution').
    export interface PromptParams {
      /** Text to display in the prompt dialog */
      message: string;
      /** Optional default text to pre-fill */
      defaultAnswer?: string;
      /** Optional custom button labels */
      buttons?: string[];
      /** Optional icon name to display (note, stop, caution) */
      icon?: 'note' | 'stop' | 'caution';
    }
  • PromptResult interface defining the return type: text (optional string, the user's input) and buttonIndex (number, 0-based index of the clicked button).
    export interface PromptResult {
      /** Text entered by the user, or undefined if cancelled */
      text?: string;
      /** Index of the button clicked (0-based) */
      buttonIndex: number;
    }
  • src/index.ts:248-267 (registration)
    Tool registration in the CallToolRequestSchema handler: the 'prompt_user' case extracts message, defaultAnswer, buttons, and icon from request params, creates a PromptParams object, calls the promptUser handler, and returns the result as JSON.
    case 'prompt_user': {
      const { message, defaultAnswer, buttons, icon } = request.params.arguments as Record<string, unknown>;
      
      const params: PromptParams = {
        message: message as string,
        defaultAnswer: typeof defaultAnswer === 'string' ? defaultAnswer : undefined,
        buttons: Array.isArray(buttons) ? buttons as string[] : undefined,
        icon: ['note', 'stop', 'caution'].includes(icon as string) ? icon as 'note' | 'stop' | 'caution' : undefined
      };
    
      const result = await promptUser(params);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result),
          },
        ],
      };
    }
  • src/index.ts:87-117 (registration)
    Tool definition and inputSchema registered in ListToolsRequestSchema: declares the 'prompt_user' tool with its description and JSON Schema input schema (message required, optional defaultAnswer, buttons array max 3, icon enum).
      name: 'prompt_user',
      description: 'Display a dialog prompt to get user input',
      inputSchema: {
        type: 'object',
        properties: {
          message: {
            type: 'string',
            description: 'Text to display in the prompt dialog',
          },
          defaultAnswer: {
            type: 'string',
            description: 'Optional default text to pre-fill',
          },
          buttons: {
            type: 'array',
            items: {
              type: 'string'
            },
            description: 'Optional custom button labels (max 3)',
            maxItems: 3
          },
          icon: {
            type: 'string',
            enum: ['note', 'stop', 'caution'],
            description: 'Optional icon to display'
          }
        },
        required: ['message'],
        additionalProperties: false,
      },
    },
Behavior3/5

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

No annotations provided. The description does not disclose blocking behavior (waits for user input) or any side effects. It adds no behavioral context beyond the basic action.

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?

Single, front-loaded sentence with no wasted words. Fully earns its place.

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

Completeness4/5

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

For a simple prompt tool with 4 params and no output schema, the description is mostly complete. It implies the return value (user input) but misses mentioning that the tool blocks execution until input is given.

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 coverage is 100% with clear param descriptions. The tool description adds no additional meaning beyond what the schema provides, scoring baseline 3.

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 ('Display a dialog prompt') and purpose ('to get user input'). It distinguishes from sibling tools like 'send_notification' (no input) and 'select_file' (file selection).

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

Usage Guidelines3/5

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

The description implies usage for general text input but provides no explicit guidance on when to use vs alternatives or when not to use (e.g., if a simple notification suffices).

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