Skip to main content
Glama
zillow
by zillow

tapOn

Tap on mobile app elements by text or ID to automate testing and interactions for Android and iOS devices.

Instructions

Tap supporting text or resourceId

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
containerElementIdNoContainer element ID to restrict the search within
actionYesAction to perform on the element
textNoText to tap on
idNoElement ID to tap on
platformYesPlatform of the device

Implementation Reference

  • Registration of the 'tapOn' tool in the ToolRegistry, linking name, description, schema, and handler function.
      "tapOn",
      "Tap supporting text or resourceId",
      tapOnSchema,
      tapOnHandler,
      true // Supports progress notifications
    );
  • The main handler function for the 'tapOn' tool. It instantiates TapOnElement and calls its execute method with parsed arguments, then formats the response.
    const tapOnHandler = async (device: BootedDevice, args: TapOnArgs, progress?: ProgressCallback) => {
      const tapOnTextCommand = new TapOnElement(device);
      const result = await tapOnTextCommand.execute({
        containerElementId: args.containerElementId,
        text: args.text,
        elementId: args.id,
        action: args.action,
      }, progress);
    
      return createJSONToolResponse({
        message: `Tapped on element`,
        observation: result.observation,
        ...result
      });
    };
  • Zod schema defining the input parameters for the 'tapOn' tool, including optional container, action, text, id, and required platform.
    export const tapOnSchema = z.object({
      containerElementId: z.string().optional().describe("Container element ID to restrict the search within"),
      action: z.enum(["tap", "doubleTap", "longPress", "focus"]).describe("Action to perform on the element"),
      text: z.string().optional().describe("Text to tap on"),
      id: z.string().optional().describe("Element ID to tap on"),
      platform: z.enum(["android", "ios"]).describe("Platform of the device")
    });
  • Core execution logic in TapOnElement.execute(). Finds element by text or ID, calculates tap point, handles focus check, performs platform-specific tap/doubleTap/longPress via ADB or Axe, wrapped in observedInteraction.
    async execute(options: TapOnElementOptions, progress?: ProgressCallback): Promise<TapOnElementResult> {
      if (!options.action) {
        return this.createErrorResult(options.action, "tap on action is required");
      }
    
      try {
        // Tap on the calculated point using observedChange
        return await this.observedInteraction(
          async (observeResult: ObserveResult) => {
    
            const viewHierarchy = observeResult.viewHierarchy;
            if (!viewHierarchy) {
              return { success: false, error: "Unable to get view hierarchy, cannot tap on element" };
            }
    
            const element = await this.findElementToTap(options, viewHierarchy);
            const tapPoint = this.elementUtils.getElementCenter(element);
    
            if (options.action === "focus") {
              // Check if element is already focused
              const isFocused = this.elementUtils.isElementFocused(element);
    
              if (isFocused) {
                logger.info(`Element is already focused, no action needed`);
                return {
                  success: true,
                  element: element,
                  wasAlreadyFocused: true,
                  focusChanged: false,
                  x: tapPoint.x,
                  y: tapPoint.y
                };
              }
    
              // if not, change action to tap
              options.action = "tap";
            }
    
            // Platform-specific tap execution
            switch (this.device.platform) {
              case "android":
                await this.executeAndroidTap(options.action, tapPoint.x, tapPoint.y);
                break;
              case "ios":
                await this.executeiOSTap(options.action, tapPoint.x, tapPoint.y);
                break;
              default:
                throw new ActionableError(`Unsupported platform: ${this.device.platform}`);
            }
    
            return {
              success: true,
              action: options.action,
              element,
            };
          },
          {
            queryOptions: {
              text: options.text,
              elementId: options.elementId,
              containerElementId: options.containerElementId
            },
            changeExpected: false,
            timeoutMs: 800, // Reduce timeout for faster execution
            progress
          }
        );
      } catch (error) {
        throw new ActionableError(`Failed to perform tap on element: ${error}`);
      }
    }
Behavior1/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 but provides almost none. It doesn't indicate whether this is a read or write operation, what happens when the element isn't found, whether it requires specific device states, or what the expected outcomes are. The description fails to disclose critical behavioral traits needed for safe and effective tool invocation.

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

Conciseness2/5

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

While technically concise with just 4 words, this is under-specification rather than effective conciseness. The single phrase doesn't provide enough information to be useful, and it's not front-loaded with the most critical information. Every word should earn its place, but here the words don't provide sufficient value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a 5-parameter mobile interaction tool with no annotations and no output schema, the description is completely inadequate. It doesn't explain what the tool does, when to use it, what behaviors to expect, or how parameters interact. For a tool that performs UI actions on mobile devices, this minimal description leaves the agent guessing about critical operational details.

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 5 parameters thoroughly with descriptions and enums. The description mentions 'text or resourceId' which loosely maps to the text and id parameters, but doesn't add meaningful semantic context beyond what the schema provides. The baseline of 3 is appropriate since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Tap supporting text or resourceId' is a tautology that essentially restates the tool name 'tapOn' without adding meaningful specificity. It mentions 'supporting text or resourceId' which hints at the text/id parameters, but doesn't clearly state what the tool actually does (perform UI interactions on mobile elements). It doesn't distinguish this from similar sibling tools like swipeOnElement or pressButton.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/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. It doesn't mention when this tool is appropriate compared to other interaction tools like swipeOnElement, pressButton, or inputText. There's no indication of prerequisites, constraints, or typical use cases for mobile UI automation.

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