Skip to main content
Glama

click_menu

Destructive

Click menu bar items in macOS applications using a path format like "File > Save As..." to automate desktop interactions.

Instructions

Click a menu bar item in an application. Specify the menu path as "Menu > Submenu > Item" (e.g., "File > Save As...", "View > Sort By > Name").

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appYesApplication name
pathYesMenu path, e.g. "File > Save As..."

Implementation Reference

  • The handleClickMenu function processes the input, builds an AppleScript command to click the menu item, and executes it.
    async function handleClickMenu(
      args: Record<string, unknown>,
    ): Promise<CallToolResult> {
      const parsed = ClickMenuInputSchema.parse(args);
      const parts = parsed.path.split(PATH_DELIMITER);
    
      if (parts.length < MIN_PATH_SEGMENTS) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Invalid menu path: expected at least ${MIN_PATH_SEGMENTS} segments separated by "${PATH_DELIMITER}", got ${parts.length}. Example: "File > Save As..."`,
            },
          ],
          isError: true,
        };
      }
    
      const app = await resolveAppName(parsed.app);
      const script = buildMenuClickScript(app, parts);
      await runAppleScript(script);
    
      return {
        content: [
          {
            type: "text" as const,
            text: JSON.stringify({
              success: true,
              app: parsed.app,
              path: parsed.path,
            }),
          },
        ],
      };
    }
  • The ClickMenuInputSchema defines the expected input structure for the click_menu tool.
    const ClickMenuInputSchema = z.object({
      app: z.string().max(1_000).describe("Application name"),
      path: z.string().max(1_000).describe('Menu path, e.g. "File > Save As..."'),
    });
  • The menuToolDefinitions array contains the MCP tool definition for click_menu.
    export const menuToolDefinitions: Tool[] = [
      {
        name: "click_menu",
        description:
          'Click a menu bar item in an application. Specify the menu path as "Menu > Submenu > Item" (e.g., "File > Save As...", "View > Sort By > Name").',
        inputSchema: zodToToolInputSchema(ClickMenuInputSchema),
        annotations: {
          readOnlyHint: false,
          destructiveHint: true,
        },
      },
    ];
  • The buildMenuClickScript helper constructs the AppleScript command used to perform the menu click.
    export function buildMenuClickScript(app: string, parts: string[]): string {
      const safeApp = escapeAppleScriptString(app);
      const escaped = parts.map(escapeAppleScriptString);
    
      const root = escaped[0];
      const leaf = escaped[escaped.length - 1];
    
      // Start with the leaf item
      let chain = `click menu item "${leaf}"`;
    
      // Traverse intermediate submenus from second-to-last down to index 1
      for (let i = escaped.length - 2; i >= 1; i--) {
        chain += ` of menu "${escaped[i]}" of menu item "${escaped[i]}"`;
      }
    
      // Attach to root menu bar item
      chain += ` of menu "${root}" of menu bar item "${root}" of menu bar 1`;
    
      return [
        'tell application "System Events"',
        `  tell process "${safeApp}"`,
        `    ${chain}`,
        "  end tell",
        "end tell",
      ].join("\n");
    }
Behavior4/5

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

Annotations indicate destructiveHint=true and readOnlyHint=false, which the description aligns with by implying a click action that may change application state. The description adds valuable context beyond annotations by specifying the menu path format and providing examples, though it does not detail potential side effects like dialog openings or data loss risks.

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 front-loaded with the core action, followed by a concise syntax specification and relevant examples. Every sentence adds necessary information without redundancy, making it highly efficient and well-structured for quick understanding.

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?

Given the tool's moderate complexity (destructive UI interaction), no output schema, and rich annotations, the description is mostly complete. It covers the action, syntax, and examples, but lacks details on error conditions or return values. However, it provides sufficient context for basic usage in the given automation toolset.

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%, with clear parameter descriptions. The description adds minimal semantic value beyond the schema by reinforcing the path format with examples, but does not explain parameter interactions or edge cases. Baseline 3 is appropriate as the schema adequately documents parameters.

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 specific action ('Click a menu bar item') and resource ('in an application'), with explicit syntax guidance. It distinguishes from sibling tools like 'click' (general) by specifying the menu context, making the purpose highly specific and unambiguous.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool (to interact with application menus) and includes a syntax example. However, it does not explicitly state when not to use it (e.g., vs. 'click' for non-menu items) or name alternatives, though the context is sufficiently clear for typical UI automation scenarios.

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/antbotlab/mac-use-mcp'

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