Skip to main content
Glama

android_screenshot

Capture screenshots from Android devices for debugging or documentation. Save locally or get base64 output, with optional device targeting.

Instructions

Capture a screenshot from the Android device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
outputPathNoLocal path to save the screenshot (optional). If not provided, returns base64 encoded image.
deviceSerialNoSpecific device serial number to target (optional)

Implementation Reference

  • The screenshotHandler function that executes the core logic of the android_screenshot tool. It invokes ADBWrapper.screenshot and formats the response as MCP content (text for file path or image with base64 data).
    export async function screenshotHandler(
      adb: ADBWrapper,
      args: any
    ): Promise<{ content: Array<{ type: string; text?: string; data?: string; mimeType?: string }> }> {
      const { outputPath, deviceSerial } = args as ScreenshotArgs;
    
      try {
        const result = await adb.screenshot(outputPath, deviceSerial);
    
        if (typeof result === 'string') {
          // Path returned
          return {
            content: [
              {
                type: 'text',
                text: `Screenshot saved to: ${result}`,
              },
            ],
          };
        } else {
          // Buffer returned - encode as base64
          const base64 = result.toString('base64');
          return {
            content: [
              {
                type: 'text',
                text: 'Screenshot captured successfully',
              },
              {
                type: 'image',
                data: base64,
                mimeType: 'image/png',
              },
            ],
          };
        }
      } catch (error) {
        throw new Error(`Screenshot failed: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Input schema and description for the android_screenshot tool, provided in the ListToolsRequestHandler response.
    {
      name: 'android_screenshot',
      description: 'Capture a screenshot from the Android device',
      inputSchema: {
        type: 'object',
        properties: {
          outputPath: {
            type: 'string',
            description: 'Local path to save the screenshot (optional). If not provided, returns base64 encoded image.',
          },
          deviceSerial: {
            type: 'string',
            description: 'Specific device serial number to target (optional)',
          },
        },
      },
  • src/index.ts:464-465 (registration)
    Registration of the screenshotHandler in the switch statement within CallToolRequestSchema handler.
    case 'android_screenshot':
      return await screenshotHandler(this.adb, args);
  • Core implementation in ADBWrapper.screenshot method: captures screenshot using 'adb shell screencap', pulls via 'adb pull', cleans up, and returns file path or buffer.
    async screenshot(outputPath?: string, deviceSerial?: string): Promise<string | Buffer> {
      const device = await this.getTargetDevice(deviceSerial);
      const devicePath = '/sdcard/screenshot.png';
    
      // Take screenshot on device
      await this.exec(['shell', 'screencap', '-p', devicePath], device);
    
      if (outputPath) {
        // Pull screenshot to local path
        await this.exec(['pull', devicePath, outputPath], device);
        // Clean up device screenshot
        await this.exec(['shell', 'rm', devicePath], device);
        return outputPath;
      } else {
        // Pull screenshot to temp and read as buffer
        const tempPath = join(tmpdir(), `screenshot_${Date.now()}.png`);
        await this.exec(['pull', devicePath, tempPath], device);
        await this.exec(['shell', 'rm', devicePath], device);
    
        const buffer = await readFile(tempPath);
        // Clean up temp file
        await rm(tempPath, { force: true });
        return buffer;
      }
    }
  • TypeScript interface defining the expected input arguments for the screenshotHandler, matching the tool schema.
    interface ScreenshotArgs {
      outputPath?: string;
      deviceSerial?: string;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'capture a screenshot' but doesn't mention any behavioral traits such as permissions needed, whether it requires an unlocked device, potential delays, or what happens if the device is off. This leaves significant gaps for a tool that interacts with hardware.

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, direct sentence that efficiently conveys the core action without any wasted words. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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 the complexity of interacting with an Android device and the lack of annotations and output schema, the description is insufficient. It doesn't explain what the tool returns (e.g., base64 image or file path), error conditions, or dependencies, making it incomplete for safe and effective use by an 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?

The input schema has 100% description coverage, clearly documenting both optional parameters. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline score of 3 for high schema coverage without extra value.

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 verb ('capture') and resource ('screenshot from the Android device'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'android_capture_frame_scrcpy' or 'android_get_latest_frame', which appear to be related screenshot/capture tools, so it doesn't reach the highest score.

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?

The description provides no guidance on when to use this tool versus alternatives. With multiple sibling tools that might involve capturing or getting frames (e.g., android_capture_frame_scrcpy, android_get_latest_frame), there's no indication of when this specific screenshot tool is preferred or what distinguishes it, leaving the agent without usage context.

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

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