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
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "screenshot_to_file"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | No | screenshot.png | |
| device_serial | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
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)"