Skip to main content
Glama

screenshot

Capture screenshots from Android devices for visual analysis. Save images locally or use them directly in automated testing workflows.

Instructions

Take a screenshot of the Android device. Returns the image for visual analysis. Optionally saves to a file path.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_idNoDevice ID (optional if only one device)
save_pathNoLocal file path to save the screenshot PNG (optional)

Implementation Reference

  • The low-level ADB execution handler for the screenshot tool. It runs `screencap -p` and returns the buffer.
    async screenshot(deviceId?: string): Promise<Buffer> {
      return this.execBuffer(["exec-out", "screencap", "-p"], deviceId);
    }
  • src/index.ts:94-122 (registration)
    MCP tool registration and high-level handler for "screenshot", which orchestrates capturing via ADB, compressing the image, and optionally saving it to disk.
    server.tool(
      "screenshot",
      "Take a screenshot of the Android device. Returns the image for visual analysis. Optionally saves to a file path.",
      {
        device_id: z.string().optional().describe("Device ID (optional if only one device)"),
        save_path: z.string().optional().describe("Local file path to save the screenshot PNG (optional)"),
      },
      async ({ device_id, save_path }) => {
        const raw = await adb.screenshot(device_id);
        const compressed = await compressScreenshot(raw);
        const base64 = compressed.toString("base64");
        const metadata = await sharp(compressed).metadata();
    
        if (save_path) {
          await adb.saveScreenshot(compressed, save_path);
        }
    
        const info = `Screenshot: ${metadata.width}x${metadata.height} (${Math.round(compressed.length / 1024)}KB)`;
        return {
          content: [
            { type: "image", data: base64, mimeType: "image/png" },
            {
              type: "text",
              text: save_path ? `${info}\nSaved to: ${save_path}` : info,
            },
          ],
        };
      },
    );

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