Skip to main content
Glama

adb_swipe

Perform screen swipes on Android devices by specifying start and end coordinates, enabling automated touch gestures for testing and control.

Instructions

Swipe from one point to another on the device screen

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
x1YesStart X coordinate
y1YesStart Y coordinate
x2YesEnd X coordinate
y2YesEnd Y coordinate
durationNoSwipe duration in milliseconds (default: 300)
deviceIdNoDevice ID (optional)

Implementation Reference

  • The core handler function for the adb_swipe tool. It validates inputs, checks device connection, and executes the ADB shell 'input swipe' command.
    async swipe(options: SwipeOptions) {
      try {
        const { x1, y1, x2, y2, deviceId, duration = 300 } = options;
        
        if (x1 < 0 || y1 < 0 || x2 < 0 || y2 < 0) {
          return {
            success: false,
            error: 'Invalid coordinates',
            message: 'All coordinates must be positive numbers'
          };
        }
    
        const connected = await this.adbClient.isDeviceConnected(deviceId);
        if (!connected) {
          return {
            success: false,
            error: 'Device not connected',
            message: 'Cannot perform swipe - device is not connected'
          };
        }
    
        const command = `shell input swipe ${x1} ${y1} ${x2} ${y2} ${duration}`;
        const result = await this.adbClient.executeCommand(command, deviceId);
        
        if (!result.success) {
          return {
            success: false,
            error: result.error,
            message: 'Failed to perform swipe'
          };
        }
    
        return {
          success: true,
          data: { 
            from: { x: x1, y: y1 },
            to: { x: x2, y: y2 },
            duration,
            deviceId: deviceId || this.adbClient.getDefaultDevice()
          },
          message: `Swiped from (${x1}, ${y1}) to (${x2}, ${y2})`
        };
      } catch (error: any) {
        return {
          success: false,
          error: error.message,
          message: 'Failed to perform swipe'
        };
      }
    }
  • Input schema definition for the adb_swipe tool, registered in the MCP server.
    name: 'adb_swipe',
    description: 'Swipe from one point to another on the device screen',
    inputSchema: {
      type: 'object',
      properties: {
        x1: {
          type: 'number',
          description: 'Start X coordinate',
        },
        y1: {
          type: 'number',
          description: 'Start Y coordinate',
        },
        x2: {
          type: 'number',
          description: 'End X coordinate',
        },
        y2: {
          type: 'number',
          description: 'End Y coordinate',
        },
        duration: {
          type: 'number',
          description: 'Swipe duration in milliseconds (default: 300)',
        },
        deviceId: {
          type: 'string',
          description: 'Device ID (optional)',
        },
      },
      required: ['x1', 'y1', 'x2', 'y2'],
    },
  • src/index.ts:445-446 (registration)
    Tool registration in the switch statement that delegates to ScreenTools.swipe method.
    case 'adb_swipe':
      return await this.handleToolCall(this.screenTools.swipe(args as any));
  • TypeScript interface defining the SwipeOptions used by the handler.
    export interface SwipeOptions {
      deviceId?: string;
      x1: number;
      y1: number;
      x2: number;
      y2: number;
      duration?: number;
    }
Behavior2/5

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

With no annotations, the description carries full burden but only states the basic action without behavioral details. It doesn't disclose side effects (e.g., screen interaction, potential errors), permissions needed, rate limits, or what happens on failure (e.g., invalid coordinates). This is inadequate for a mutation tool with zero annotation coverage.

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 front-loads the core action ('Swipe from one point to another') and target ('on the device screen'). There is zero waste or redundancy, making it highly concise and well-structured.

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?

Given no annotations, no output schema, and a mutation tool (swiping implies device interaction), the description is incomplete. It lacks details on behavior, error handling, dependencies (e.g., device must be connected), or output format. This is insufficient for safe and effective tool use by an AI agent.

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 parameters are well-documented in the schema. The description adds no additional parameter semantics beyond implying coordinate-based movement, which is already clear from schema descriptions like 'Start X coordinate'. Baseline 3 is appropriate as 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 ('Swipe') and the target ('device screen'), specifying movement from one point to another. It distinguishes from siblings like adb_click (single tap) and adb_press_key (keyboard input), but doesn't explicitly contrast with other gesture tools (none present in siblings).

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?

No guidance on when to use this tool versus alternatives is provided. It doesn't mention prerequisites (e.g., device connection), typical use cases (e.g., UI navigation), or when not to use it (e.g., versus adb_click for taps). The context is implied but not explicit.

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/richard0913/adb-mcp'

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