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' }], }), };

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

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