Skip to main content
Glama

tap_id

Tap iOS UI elements by their accessibility identifier for automated testing and interaction in simulators.

Instructions

Find a UI element by its accessibility identifier and tap its center.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesAccessibility identifier of the element (set via .accessibilityIdentifier in SwiftUI)
udidNoSimulator UDID (optional, defaults to booted simulator)

Implementation Reference

  • The tapById method handles the tap_id tool, searching for an element by ID in the UI tree, handling specific toggle logic for switches, and executing the tap via idb.
    private async tapById(id: string, udid?: string) {
      const target = await resolveUdid(udid);
      try {
        const elements = await this.fetchUiTree(target);
        const matches = findElementsById(elements, id);
    
        if (matches.length === 0) {
          throw new McpError(ErrorCode.InvalidRequest, `No element found with identifier "${id}"`);
        }
    
        const el = matches[0];
        const cx = Math.round(el.frame.x + el.frame.w / 2);
        const cy = Math.round(el.frame.y + el.frame.h / 2);
    
        // UISwitch requires a swipe gesture; a raw coordinate tap doesn't toggle it
        if (/switch/i.test(el.type)) {
          const isOn = el.value === '1';
          const fromX = isOn
            ? Math.round(el.frame.x + el.frame.w - 6)
            : Math.round(el.frame.x + 6);
          const toX = isOn
            ? Math.round(el.frame.x + 6)
            : Math.round(el.frame.x + el.frame.w - 6);
          await execAsync(`idb ui swipe --udid ${target} ${fromX} ${cy} ${toX} ${cy} --duration 0.15`);
          return {
            content: [{
              type: 'text',
              text: `Toggled switch "${id}" (was ${isOn ? 'ON' : 'OFF'}) at (${cx}, ${cy}) on ${target}`,
            }],
          };
        }
    
        await execAsync(`idb ui tap --udid ${target} ${cx} ${cy}`);
        return {
          content: [{
            type: 'text',
            text: `Tapped element with id "${id}" at (${cx}, ${cy}) on ${target}`,
          }],
        };
      } catch (error: any) {
        if (error instanceof McpError) throw error;
        throw new McpError(ErrorCode.InternalError, `Failed to tap by id: ${error.message}`);
      }
    }
  • src/index.ts:473-484 (registration)
    Definition of the tap_id tool in the ListToolsRequestSchema.
      name: 'tap_id',
      description: 'Find a UI element by its accessibility identifier and tap its center.',
      inputSchema: {
        type: 'object',
        properties: {
          id: { type: 'string', description: 'Accessibility identifier of the element (set via .accessibilityIdentifier in SwiftUI)' },
          udid: { type: 'string', description: 'Simulator UDID (optional, defaults to booted simulator)' },
        },
        required: ['id'],
        additionalProperties: false,
      },
    },
  • src/index.ts:534-535 (registration)
    CallToolRequestSchema handler for tap_id.
    case 'tap_id':
      return this.tapById(args.id as string, args.udid);
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action (find and tap) but does not mention potential side effects (e.g., app state changes), error conditions (e.g., if element not found), or performance considerations. It adds minimal context beyond the basic action.

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 directly states the tool's purpose without any wasted words. It is front-loaded with the core action and resource, making it easy to understand quickly.

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 (interactive UI action), lack of annotations, and no output schema, the description is minimally adequate. It covers the basic purpose but lacks details on behavior, errors, or output, which could be important for an AI agent to use it correctly in context.

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 both parameters ('id' and 'udid') fully. The description does not add any meaning beyond what the schema provides, such as examples or usage nuances, but the baseline is 3 when schema coverage is high.

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 its center') and the target resource ('UI element by its accessibility identifier'). It distinguishes itself from siblings like 'tap' (generic), 'tap_text' (text-based), and 'tap_relative' (coordinate-based) by specifying the identifier-based targeting method.

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

Usage Guidelines3/5

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

The description implies usage when you need to tap an element via its accessibility identifier, but it does not explicitly state when to use this tool versus alternatives like 'tap_text' (for text-based tapping) or 'tap' (for coordinate-based tapping). No exclusions or prerequisites are mentioned.

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