Skip to main content
Glama

adb_screenshot

Capture screenshots from connected Android devices using device ID and preferred format (PNG or JPG) for debugging or remote device management.

Instructions

Take a screenshot of the device screen

Input Schema

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

Implementation Reference

  • The main handler function that takes a screenshot using ADB 'screencap', pulls it to local, cleans up, and returns paths.
    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' }; } }
  • JSON input schema defining parameters for the adb_screenshot tool.
    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:89-107 (registration)
    Tool registration in the ListToolsRequestHandler, including name, description, and schema.
    { 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)
    Dispatch registration in the CallToolRequestHandler switch statement calling the handler.
    case 'adb_screenshot': return await this.handleToolCall(this.screenTools.takeScreenshot(args || {}));
  • TypeScript interface defining input options for the screenshot tool.
    export interface ScreenshotOptions { deviceId?: string; format?: 'png' | 'jpg'; quality?: 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