screenshot
Capture device screen images for UI testing, visual QA, and debugging workflows. Returns base64 PNG data for direct viewing.
Instructions
Take a screenshot of the device screen. Returns base64 encoded PNG image that can be viewed directly.
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"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device_serial | No |
Implementation Reference
- src/adb_mcp_server/server.py:151-169 (handler)The main 'screenshot' MCP tool handler function. Decorated with @mcp.tool() for automatic registration and schema inference from signature/docstring. Captures device screenshot using ADB 'screencap', base64 encodes PNG, returns image metadata and data.
@mcp.tool() def screenshot(device_serial: str | None = None) -> dict: """ Take a screenshot of the device screen. Returns base64 encoded PNG image that can be viewed directly. """ 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"} img_base64 = base64.b64encode(img_data).decode('utf-8') return { "type": "image", "format": "png", "size_bytes": len(img_data), "data": img_base64 } - src/adb_mcp_server/server.py:42-51 (helper)Helper utility 'run_adb_binary' called by screenshot tool to execute ADB screencap command and capture binary PNG image data.
def run_adb_binary(args: list[str], device_serial: str | None = None) -> bytes: """Run an ADB command and return binary output""" cmd = ["adb"] if device_serial: cmd.extend(["-s", device_serial]) cmd.extend(args) result = subprocess.run(cmd, capture_output=True) return result.stdout - src/adb_mcp_server/server.py:151-151 (registration)@mcp.tool() decorator on screenshot function registers it as an MCP tool with FastMCP server instance.
@mcp.tool()