Skip to main content
Glama

tap

Tap on Android screen coordinates to interact with apps and automate UI tasks. Use absolute pixels or normalized values for precise touch simulation.

Instructions

Tap at specific coordinates on the Android screen. Coordinates can be absolute pixels or normalized (0-1 range, will be scaled to screen size).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xYesX coordinate (pixels or 0-1 normalized)
yYesY coordinate (pixels or 0-1 normalized)
device_idNoDevice serial number

Implementation Reference

  • The handler implementation for the tap tool, which resolves device ID, checks rate limits, validates coordinates, and executes the ADB tap command.
    export async function tap(x: number, y: number, deviceId?: string): Promise<{ x: number; y: number }> {
      const resolved = await deviceManager.resolveDeviceId(deviceId);
      deviceManager.checkRateLimit(resolved);
    
      const coords = await normalizeCoordinates(x, y, resolved);
      validateCoordinate(coords.x, 'x');
      validateCoordinate(coords.y, 'y');
    
      await adbShell(['input', 'tap', String(coords.x), String(coords.y)], resolved);
      deviceManager.touchSession(resolved);
    
      log.info('Tap performed', { x: coords.x, y: coords.y, deviceId: resolved });
      return coords;
    }
  • The MCP tool registration for 'tap', which handles input validation using zod, checks execution context, invokes the core tap handler, and performs post-action verification.
    server.registerTool(
      'tap',
      {
        description: 'Tap at specific coordinates on the Android screen. Coordinates can be absolute pixels or normalized (0-1 range, will be scaled to screen size).',
        inputSchema: {
          x: z.number().describe('X coordinate (pixels or 0-1 normalized)'),
          y: z.number().describe('Y coordinate (pixels or 0-1 normalized)'),
          device_id: z.string().optional().describe('Device serial number'),
        },
      },
      async ({ x, y, device_id }) => {
        return await metrics.measure('tap', device_id || 'default', async () => {
          const resolved = await deviceManager.resolveDeviceId(device_id);
          const execCtx = executionEngine.preExecutionCheck('tap', { x, y }, resolved);
    
          if (!execCtx.allowed) {
            return {
              content: [{
                type: 'text' as const,
                text: JSON.stringify({
                  success: false,
                  blocked: true,
                  reason: execCtx.blockReason,
                  _context: execCtx.recentContext,
                }, null, 2),
              }],
            };
          }
    
          const preHash = await capturePreActionState(resolved);
          const result = await tap(x, y, resolved);
          invalidateCaches(resolved);
          const verification = await verifyAction('tap', resolved, preHash);
    
          return buildVerifiedResponse({ tapped: result }, execCtx, verification);
        });
      }
    );

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/divineDev-dotcom/android_mcp'

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