adb_screenshot
Capture screenshots from connected Android devices over WiFi using ADB commands. Save screenshots locally for debugging, documentation, or remote monitoring purposes.
Instructions
Take a screenshot of the connected Android device
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| output_path | No | Local path to save the screenshot (default: screenshot.png) | screenshot.png |
| device_id | No | Device ID/serial (optional, uses first device if not specified) |
Implementation Reference
- src/index.ts:143-173 (handler)Handler function for the 'adb_screenshot' tool. It takes a screenshot using ADB shell screencap on the device (optionally specified by device_id), pulls it to the local output_path (default 'screenshot.png'), cleans up the temp file on device, and returns a success message.case "adb_screenshot": { const { output_path = "screenshot.png", device_id } = args as { output_path?: string; device_id?: string; }; const deviceArg = device_id ? `-s ${device_id}` : ""; const tempPath = "/sdcard/screenshot.png"; // Take screenshot on device await execAsync(`adb ${deviceArg} shell screencap -p ${tempPath}`); // Pull screenshot to local machine const { stdout, stderr } = await execAsync(`adb ${deviceArg} pull ${tempPath} ${output_path}`); // Clean up temp file on device await execAsync(`adb ${deviceArg} shell rm ${tempPath}`); if (stderr && stderr.includes("error")) { throw new McpError(ErrorCode.InternalError, `Screenshot failed: ${stderr}`); } return { content: [ { type: "text", text: `Screenshot saved to ${output_path}`, }, ], }; }
- src/index.ts:54-68 (schema)Input schema definition for the 'adb_screenshot' tool, defining optional parameters output_path and device_id.inputSchema: { type: "object", properties: { output_path: { type: "string", description: "Local path to save the screenshot (default: screenshot.png)", default: "screenshot.png", }, device_id: { type: "string", description: "Device ID/serial (optional, uses first device if not specified)", }, }, required: [], },
- src/index.ts:51-70 (registration)Registration of the 'adb_screenshot' tool in the ListToolsRequestSchema handler, including name, description, and input schema.{ name: "adb_screenshot", description: "Take a screenshot of the connected Android device", inputSchema: { type: "object", properties: { output_path: { type: "string", description: "Local path to save the screenshot (default: screenshot.png)", default: "screenshot.png", }, device_id: { type: "string", description: "Device ID/serial (optional, uses first device if not specified)", }, }, required: [], }, }, {