record_screen
Capture Android device screen activity by specifying output path and recording duration using the screen recording tool on espresso-mcp server.
Instructions
Record the screen of the connected Android device for a specified duration
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| duration | Yes | ||
| output_path | Yes |
Implementation Reference
- src/espresso_mcp/server.py:203-224 (handler)The handler function for the 'record_screen' tool. It uses ADB to record the screen of a connected Android device/emulator for the specified duration, saves it temporarily on the device, pulls it to the local output_path, and returns a success message. The @mcp.tool() decorator also handles registration with the FastMCP server.@mcp.tool() def record_screen(output_path: str, duration: int) -> str: """Record the screen of the connected Android device for a specified duration""" timestamp = datetime.now().strftime("%Y%m%d%H%M%S") file = f"/sdcard/espresso-mcp_recording_{timestamp}.mp4" result = subprocess.run( ["adb", "shell", "screenrecord", file], capture_output=True, text=True, timeout=duration, ) if result.returncode != 0: raise RuntimeError(f"Error recording screen: {result.stderr}") pull_result = subprocess.run( ["adb", "pull", file, output_path], capture_output=True, text=True, ) if pull_result.returncode != 0: raise RuntimeError(f"Error pulling recorded file: {pull_result.stderr}") return f"Screen recording saved to '{output_path}'."