Skip to main content
Glama

long_press

Simulate long press gestures on Android screens to access context menus, initiate drag actions, or select UI elements by specifying coordinates and duration.

Instructions

Long press at specific coordinates on the Android screen. Useful for context menus, drag initiation, or selection.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xYesX coordinate
yYesY coordinate
durationNoPress duration in milliseconds (default: 1000)
device_idNoDevice serial number

Implementation Reference

  • The core implementation of the long_press tool, which performs an ADB swipe operation for a specific duration to simulate a long press.
    export async function longPress(
      x: number, y: number,
      durationMs: number = 1000,
      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');
    
      // Long press = swipe to same point with long duration
      await adbShell([
        'input', 'swipe',
        String(coords.x), String(coords.y),
        String(coords.x), String(coords.y),
        String(Math.round(durationMs)),
      ], resolved);
    
      deviceManager.touchSession(resolved);
      log.info('Long press performed', { x: coords.x, y: coords.y, durationMs, deviceId: resolved });
      return coords;
    }
  • The MCP tool registration and handler entry point, which invokes the longPress function from the input-controller.
    return await metrics.measure('long_press', device_id || 'default', async () => {
      const resolved = await deviceManager.resolveDeviceId(device_id);
      const execCtx = executionEngine.preExecutionCheck('long_press', { x, y, duration }, 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 longPress(x, y, duration, device_id);
      invalidateCaches(resolved);
      const verification = await verifyAction('long_press', resolved, preHash);
    
      return buildVerifiedResponse({ pressed: result }, execCtx, verification);
    });
Behavior3/5

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

No annotations provided, so description carries full burden. Adds valuable behavioral context via use cases (context menus, drag initiation), but omits execution semantics like blocking behavior, failure modes, or whether the gesture includes a release 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?

Two efficient sentences with zero waste. First sentence front-loads the core action ('Long press at specific coordinates'), second provides usage context. Every word earns its place.

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?

Appropriately complete for a 4-parameter gesture tool with full schema coverage. Covers action, location paradigm, and use cases. Lacks mention of return behavior or error handling, but tool complexity is low enough that the description suffices.

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% (x, y, duration, device_id all documented). Description mentions 'coordinates' reinforcing x/y purpose, but adds no syntax details, format constraints, or semantic meaning beyond what the schema already provides. Baseline 3 appropriate when schema is complete.

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?

Specific verb 'Long press' combined with resource 'coordinates on the Android screen' clearly defines the action. Distinguishes from siblings 'tap' and 'click_element' by specifying 'long press' and 'coordinates' rather than elements or short taps.

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?

Provides clear usage contexts ('context menus, drag initiation, or selection') indicating when to use the tool. However, lacks explicit comparison to alternatives (e.g., when to use 'tap' vs 'long_press') 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/divineDev-dotcom/android_mcp'

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