Skip to main content
Glama

swipe

Perform swipe gestures on Android device screens for navigation and interaction automation by specifying start and end coordinates.

Instructions

Perform a swipe gesture on the screen

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_xYesStart X coordinate
start_yYesStart Y coordinate
end_xYesEnd X coordinate
end_yYesEnd Y coordinate
duration_msNoSwipe duration in ms (default 300)
device_idNoDevice ID (optional if only one device)

Implementation Reference

  • The actual implementation of the swipe logic using adb shell commands.
    async swipe(
      x1: number,
      y1: number,
      x2: number,
      y2: number,
      durationMs?: number,
      deviceId?: string,
    ): Promise<void> {
      const args = ["shell", "input", "swipe", String(x1), String(y1), String(x2), String(y2)];
      if (durationMs !== undefined) args.push(String(durationMs));
      await this.exec(args, deviceId);
    }
  • src/index.ts:336-358 (registration)
    The MCP tool registration and handler definition for the "swipe" tool.
    server.tool(
      "swipe",
      "Perform a swipe gesture on the screen",
      {
        start_x: z.number().describe("Start X coordinate"),
        start_y: z.number().describe("Start Y coordinate"),
        end_x: z.number().describe("End X coordinate"),
        end_y: z.number().describe("End Y coordinate"),
        duration_ms: z.number().optional().default(300).describe("Swipe duration in ms (default 300)"),
        device_id: z.string().optional().describe("Device ID (optional if only one device)"),
      },
      async ({ start_x, start_y, end_x, end_y, duration_ms, device_id }) => {
        await adb.swipe(start_x, start_y, end_x, end_y, duration_ms, device_id);
        return {
          content: [
            {
              type: "text",
              text: `Swiped from (${start_x},${start_y}) to (${end_x},${end_y}) over ${duration_ms}ms`,
            },
          ],
        };
      },
    );

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/martingeidobler/android-mcp-server'

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