Skip to main content
Glama

button

Simulate hardware button presses on iOS simulators, including apple-pay, home, lock, side-button, and siri, via XcodeBuildMCP for precise testing and control.

Instructions

Press hardware button on iOS simulator. Supported buttons: apple-pay, home, lock, side-button, siri

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
buttonTypeYes
durationNo
simulatorUuidYes

Implementation Reference

  • The core handler function `buttonLogic` that parses parameters, constructs the AXE command to press the specified hardware button on the iOS simulator, executes it, handles various error types, and returns appropriate responses.
    export async function buttonLogic(
      params: ButtonParams,
      executor: CommandExecutor,
      axeHelpers: AxeHelpers = {
        getAxePath,
        getBundledAxeEnvironment,
        createAxeNotAvailableResponse,
      },
    ): Promise<ToolResponse> {
      const toolName = 'button';
      const { simulatorId, buttonType, duration } = params;
      const commandArgs = ['button', buttonType];
      if (duration !== undefined) {
        commandArgs.push('--duration', String(duration));
      }
    
      log('info', `${LOG_PREFIX}/${toolName}: Starting ${buttonType} button press on ${simulatorId}`);
    
      try {
        await executeAxeCommand(commandArgs, simulatorId, 'button', executor, axeHelpers);
        log('info', `${LOG_PREFIX}/${toolName}: Success for ${simulatorId}`);
        return createTextResponse(`Hardware button '${buttonType}' pressed successfully.`);
      } catch (error) {
        log('error', `${LOG_PREFIX}/${toolName}: Failed - ${error}`);
        if (error instanceof DependencyError) {
          return axeHelpers.createAxeNotAvailableResponse();
        } else if (error instanceof AxeError) {
          return createErrorResponse(
            `Failed to press button '${buttonType}': ${error.message}`,
            error.axeOutput,
          );
        } else if (error instanceof SystemError) {
          return createErrorResponse(
            `System error executing axe: ${error.message}`,
            error.originalError?.stack,
          );
        }
        return createErrorResponse(
          `An unexpected error occurred: ${error instanceof Error ? error.message : String(error)}`,
        );
      }
    }
  • Zod schema `buttonSchema` validating input parameters: required simulatorId (UUID), buttonType (enum of supported buttons), and optional duration (non-negative number).
    const buttonSchema = z.object({
      simulatorId: z.string().uuid('Invalid Simulator UUID format'),
      buttonType: z.enum(['apple-pay', 'home', 'lock', 'side-button', 'siri']),
      duration: z.number().min(0, 'Duration must be non-negative').optional(),
    });
  • Default export registering the 'button' tool with name, description, public schema (omitting simulatorId), and a session-aware handler wrapping the buttonLogic function.
    const publicSchemaObject = buttonSchema.omit({ simulatorId: true } as const).strict();
    
    export default {
      name: 'button',
      description:
        'Press hardware button on iOS simulator. Supported buttons: apple-pay, home, lock, side-button, siri',
      schema: publicSchemaObject.shape, // MCP SDK compatibility
      handler: createSessionAwareTool<ButtonParams>({
        internalSchema: buttonSchema as unknown as z.ZodType<ButtonParams>,
        logicFunction: (params: ButtonParams, executor: CommandExecutor) =>
          buttonLogic(params, executor, {
            getAxePath,
            getBundledAxeEnvironment,
            createAxeNotAvailableResponse,
          }),
        getExecutor: getDefaultCommandExecutor,
        requirements: [{ allOf: ['simulatorId'], message: 'simulatorId is required' }],
      }),
    };
Behavior2/5

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

With no annotations provided, the description carries full burden of behavioral disclosure. It states what the tool does but doesn't describe important behavioral aspects: whether this requires the simulator to be running, what happens when pressing different button types (e.g., does 'lock' simulate locking the device?), whether there are side effects, or what the expected outcome is. The mention of 'duration' parameter hints at press duration control but isn't explained.

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 perfectly concise - a single sentence that efficiently communicates the core functionality with zero wasted words. It's front-loaded with the main action and immediately follows with the specific supported options.

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?

For a 3-parameter tool with no annotations and no output schema, the description is insufficient. While it covers the button types well, it lacks information about required simulator state, behavioral outcomes, parameter interactions, and what (if anything) the tool returns. The complexity of simulating hardware button presses warrants more complete guidance.

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

Parameters4/5

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

Schema description coverage is 0%, so the description must compensate. It provides valuable semantic context by enumerating the supported button types for the 'buttonType' parameter, which the schema only lists as enum values without explanation. However, it doesn't explain the 'duration' parameter's purpose or the 'simulatorUuid' parameter's role in targeting specific simulators.

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 ('Press hardware button') and the target resource ('iOS simulator'), with specific enumeration of supported button types. It distinguishes from sibling tools like 'key_press', 'tap', or 'gesture' by focusing on physical hardware buttons rather than software interactions.

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 context (iOS simulator hardware button pressing) but doesn't explicitly state when to use this tool versus alternatives like 'home' button simulation via other methods or how it relates to sibling tools like 'lock' functionality. No explicit when-not-to-use guidance or prerequisites are provided.

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/getsentry/XcodeBuildMCP'

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