Skip to main content
Glama

record_screen

Record Android device screen activity to specified output file for set duration to capture visual workflows and interactions.

Instructions

Record the screen of the connected Android device for a specified duration

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
output_pathYes
durationYes

Implementation Reference

  • The handler function for the 'record_screen' tool, decorated with @mcp.tool() for registration. It records the Android device screen using 'adb shell screenrecord' for the specified duration and pulls the MP4 file to the local output_path.
    @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}'."

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vs4vijay/espresso-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server