Skip to main content
Glama

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
NameRequiredDescriptionDefault
deltaNo
durationNo
postDelayNo
preDelayNo
simulatorUuidYes
x1Yes
x2Yes
y1Yes
y2Yes

Implementation Reference

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

Tool Definition Quality

Score is being calculated. Check back soon.

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