Skip to main content
Glama

swipe

Perform swipe gestures on Android screens to scroll content, navigate between pages, or execute drag actions by specifying start and end coordinates.

Instructions

Swipe from one point to another on the Android screen. Useful for scrolling, swiping between pages, or drag gestures.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
x1YesStart X coordinate
y1YesStart Y coordinate
x2YesEnd X coordinate
y2YesEnd Y coordinate
durationNoSwipe duration in milliseconds (default: 300)
device_idNoDevice serial number

Implementation Reference

  • The actual implementation of the swipe logic using ADB commands.
    export async function swipe(
      x1: number, y1: number,
      x2: number, y2: number,
      durationMs: number = 300,
      deviceId?: string
    ): Promise<{ from: { x: number; y: number }; to: { x: number; y: number } }> {
      const resolved = await deviceManager.resolveDeviceId(deviceId);
      deviceManager.checkRateLimit(resolved);
    
      const from = await normalizeCoordinates(x1, y1, resolved);
      const to = await normalizeCoordinates(x2, y2, resolved);
    
      validateCoordinate(from.x, 'x1');
      validateCoordinate(from.y, 'y1');
      validateCoordinate(to.x, 'x2');
      validateCoordinate(to.y, 'y2');
    
      await adbShell([
        'input', 'swipe',
        String(from.x), String(from.y),
        String(to.x), String(to.y),
        String(Math.round(durationMs)),
      ], resolved);
    
      deviceManager.touchSession(resolved);
      log.info('Swipe performed', { from, to, durationMs, deviceId: resolved });
      return { from, to };
    }
  • The registration of the 'swipe' tool in the MCP server, including the handler wrapper and input schema.
    server.registerTool(
      'swipe',
      {
        description: 'Swipe from one point to another on the Android screen. Useful for scrolling, swiping between pages, or drag gestures.',
        inputSchema: {
          x1: z.number().describe('Start X coordinate'),
          y1: z.number().describe('Start Y coordinate'),
          x2: z.number().describe('End X coordinate'),
          y2: z.number().describe('End Y coordinate'),
          duration: z.number().optional().default(300).describe('Swipe duration in milliseconds (default: 300)'),
          device_id: z.string().optional().describe('Device serial number'),
        },
      },
      async ({ x1, y1, x2, y2, duration, device_id }) => {
        return await metrics.measure('swipe', device_id || 'default', async () => {
          const resolved = await deviceManager.resolveDeviceId(device_id);
          const execCtx = executionEngine.preExecutionCheck('swipe', { x1, y1, x2, y2, 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 swipe(x1, y1, x2, y2, duration, device_id);
          invalidateCaches(resolved);
          const verification = await verifyAction('swipe', resolved, preHash);
    
          return buildVerifiedResponse({ swipe: result }, execCtx, verification);
        });
      }
    );
Behavior3/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. It clearly describes the core action (coordinate-to-coordinate swipe) and gesture types, but omits behavioral details like error handling (what happens if coordinates are out of bounds), blocking vs. async execution, or whether the action wakes a sleeping device.

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 consists of two efficient sentences with zero waste. It is front-loaded with the core action ('Swipe from one point to another') followed immediately by use case guidance, making it easy to scan and understand.

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?

Given the tool's moderate complexity (6 parameters, simple action) and complete parameter documentation in the schema, the description is sufficiently complete. It could be improved by mentioning success/failure behavior or coordinate system details (absolute vs. relative), but these are minor gaps for a gesture automation tool.

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?

With 100% schema description coverage, the schema already clearly documents all parameters (start/end coordinates, duration, device_id). The description aligns with this by mentioning 'from one point to another,' but does not add significant semantic meaning, syntax examples, or constraints beyond what the schema provides. Baseline 3 is appropriate for high schema coverage.

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 provides a specific verb ('Swipe') and resource ('Android screen'), clearly defining the tool's function. It effectively distinguishes from sibling tools like 'tap', 'click_element', and 'long_press' by specifying this is for continuous gestures between two points.

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 lists appropriate use cases ('scrolling, swiping between pages, or drag gestures'), giving positive guidance on when to use the tool. However, it lacks explicit negative guidance ('when not to use') or named alternatives (e.g., 'use tap for single clicks instead').

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