Skip to main content
Glama

ui_swipe

Simulate a swipe gesture on an iOS simulator by providing start and end coordinates, with adjustable duration and step size for precise testing.

Instructions

Swipe on the screen in the iOS Simulator

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
durationNoSwipe duration in seconds (e.g., 0.1)
udidNoUdid of target, can also be set with the IDB_UDID env var
x_startYesThe starting x-coordinate
y_startYesThe starting y-coordinate
x_endYesThe ending x-coordinate
y_endYesThe ending y-coordinate
deltaNoThe size of each step in the swipe (default is 1)

Implementation Reference

  • src/index.ts:446-515 (registration)
    Registration block for the 'ui_swipe' tool. Calls server.tool() with name, description, Zod schema, metadata, and handler.
    if (!isToolFiltered("ui_swipe")) {
      server.tool(
        "ui_swipe",
        "Swipe on the screen in the iOS Simulator",
        {
          duration: z
            .string()
            .regex(/^\d+(\.\d+)?$/)
            .optional()
            .describe("Swipe duration in seconds (e.g., 0.1)"),
          udid: z
            .string()
            .regex(UDID_REGEX)
            .optional()
            .describe("Udid of target, can also be set with the IDB_UDID env var"),
          x_start: z.number().describe("The starting x-coordinate"),
          y_start: z.number().describe("The starting y-coordinate"),
          x_end: z.number().describe("The ending x-coordinate"),
          y_end: z.number().describe("The ending y-coordinate"),
          delta: z
            .number()
            .optional()
            .describe("The size of each step in the swipe (default is 1)")
            .default(1),
        },
        { title: "UI Swipe", readOnlyHint: false, openWorldHint: true },
        async ({ duration, udid, x_start, y_start, x_end, y_end, delta }) => {
          try {
            const actualUdid = await getBootedDeviceId(udid);
    
            const { stderr } = await idb(
              "ui",
              "swipe",
              "--udid",
              actualUdid,
              ...(duration ? ["--duration", duration] : []),
              ...(delta ? ["--delta", String(delta)] : []),
              "--json",
              // When passing user-provided values to a command, it's crucial to use `--`
              // to separate the command's options from positional arguments.
              // This prevents the shell from misinterpreting the arguments as options.
              "--",
              String(x_start),
              String(y_start),
              String(x_end),
              String(y_end)
            );
    
            if (stderr) throw new Error(stderr);
    
            return {
              isError: false,
              content: [{ type: "text", text: "Swiped successfully" }],
            };
          } catch (error) {
            return {
              isError: true,
              content: [
                {
                  type: "text",
                  text: errorWithTroubleshooting(
                    `Error swiping on the screen: ${toError(error).message}`
                  ),
                },
              ],
            };
          }
        }
      );
    }
  • Zod schema for ui_swipe defining input params: duration (optional string regex), udid (optional UDID regex), x_start, y_start, x_end, y_end (numbers), delta (optional number default 1).
    {
      duration: z
        .string()
        .regex(/^\d+(\.\d+)?$/)
        .optional()
        .describe("Swipe duration in seconds (e.g., 0.1)"),
      udid: z
        .string()
        .regex(UDID_REGEX)
        .optional()
        .describe("Udid of target, can also be set with the IDB_UDID env var"),
      x_start: z.number().describe("The starting x-coordinate"),
      y_start: z.number().describe("The starting y-coordinate"),
      x_end: z.number().describe("The ending x-coordinate"),
      y_end: z.number().describe("The ending y-coordinate"),
      delta: z
        .number()
        .optional()
        .describe("The size of each step in the swipe (default is 1)")
        .default(1),
    },
  • Handler function for ui_swipe. Resolves the booted device ID, executes 'idb ui swipe' with provided coordinates and options, returns success or error with troubleshooting link.
    async ({ duration, udid, x_start, y_start, x_end, y_end, delta }) => {
      try {
        const actualUdid = await getBootedDeviceId(udid);
    
        const { stderr } = await idb(
          "ui",
          "swipe",
          "--udid",
          actualUdid,
          ...(duration ? ["--duration", duration] : []),
          ...(delta ? ["--delta", String(delta)] : []),
          "--json",
          // When passing user-provided values to a command, it's crucial to use `--`
          // to separate the command's options from positional arguments.
          // This prevents the shell from misinterpreting the arguments as options.
          "--",
          String(x_start),
          String(y_start),
          String(x_end),
          String(y_end)
        );
    
        if (stderr) throw new Error(stderr);
    
        return {
          isError: false,
          content: [{ type: "text", text: "Swiped successfully" }],
        };
      } catch (error) {
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: errorWithTroubleshooting(
                `Error swiping on the screen: ${toError(error).message}`
              ),
            },
          ],
        };
      }
    }
  • Helper function 'idb' that wraps the idb CLI command execution.
    async function idb(...args: string[]) {
      return run(getIdbPath(), args);
    }
  • Helper function 'getBootedDeviceId' used by ui_swipe to resolve the target device UDID.
    async function getBootedDeviceId(
      deviceId: string | undefined
    ): Promise<string> {
      // If deviceId not provided, get the currently booted simulator
      let actualDeviceId = deviceId;
      if (!actualDeviceId) {
        const { id } = await getBootedDevice();
        actualDeviceId = id;
      }
      if (!actualDeviceId) {
        throw new Error("No booted simulator found and no deviceId provided");
      }
      return actualDeviceId;
    }
Behavior2/5

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

Annotations already indicate a mutable operation (readOnlyHint=false), but the description adds no behavioral detail (e.g., coordinate system, effect of duration, or side effects). The agent gets no insight beyond the schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence. It is concise but could benefit from slightly more detail without becoming verbose.

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?

Despite having 7 parameters and no output schema, the description is too brief. It omits coordinate system, effect of duration, and behavior after swipe, leaving the agent uninformed.

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?

Schema coverage is 100%, so the description does not need to add param details. However, it adds no extra meaning (e.g., coordinate origin), maintaining the baseline score.

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 it swipes on the iOS Simulator, distinguishing it from siblings like ui_tap and ui_type. However, it doesn't specify the gesture semantics (e.g., drag vs scroll), which limits clarity.

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?

No guidance is provided on when to use this tool versus alternatives like ui_tap or when a swipe is appropriate. The description lacks context for tool selection.

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

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/joshuayoes/ios-simulator-mcp'

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