Skip to main content
Glama

tap_text

Tap UI elements in iOS simulators by matching visible text labels to automate testing and interaction workflows.

Instructions

Find a UI element by visible text and tap its center.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesVisible text/label of the element to tap
udidNoSimulator UDID (optional, defaults to booted simulator)

Implementation Reference

  • The tapText handler function which finds elements by text, chooses the best one, and performs the tap using idb.
    private async tapText(text: string, udid?: string) {
      const target = await resolveUdid(udid);
      try {
        const elements = await this.fetchUiTree(target);
        const matches = findElementsByText(elements, text);
    
        if (matches.length === 0) {
          throw new McpError(ErrorCode.InvalidRequest, `No element found with text matching "${text}"`);
        }
    
        const el = pickBestTextMatch(matches, text, elements);
        const screen = getScreenFrame(elements);
        const primary = inferTapPointForText(el, text, screen);
        const candidates = buildTapPointCandidates(el, primary, screen);
        const beforeSignature = this.buildUiSignature(elements);
    
        let chosen = candidates[0];
        let transitioned = false;
        for (let i = 0; i < candidates.length; i++) {
          const point = candidates[i];
          await execAsync(`idb ui tap --udid ${target} ${point.x} ${point.y}`);
          chosen = point;
    
          const shouldProbeTransition = candidates.length > 1 && i < candidates.length - 1;
          if (!shouldProbeTransition) break;
    
          await new Promise((resolve) => setTimeout(resolve, 350));
          const afterProbe = await this.fetchUiTree(target);
          if (this.buildUiSignature(afterProbe) !== beforeSignature) {
            transitioned = true;
            break;
          }
        }
    
        return {
          content: [{
            type: 'text',
            text: `Tapped element "${el.label ?? el.value ?? text}" at (${chosen.x}, ${chosen.y}) on ${target} using ${chosen.strategy}${transitioned ? ' (transition-detected)' : ''}`,
          }],
        };
      } catch (error: any) {
        if (error instanceof McpError) throw error;
        throw new McpError(ErrorCode.InternalError, `Failed to tap text: ${error.message}`);
      }
    }
  • src/index.ts:460-471 (registration)
    Tool definition for 'tap_text'.
      name: 'tap_text',
      description: 'Find a UI element by visible text and tap its center.',
      inputSchema: {
        type: 'object',
        properties: {
          text: { type: 'string', description: 'Visible text/label of the element to tap' },
          udid: { type: 'string', description: 'Simulator UDID (optional, defaults to booted simulator)' },
        },
        required: ['text'],
        additionalProperties: false,
      },
    },
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 states the action ('tap its center') but omits critical details like whether this requires app focus, what happens if the text isn't found (error behavior), or if it's limited to specific app states. For a UI interaction tool, this leaves significant gaps in understanding its operation.

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 a single, efficient sentence that front-loads the core action ('Find... and tap') with no wasted words. Every part contributes directly to understanding the tool's purpose, making it highly concise and well-structured.

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

Completeness3/5

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

Given the tool's moderate complexity (UI interaction with targeting), no annotations, and no output schema, the description is minimally adequate. It covers the basic action but lacks details on behavioral outcomes, error handling, or dependencies (e.g., needing a booted simulator), leaving room for improvement in completeness.

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 fully documents both parameters (text and udid). The description adds no additional parameter semantics beyond what the schema provides, such as text matching rules or udid defaults. Baseline 3 is appropriate when the schema handles all parameter documentation.

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 ('Find... and tap') and target resource ('UI element by visible text'), distinguishing it from siblings like tap_id (by ID) or tap_relative (by coordinates). It precisely conveys the tool's function without redundancy.

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

Usage Guidelines4/5

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

The description implies usage context by specifying 'visible text' targeting, suggesting it's for interacting with labeled UI elements. However, it lacks explicit guidance on when to use this versus alternatives like tap_id (for elements with IDs) or find_elements (for locating without tapping), missing clear exclusions or prerequisites.

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/xmuweili/app-screen-mcp'

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