Skip to main content
Glama

tap_and_wait

Tap an Android UI element and wait for the interface to stabilize, returning the updated UI tree in a single operation to automate touch interactions.

Instructions

Tap element then wait for UI to settle and return the new UI tree. Combines tap + wait + get_ui_tree into a single fast operation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
byYesHow to find the element to tap
valueYesValue to match
wait_msNoTime to wait for UI to settle after tap (default 1000ms)
device_idNoDevice ID (optional if only one device)

Implementation Reference

  • The handler implementation for the `tap_and_wait` MCP tool. It performs the tap, waits for the specified duration, and then retrieves the new UI tree.
    async ({ by, value, wait_ms, device_id }) => {
      const elements = await adb.getUiTree(device_id);
      const finder: Record<string, (el: (typeof elements)[0]) => boolean> = {
        "resource-id": (el) => el.resourceId === value || el.resourceId.endsWith(`:id/${value}`),
        text: (el) => el.text === value || el.text.toLowerCase().includes(value.toLowerCase()),
        "content-desc": (el) =>
          el.contentDesc === value ||
          el.contentDesc.toLowerCase().includes(value.toLowerCase()),
      };
    
      const el = elements.find(finder[by]);
      if (!el) {
        return {
          content: [
            {
              type: "text",
              text: `Element not found: ${by}="${value}". Available elements:\n${elements
                .filter((e) => e.clickable)
                .map((e) => `  id:${e.resourceId} text:"${e.text}" desc:"${e.contentDesc}"`)
                .join("\n")}`,
            },
          ],
          isError: true,
        };
      }
    
      await adb.tap(el.center.x, el.center.y, device_id);
      await new Promise((r) => setTimeout(r, wait_ms));
    
      const newElements = await adb.getUiTree(device_id);
      const summary = newElements.map((newEl, i) => {
        const parts: string[] = [`[${i}]`];
        if (newEl.resourceId) parts.push(`id:${newEl.resourceId}`);
        if (newEl.text) parts.push(`text:"${newEl.text}"`);
        if (newEl.contentDesc) parts.push(`desc:"${newEl.contentDesc}"`);
        parts.push(`class:${newEl.className.split(".").pop()}`);
        parts.push(`center:(${newEl.center.x},${newEl.center.y})`);
        const flags: string[] = [];
        if (newEl.clickable) flags.push("clickable");
        if (newEl.scrollable) flags.push("scrollable");
        if (newEl.checked) flags.push("checked");
        if (newEl.focused) flags.push("focused");
        if (!newEl.enabled) flags.push("disabled");
        if (flags.length) parts.push(`[${flags.join(",")}]`);
        return parts.join(" ");
      });
    
      return {
        content: [
          {
            type: "text",
            text: `Tapped "${by}=${value}" at (${el.center.x}, ${el.center.y}) [${el.className.split(".").pop()}]\n\nNew UI (${newElements.length} elements):\n\n${summary.join("\n")}`,
          },
        ],
      };
    },
  • The Zod schema validation for the `tap_and_wait` tool inputs.
    {
      by: z
        .enum(["resource-id", "text", "content-desc"])
        .describe("How to find the element to tap"),
      value: z.string().describe("Value to match"),
      wait_ms: z.number().optional().default(1000).describe("Time to wait for UI to settle after tap (default 1000ms)"),
      device_id: z.string().optional().describe("Device ID (optional if only one device)"),
    },
  • src/index.ts:222-224 (registration)
    The MCP tool registration for `tap_and_wait`.
    server.tool(
      "tap_and_wait",
      "Tap element then wait for UI to settle and return the new UI tree. Combines tap + wait + get_ui_tree into a single fast operation.",
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses the behavioral trait of returning 'the new UI tree' after the operation, which is valuable. However, it doesn't mention potential side effects (like what happens if the tap fails), error conditions, or performance characteristics beyond 'fast operation'. For a tool with no annotations, this leaves some behavioral aspects unclear.

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

Conciseness5/5

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

The description is perfectly concise with two sentences that each earn their place: the first states the core functionality, and the second explains the efficiency benefit. It's front-loaded with the main purpose and contains zero wasted words.

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

Completeness4/5

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

For a tool with 4 parameters, 100% schema coverage, but no output schema and no annotations, the description does well by explaining the composite nature and efficiency benefit. However, it doesn't describe the return value format (what 'UI tree' means) or error scenarios, leaving some gaps given the lack of output schema.

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 fully documents all parameters. The description doesn't add any parameter-specific information beyond what's in the schema (like explaining the 'by' enum values or 'wait_ms' behavior). With complete schema coverage, the baseline score of 3 is appropriate as the description doesn't enhance parameter understanding.

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

Purpose5/5

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

The description clearly states the specific action ('Tap element then wait for UI to settle and return the new UI tree') and explicitly distinguishes it from sibling tools by mentioning it combines 'tap + wait + get_ui_tree into a single fast operation'. This directly contrasts with individual tools like 'tap', 'wait_for_element', and 'get_ui_tree' in the sibling list.

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

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool versus alternatives: it states it's for combining three operations (tap, wait, get_ui_tree) into one faster operation, implying it should be used instead of calling those three tools separately. This gives clear context about its efficiency advantage over the sibling tools.

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/martingeidobler/android-mcp-server'

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