Skip to main content
Glama

dump_ui_hierarchy

Extract the UI hierarchy from a connected Android device to analyze screen structure and elements for testing or debugging purposes.

Instructions

Dump the UI hierarchy of the connected Android device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function decorated with @mcp.tool() that implements the dump_ui_hierarchy tool. It uses ADB to dump the UI hierarchy XML from the Android device, pulls the file locally, reads it, and returns the contents as a string.
    @mcp.tool()
    def dump_ui_hierarchy() -> str:
        """Dump the UI hierarchy of the connected Android device"""
        result = subprocess.run(["adb", "shell", "uiautomator", "dump"], capture_output=True, text=True)
        if result.returncode != 0:
            raise RuntimeError(f"Error dumping UI hierarchy: {result.stderr}")
    
        # The UI hierarchy is dumped to a file on the device /sdcard/window_dump.xml
        # Pull the file to the local machine and read its contents
        pull_result = subprocess.run(
            ["adb", "pull", "/sdcard/window_dump.xml", "window_dump.xml"],
            capture_output=True,
            text=True,
        )
        if pull_result.returncode != 0:
            raise RuntimeError(f"Error pulling UI hierarchy file: {pull_result.stderr}")
    
        with open("window_dump.xml", encoding="utf-8") as f:
            ui_hierarchy = f.read()
        return ui_hierarchy
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 states the action but lacks details on what 'dump' entails (e.g., output format, whether it's read-only or has side effects, performance impact, or error conditions). This is a significant gap for a tool with zero annotation coverage.

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, efficient sentence that directly states the tool's purpose without any wasted words. It is appropriately sized and front-loaded, making it easy to understand at a glance.

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

Completeness3/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 (involving Android device interaction) and lack of annotations or output schema, the description is minimally adequate. It covers the basic purpose but lacks behavioral details and output information, leaving gaps that could hinder effective use by an AI agent.

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

Parameters4/5

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

The input schema has 0 parameters with 100% coverage, so the schema fully documents the lack of inputs. The description does not add parameter information, which is unnecessary here. Baseline is 4 for 0 parameters, as the description need not compensate for any gaps.

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 ('dump') and the resource ('UI hierarchy of the connected Android device'), making the purpose specific and understandable. However, it does not explicitly differentiate from sibling tools like 'dump_current_activity' or 'take_screenshot', which might involve similar Android device interactions, so it misses full sibling differentiation.

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?

The description provides no guidance on when to use this tool versus alternatives. It does not mention prerequisites (e.g., needing a connected device), exclusions, or comparisons to siblings like 'dump_current_activity' or 'take_screenshot', leaving usage context implied at best.

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/vs4vijay/espresso-mcp'

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