Skip to main content
Glama

android_touch

Simulate touch interactions on Android devices by specifying screen coordinates and duration for automated testing or remote control.

Instructions

Simulate a touch event at specific screen coordinates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xYesX coordinate
yYesY coordinate
durationNoTouch duration in milliseconds (default: 100)
deviceSerialNoSpecific device serial number to target (optional)

Implementation Reference

  • The main handler function for the 'android_touch' tool. It validates input arguments and calls the ADB wrapper's touch method to simulate the touch event.
    export async function touchHandler(
      adb: ADBWrapper,
      args: any
    ): Promise<{ content: Array<{ type: string; text: string }> }> {
      const { x, y, duration = 100, deviceSerial } = args as TouchArgs;
    
      if (typeof x !== 'number' || typeof y !== 'number') {
        throw new Error('Invalid coordinates: x and y must be numbers');
      }
    
      if (x < 0 || y < 0) {
        throw new Error('Invalid coordinates: x and y must be positive');
      }
    
      try {
        await adb.touch(x, y, duration, deviceSerial);
    
        return {
          content: [
            {
              type: 'text',
              text: `Touch executed at (${x}, ${y}) with duration ${duration}ms`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Touch failed: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • The input schema and metadata for the 'android_touch' tool, registered in the ListTools response.
    {
      name: 'android_touch',
      description: 'Simulate a touch event at specific screen coordinates',
      inputSchema: {
        type: 'object',
        properties: {
          x: {
            type: 'number',
            description: 'X coordinate',
          },
          y: {
            type: 'number',
            description: 'Y coordinate',
          },
          duration: {
            type: 'number',
            description: 'Touch duration in milliseconds (default: 100)',
            default: 100,
          },
          deviceSerial: {
            type: 'string',
            description: 'Specific device serial number to target (optional)',
          },
        },
        required: ['x', 'y'],
      },
    },
  • src/index.ts:466-467 (registration)
    The switch case that registers and routes 'android_touch' tool calls to the touchHandler function.
    case 'android_touch':
      return await touchHandler(this.adb, args);
  • The ADBWrapper.touch method that implements the actual touch simulation using ADB 'input tap' or 'input swipe' shell commands.
    async touch(
      x: number,
      y: number,
      duration: number = 100,
      deviceSerial?: string
    ): Promise<void> {
      const device = await this.getTargetDevice(deviceSerial);
    
      if (duration <= 100) {
        // Simple tap
        await this.exec(['shell', 'input', 'tap', String(x), String(y)], device);
      } else {
        // Long press using swipe with same start/end coordinates
        await this.exec(
          ['shell', 'input', 'swipe', String(x), String(y), String(x), String(y), String(duration)],
          device
        );
      }
    }
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 mentions 'simulate a touch event' which implies a write/mutation operation, but fails to specify critical details like required permissions (e.g., device accessibility), side effects (e.g., potential app state changes), error handling, or response format. This is a significant gap for a tool that interacts with device input.

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 function without unnecessary words. It is front-loaded with the core action ('simulate a touch event') and avoids redundancy, making it easy for an agent to parse quickly.

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

Completeness2/5

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

For a tool with no annotations, no output schema, and parameters that control device interaction, the description is incomplete. It lacks information about behavioral traits (e.g., mutation effects, error conditions), output expectations, or integration context (e.g., how it relates to other Android tools like android_start_scrcpy_stream). This leaves the agent under-informed for safe and effective use.

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 all parameters (x, y, duration, deviceSerial). The description adds no additional meaning beyond the schema's parameter descriptions, such as coordinate system details (e.g., screen resolution) or practical usage tips. Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('simulate a touch event') and target ('at specific screen coordinates'), which distinguishes it from siblings like android_swipe or android_uiautomator_click that involve different interaction types. However, it doesn't explicitly differentiate from all siblings (e.g., android_uiautomator_click also involves touch-like actions but with element-based targeting).

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

Usage Guidelines2/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 like android_swipe (for drag gestures) or android_uiautomator_click (for element-based interactions). It lacks context about prerequisites (e.g., device state) or exclusions, leaving the agent to infer usage from the tool name and parameters alone.

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

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