Skip to main content
Glama

adb_screenshot

Capture device screenshots using Android Debug Bridge for remote device management and screen operations.

Instructions

Take a screenshot of the device screen

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceIdNoDevice ID (optional)
formatNoScreenshot format (default: png)

Implementation Reference

  • Core handler function for adb_screenshot tool. Captures screenshot via ADB screencap, pulls file to local directory, cleans up on device, and returns file paths and info.
    async takeScreenshot(options: ScreenshotOptions = {}) {
      try {
        const deviceId = options.deviceId;
        const format = options.format || 'png';
        
        // Check if device is connected
        const connected = await this.adbClient.isDeviceConnected(deviceId);
        if (!connected) {
          return {
            success: false,
            error: 'Device not connected',
            message: 'Cannot take screenshot - device is not connected'
          };
        }
    
        // Take screenshot on device
        const screenshotPath = `/sdcard/screenshot.${format}`;
        const result = await this.adbClient.executeCommand(`shell screencap -p ${screenshotPath}`, deviceId);
        
        if (!result.success) {
          return {
            success: false,
            error: result.error,
            message: 'Failed to capture screenshot on device'
          };
        }
    
        // Use fixed filename for easy access
        const filename = `current_screenshot.${format}`;
        const adbPath = this.configManager.getAdbPath(filename);
        const mcpPath = this.configManager.getMcpPath(filename);
        
        const pullResult = await this.adbClient.executeCommand(`pull ${screenshotPath} ${adbPath}`, deviceId);
        
        if (!pullResult.success) {
          return {
            success: false,
            error: pullResult.error,
            message: 'Failed to pull screenshot from device'
          };
        }
    
        // Clean up device screenshot
        await this.adbClient.executeCommand(`shell rm ${screenshotPath}`, deviceId);
    
        // Try to read the file to verify it was downloaded and get file info
        let fileSize = 'Unknown';
        let fileExists = false;
        try {
          const stats = await fs.stat(mcpPath);
          fileSize = `${Math.round(stats.size / 1024)} KB`;
          fileExists = true;
        } catch (error) {
          console.warn('Could not read screenshot file stats:', error);
        }
    
        return {
          success: true,
          data: { 
            adbPath,
            mcpPath,
            filename,
            format,
            fileSize,
            fileExists,
            deviceId: deviceId || this.adbClient.getDefaultDevice(),
            pullInfo: pullResult.output
          },
          message: `Screenshot saved to ${adbPath} (readable at ${mcpPath})`
        };
      } catch (error: any) {
        return {
          success: false,
          error: error.message,
          message: 'Failed to take screenshot'
        };
      }
    }
  • Input schema definition for the adb_screenshot tool registered in the MCP server tool list.
    {
      name: 'adb_screenshot',
      description: 'Take a screenshot of the device screen',
      inputSchema: {
        type: 'object',
        properties: {
          deviceId: {
            type: 'string',
            description: 'Device ID (optional)',
          },
          format: {
            type: 'string',
            enum: ['png', 'jpg'],
            description: 'Screenshot format (default: png)',
          },
        },
        required: [],
      },
  • src/index.ts:441-442 (registration)
    Registration and dispatch point in the tool call handler switch statement, routing adb_screenshot calls to ScreenTools.takeScreenshot.
    case 'adb_screenshot':
      return await this.handleToolCall(this.screenTools.takeScreenshot(args || {}));
  • TypeScript interface defining the input options for screenshot operations, used by the handler.
    export interface ScreenshotOptions {
      deviceId?: string;
      format?: 'png' | 'jpg';
      quality?: number;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action. It doesn't disclose behavioral traits like whether this requires ADB setup, affects device state, has rate limits, returns file data or path, or potential errors. This is inadequate for a tool with potential side effects.

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, efficient sentence with zero waste. It's front-loaded with the core action and appropriately sized for a straightforward tool, earning its place without unnecessary elaboration.

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 no annotations, no output schema, and a tool that interacts with external devices, the description is incomplete. It doesn't explain return values (e.g., image data format), error conditions, or dependencies like ADB connectivity, leaving significant gaps for agent understanding.

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?

Schema description coverage is 100%, so the schema fully documents both parameters (deviceId and format). The description adds no parameter semantics beyond implying a screenshot is taken, which the schema already covers through property names and descriptions. Baseline 3 is appropriate when schema does the heavy lifting.

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 ('take') and resource ('screenshot of the device screen'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like adb_get_device_info or adb_get_system_info that also retrieve device information but through different mechanisms.

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. It doesn't mention prerequisites (e.g., device connection), exclusions, or how it compares to other screenshot methods in the sibling set, leaving the agent to infer 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/richard0913/adb-mcp'

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