screenshot_to_file
Capture Android device screenshots and save them directly to local files for visual testing, debugging, or documentation purposes.
Instructions
Save screenshot to a local file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | No | screenshot.png | |
| device_serial | No |
Implementation Reference
- src/adb_mcp_server/server.py:171-185 (handler)The handler function decorated with @mcp.tool(), implementing the screenshot_to_file tool. Captures screenshot using ADB screencap command and writes the binary PNG data to the specified local file.@mcp.tool() def screenshot_to_file( filename: str = "screenshot.png", device_serial: str | None = None ) -> str: """Save screenshot to a local file""" img_data = run_adb_binary(["exec-out", "screencap", "-p"], device_serial) if not img_data or len(img_data) < 100: return "Error: Failed to capture screenshot" with open(filename, 'wb') as f: f.write(img_data) return f"Screenshot saved to {filename} ({len(img_data)} bytes)"