Skip to main content
Glama
zillow
by zillow

swipe

Scroll mobile app interfaces in specified directions and speeds to locate elements or text during automated testing.

Instructions

Unified scroll command supporting direction and speed (no index support due to reliability)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
containerElementIdYesElement ID to scroll until visible
directionYesScroll direction
lookForNoWhat we're searching for while scrolling
speedNoScroll speed
platformYesPlatform of the device

Implementation Reference

  • Registration of the 'swipe' tool, which uses scrollSchema for input validation and scrollHandler for execution logic.
      "swipe",
      "Unified scroll command supporting direction and speed (no index support due to reliability)",
      scrollSchema,
      scrollHandler,
      true // Supports progress notifications
    );
  • The scrollHandler function, directly used as the handler for the 'swipe' tool. Implements scrolling logic by performing repeated swipes on a container element until a target is found or basic scroll is done.
    const scrollHandler = async (device: BootedDevice, args: ScrollArgs, progress?: ProgressCallback) => {
      // Element-specific scrolling
      const observeScreen = new ObserveScreen(device);
      const swipe = new SwipeOnElement(device);
      const observeResult = await observeScreen.execute();
    
      if (!observeResult.viewHierarchy) {
        throw new ActionableError("Could not get view hierarchy for element scrolling");
      }
    
      // Find the element by resource ID
      const element = elementUtils.findElementByResourceId(
        observeResult.viewHierarchy,
        args.containerElementId,
        args.containerElementId,
        true // partial match
      );
    
      if (!element) {
        throw new ActionableError(`Container element not found with ID: ${args.containerElementId}`);
      }
    
      const containerElement = element;
    
      if (!args.lookFor) {
        const duration = elementUtils.getSwipeDurationFromSpeed(args.speed);
        const result = await swipe.execute(
          containerElement,
          elementUtils.getSwipeDirectionForScroll(args.direction), {
            duration: duration,
            easing: "accelerateDecelerate",
            fingers: 1,
            randomize: false,
            lift: true,
            pressure: 1
          },
          progress
        );
    
        return createJSONToolResponse({
          message: `Scrolled ${args.direction} within element ${args.containerElementId}`,
          observation: result.observation
        });
    
      } else if (!args.lookFor.text && !args.lookFor.elementId) {
        throw new ActionableError("Either text or element id must be specified to look for something in a scrollable list.");
      } else {
        let lastObservation = await observeScreen.execute();
        if (!lastObservation.viewHierarchy || !lastObservation.screenSize) {
          throw new Error("Failed to get initial observation for scrolling until visible.");
        }
    
        const direction = args.direction;
        const maxTime = 120000; // args.lookFor.maxTime ?? 120000;
        const startTime = Date.now();
        let foundElement = null;
    
        while (Date.now() - startTime < maxTime) {
          // Re-observe the screen to get current state
          lastObservation = await observeScreen.execute();
          if (!lastObservation.viewHierarchy) {
            throw new Error("Lost observation during scroll until visible.");
          }
    
          // Check if target element is now visible
          if (args.lookFor.text) {
            foundElement = elementUtils.findElementByText(
              lastObservation.viewHierarchy,
              args.lookFor.text,
              args.containerElementId, // Search within the specific container
              true, // fuzzy match
              false // case-sensitive
            );
          } else if (args.lookFor.elementId) {
            foundElement = elementUtils.findElementByResourceId(
              lastObservation.viewHierarchy,
              args.lookFor.elementId,
              args.containerElementId, // Search within the specific container
              true // partial match
            );
          }
    
          if (foundElement) {
            logger.info(`Found element after scrolling for ${Date.now() - startTime}ms.`);
            break;
          }
    
          // Use the specific container element to swipe, not any scrollable element
          const result = await swipe.execute(
            containerElement,
            elementUtils.getSwipeDirectionForScroll(direction),
            { duration: 600 },
            progress
          );
    
          // Update observation from swipe result
          if (result.observation && result.observation.viewHierarchy) {
            lastObservation = result.observation;
          } else {
            throw new Error("Lost observation after swipe during scroll until visible.");
          }
        }
    
        if (!foundElement) {
          const target = args.lookFor.text ? `text "${args.lookFor.text}"` : `element with id "${args.lookFor.elementId}"`;
          throw new ActionableError(`${target} not found after scrolling for ${maxTime}ms.`);
        }
    
        const target = args.lookFor.text ? `text "${args.lookFor.text}"` : `element with id "${args.lookFor.elementId}"`;
        return createJSONToolResponse({
          message: `Scrolled until ${target} became visible`,
          found: !!foundElement,
          observation: lastObservation
        });
      }
    };
  • Zod schema for input parameters to the 'swipe' tool (shared with 'scroll' tool).
    export const scrollSchema = z.object({
      containerElementId: z.string().describe("Element ID to scroll until visible"),
      direction: z.enum(["up", "down", "left", "right"]).describe("Scroll direction"),
      lookFor: z.object({
        elementId: z.string().optional().describe("ID of the element to look for while scrolling"),
        text: z.string().optional().describe("Optional text to look for while scrolling"),
        maxTime: z.number().optional().describe("Maximum amount of time to spend scrolling, (default 10 seconds)")
      }).optional().describe("What we're searching for while scrolling"),
      speed: z.enum(["slow", "normal", "fast"]).optional().describe("Scroll speed"),
      platform: z.enum(["android", "ios"]).describe("Platform of the device")
    });
  • SwipeOnElement.execute method: core helper function used by scrollHandler to perform individual swipe gestures on UI elements.
    async execute(
      element: Element,
      direction: "up" | "down" | "left" | "right",
      options: GestureOptions = {},
      progress?: ProgressCallback
    ): Promise<SwipeResult> {
      logger.info(`[SwipeOnElement] Starting swipe: direction=${direction}, platform=${this.device.platform}`);
      logger.info(`[SwipeOnElement] Element bounds: ${JSON.stringify(element.bounds)}`);
      logger.info(`[SwipeOnElement] Options: ${JSON.stringify(options)}`);
    
      return this.observedInteraction(
        async () => {
          logger.info(`[SwipeOnElement] In observedInteraction callback`);
    
          const { startX, startY, endX, endY } = this.elementUtils.getSwipeWithinBounds(
            direction,
            element.bounds
          );
    
          logger.info(`[SwipeOnElement] Raw swipe coordinates: start=(${startX}, ${startY}), end=(${endX}, ${endY})`);
    
          const flooredStartX = Math.floor(startX);
          const flooredStartY = Math.floor(startY);
          const flooredEndX = Math.floor(endX);
          const flooredEndY = Math.floor(endY);
    
          logger.info(`[SwipeOnElement] Floored swipe coordinates: start=(${flooredStartX}, ${flooredStartY}), end=(${flooredEndX}, ${flooredEndY})`);
    
          try {
            const result = await this.executeGesture.swipe(
              flooredStartX,
              flooredStartY,
              flooredEndX,
              flooredEndY,
              options
            );
            logger.info(`[SwipeOnElement] Swipe completed successfully: ${JSON.stringify(result)}`);
            return result;
          } catch (error) {
            logger.error(`[SwipeOnElement] Swipe execution failed: ${error}`);
            throw error;
          }
        },
        {
          changeExpected: false,
          timeoutMs: 500,
          progress
        }
      );
    }
  • TypeScript interface defining the return type for swipe operations, used throughout the swipe implementations.
    export interface SwipeResult {
      success: boolean;
      x1: number;
      y1: number;
      x2: number;
      y2: number;
      duration: number;
      path?: number;
      easing?: "linear" | "decelerate" | "accelerate" | "accelerateDecelerate";
      observation?: ObserveResult;
      error?: string;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'no index support due to reliability', which adds some context about limitations, but fails to describe critical behaviors like whether this is a read-only or mutating operation, what happens on success/failure, or any performance/rate-limit considerations for a scrolling tool.

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 appropriately concise with a single sentence that communicates the core functionality and a key limitation. It's front-loaded with the main purpose, though it could be slightly more structured by separating the capability statement from the limitation.

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 scrolling tool with 5 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what the tool returns, how errors are handled, or provide context about scrolling behavior differences across platforms. The 'no index support' note is helpful but doesn't compensate for other missing behavioral information.

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 description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional meaning beyond what's in the schema - it mentions direction and speed but doesn't explain their interaction or provide usage examples. Baseline 3 is appropriate when schema does the heavy lifting.

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 the tool's purpose as a 'Unified scroll command' that supports direction and speed, which is a specific verb+resource combination. It distinguishes itself from siblings like 'scroll' by mentioning 'no index support due to reliability', though it doesn't explicitly differentiate from 'swipeOnElement' or 'swipeOnScreen'.

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?

The description provides no guidance on when to use this tool versus alternatives like 'scroll', 'swipeOnElement', or 'swipeOnScreen'. It mentions 'no index support' as a limitation but doesn't explain when this tool is preferred or when other tools might be better suited.

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/zillow/auto-mobile'

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