Skip to main content
Glama

get_device_dimensions

Retrieve screen dimensions of Android devices or emulators to enable precise UI automation and element interaction.

Instructions

Get the dimensions of the Android device/emulator screen.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_idNo

Implementation Reference

  • The @mcp.tool()-decorated handler function that implements the get_device_dimensions tool. It retrieves Android device screen dimensions using ADB command 'wm size', parses the physical size, and returns a dictionary with success status, dimensions, and device ID.
    @mcp.tool()
    async def get_device_dimensions(device_id: str = None) -> dict:
        """Get the dimensions of the Android device/emulator screen."""
        try:
            # Get device dimensions using adb
            cmd = ['adb']
            if device_id:
                cmd.extend(['-s', device_id])
            cmd.extend(['shell', 'wm', 'size'])
    
            result = subprocess.run(cmd, capture_output=True, text=True, check=True)
            output = result.stdout.strip()
    
            width, height = None, None
            if 'Physical size:' in output:
                size_part = output.split('Physical size:')[1].strip()
                width, height = map(int, size_part.split('x'))
    
            return {
                "success": True,
                "device_id": device_id or "default",
                "width": width,
                "height": height,
                "dimensions": f"{width}x{height}" if width and height else None
            }
    
        except subprocess.CalledProcessError as e:
            return {
                "success": False,
                "error": f"Failed to get device dimensions: {e}",
                "device_id": device_id or "default"
            }
        except Exception as e:
            return {
                "success": False,
                "error": f"Unexpected error: {e}",
                "device_id": device_id or "default"
            }
  • puppeteer.py:610-610 (registration)
    The @mcp.tool() decorator registers the get_device_dimensions function as an MCP tool.
    @mcp.tool()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions retrieving dimensions but lacks critical details: whether this requires a connected device, what format the dimensions are returned in (e.g., pixels, resolution), if it's read-only or has side effects, or any error conditions. This leaves significant gaps for an agent to understand the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, direct sentence that efficiently conveys the core purpose without unnecessary words. It is front-loaded with the key action and resource, making it easy to parse. Every part of the sentence earns its place by specifying the target (Android device/emulator screen).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (retrieving device dimensions), lack of annotations, no output schema, and low parameter coverage, the description is incomplete. It doesn't address how results are returned, what happens without a device_id, or behavioral nuances, making it insufficient for an agent to use the tool effectively without additional context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0% description coverage for its single parameter 'device_id', and the tool description provides no information about parameters. It doesn't explain what 'device_id' represents, how to obtain it, or if it's optional (default is null). With low schema coverage, the description fails to compensate, leaving the parameter's meaning unclear.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and target resource ('dimensions of the Android device/emulator screen'), making the purpose immediately understandable. It doesn't explicitly differentiate from siblings like 'take_screenshot' or 'get_ui_elements_info', but the focus on screen dimensions is specific enough to avoid confusion with those tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. For example, it doesn't clarify if this should be used instead of 'get_ui_elements_info' for dimension-related queries or specify prerequisites like needing an active device/emulator. The description only states what it does, not when or why to invoke it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/pedro-rivas/android-puppeteer-mcp'

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