Skip to main content
Glama

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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_serialNo

Implementation Reference

  • 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 }
  • 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
  • @mcp.tool() decorator on screenshot function registers it as an MCP tool with FastMCP server instance.
    @mcp.tool()

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/rahulkr/r_adb_mcp_server'

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