Skip to main content
Glama

adb_swipe

Perform screen swipes on Android devices by defining start and end coordinates. Specify swipe duration and device ID to automate touch interactions via ADB MCP Server.

Instructions

Swipe from one point to another on the device screen

Input Schema

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

Implementation Reference

  • The main handler function for the adb_swipe tool, which executes the ADB 'input swipe' command with the provided coordinates and duration.
    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' }; } }
  • The input schema definition for the adb_swipe tool as registered in the MCP listTools response.
    { 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)
    The switch case registration that dispatches calls to the adb_swipe tool to the ScreenTools.swipe handler.
    case 'adb_swipe': return await this.handleToolCall(this.screenTools.swipe(args as any));
  • TypeScript interface defining the SwipeOptions used by the handler, matching the input schema.
    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