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; }

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