swipe
Perform precise swipes on iOS simulators by defining exact coordinates and timing parameters. Use describe_ui for accuracy and avoid guessing from screenshots. Integrates with XcodeBuildMCP for streamlined testing.
Instructions
Swipe from one point to another. Use describe_ui for precise coordinates (don't guess from screenshots). Supports configurable timing.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| delta | No | ||
| duration | No | ||
| postDelay | No | ||
| preDelay | No | ||
| simulatorUuid | Yes | ||
| x1 | Yes | ||
| x2 | Yes | ||
| y1 | Yes | ||
| y2 | Yes |
Implementation Reference
- src/mcp/tools/ui-testing/swipe.ts:50-120 (handler)Core handler function that parses parameters, constructs the axe 'swipe' command arguments, executes it on the iOS simulator, handles responses, warnings, and errors.export async function swipeLogic( params: SwipeParams, executor: CommandExecutor, axeHelpers: AxeHelpers = { getAxePath, getBundledAxeEnvironment, createAxeNotAvailableResponse, }, ): Promise<ToolResponse> { const toolName = 'swipe'; const { simulatorId, x1, y1, x2, y2, duration, delta, preDelay, postDelay } = params; const commandArgs = [ 'swipe', '--start-x', String(x1), '--start-y', String(y1), '--end-x', String(x2), '--end-y', String(y2), ]; if (duration !== undefined) { commandArgs.push('--duration', String(duration)); } if (delta !== undefined) { commandArgs.push('--delta', String(delta)); } if (preDelay !== undefined) { commandArgs.push('--pre-delay', String(preDelay)); } if (postDelay !== undefined) { commandArgs.push('--post-delay', String(postDelay)); } const optionsText = duration ? ` duration=${duration}s` : ''; log( 'info', `${LOG_PREFIX}/${toolName}: Starting swipe (${x1},${y1})->(${x2},${y2})${optionsText} on ${simulatorId}`, ); try { await executeAxeCommand(commandArgs, simulatorId, 'swipe', executor, axeHelpers); log('info', `${LOG_PREFIX}/${toolName}: Success for ${simulatorId}`); const warning = getCoordinateWarning(simulatorId); const message = `Swipe from (${x1}, ${y1}) to (${x2}, ${y2})${optionsText} simulated successfully.`; if (warning) { return createTextResponse(`${message}\n\n${warning}`); } return createTextResponse(message); } 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 simulate swipe: ${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 defining the input parameters for the swipe tool including required simulatorId, start/end coordinates, and optional timing parameters.const swipeSchema = z.object({ simulatorId: z.string().uuid('Invalid Simulator UUID format'), x1: z.number().int('Start X coordinate'), y1: z.number().int('Start Y coordinate'), x2: z.number().int('End X coordinate'), y2: z.number().int('End Y coordinate'), duration: z.number().min(0, 'Duration must be non-negative').optional(), delta: z.number().min(0, 'Delta must be non-negative').optional(), preDelay: z.number().min(0, 'Pre-delay must be non-negative').optional(), postDelay: z.number().min(0, 'Post-delay must be non-negative').optional(), });
- src/mcp/tools/ui-testing/swipe.ts:122-138 (registration)Default export registering the 'swipe' tool with name, description, public schema (omitting simulatorId), and handler created by createSessionAwareTool that wraps the swipeLogic function.export default { name: 'swipe', description: "Swipe from one point to another. Use describe_ui for precise coordinates (don't guess from screenshots). Supports configurable timing.", schema: publicSchemaObject.shape, // MCP SDK compatibility handler: createSessionAwareTool<SwipeParams>({ internalSchema: swipeSchema as unknown as z.ZodType<SwipeParams>, logicFunction: (params: SwipeParams, executor: CommandExecutor) => swipeLogic(params, executor, { getAxePath, getBundledAxeEnvironment, createAxeNotAvailableResponse, }), getExecutor: getDefaultCommandExecutor, requirements: [{ allOf: ['simulatorId'], message: 'simulatorId is required' }], }), };