Skip to main content
Glama

execute_menu_item

Performs actions in Unity Editor by triggering menu items via specified paths, enabling automation and integration with AI model clients.

Instructions

Executes a Unity menu item by path

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
menuPathYesThe path to the menu item to execute (e.g. "GameObject/Create Empty")

Implementation Reference

  • The core handler function that executes the tool logic: destructures menuPath, sends request to mcpUnity with method 'execute_menu_item', handles response success/error, returns CallToolResult.
    async function toolHandler(mcpUnity: McpUnity, params: any): Promise<CallToolResult> {
      const { menuPath } = params;
      const response = await mcpUnity.sendRequest({
        method: toolName,
        params: { menuPath }
      });
      
      if (!response.success) {
        throw new McpUnityError(
          ErrorType.TOOL_EXECUTION,
          response.message || `Failed to execute menu item: ${menuPath}`
        );
      }
      
      return {
        content: [{
          type: response.type,
          text: response.message || `Successfully executed menu item: ${menuPath}` 
        }]
      };
    }
  • Registers the 'execute_menu_item' tool with the MCP server using server.tool(), providing name, description, schema, and a wrapper handler that calls the core toolHandler.
    server.tool(
      toolName,
      toolDescription,
      paramsSchema.shape,
      async (params: any) => {
        try {
          logger.info(`Executing tool: ${toolName}`, params);
          const result = await toolHandler(mcpUnity, params);
          logger.info(`Tool execution successful: ${toolName}`);
          return result;
        } catch (error) {
          logger.error(`Tool execution failed: ${toolName}`, error);
          throw error;
        }
      }
    );
  • Zod schema defining the single input parameter 'menuPath' as a string with description.
    const paramsSchema = z.object({
      menuPath: z.string().describe('The path to the menu item to execute (e.g. "GameObject/Create Empty")')
    });
  • Calls the registerMenuItemTool function to register the tool during server initialization.
    registerMenuItemTool(server, mcpUnity, toolLogger);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Executes') but doesn't clarify what 'execute' entails—whether it triggers UI changes, runs scripts, modifies project state, or has side effects like requiring specific permissions or being irreversible. This leaves significant gaps in understanding the tool's behavior.

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, direct sentence with zero wasted words. It's front-loaded with the core action and resource, making it highly efficient and easy to parse, which is ideal for conciseness.

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?

Given the complexity of executing a Unity menu item (which could involve UI interactions, project changes, or script execution), the description is incomplete. With no annotations, no output schema, and minimal behavioral context, it fails to provide enough information for safe and effective use, especially for a tool that likely performs mutations in a development environment.

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 schema description coverage is 100%, with the single parameter 'menuPath' well-documented in the schema (including an example). The description adds no additional semantic context beyond what the schema provides, such as format constraints or common use cases, so it meets the baseline for high schema coverage.

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 ('Executes') and the target resource ('a Unity menu item by path'), making the purpose immediately understandable. However, it doesn't differentiate this tool from its siblings (like notify_message or run_tests), which would require more specific context about Unity menu execution versus other operations.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing Unity running), exclusions, or how it relates to sibling tools like run_tests or select_object, leaving the agent to infer usage 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

Related 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/CoderGamester/mcp-unity'

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