Skip to main content
Glama

Get the UI hierarchy

get_ui_hierarchy
Read-onlyIdempotent

Dump the current view hierarchy as uiautomator XML with bounds, IDs, text, and clickability to find stable selectors before shell tap/text actions. Use to_file for large dumps.

Instructions

Dump the current view hierarchy of one device as uiautomator XML (uiautomator dump), including bounds, resource ids, text and clickability. Use it to find stable selectors before driving the UI through shell (input tap/text). With to_file: true the XML is kept on the device at /data/local/tmp/adbmcp-ui-.xml and returned as {path, bytes} instead of inline text, so large dumps stay structurally valid; retrieve it with pull_file. Dumps accumulate at that prefix by design — remove them with the shell tool (rm ) after pulling.

Input Schema

NameRequiredDescriptionDefault
deviceNoDevice serial from list_devices; optional when exactly one device is connected.
to_fileNoWrite the dump to /data/local/tmp/adbmcp-ui-<timestamp>.xml and return {path, bytes} instead of inline XML (default false).
timeout_msNoTimeout in milliseconds for the dump (default 30000).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.6.0

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, idempotentHint and destructiveHint=false, so safety is covered. The description adds substantive side-effect context beyond that: to_file:true persists XML on the device, dumps accumulate by design, and cleanup requires a manual rm — not inferable from the schema or annotations.

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

Conciseness4/5

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

The scoping and usage guidance is front-loaded, and each sentence carries distinct information (purpose, when-to-use, to_file behavior, cleanup). It is dense across three sentences but no sentence is filler.

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

Completeness5/5

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

With no output schema, the description compensates by describing both return shapes (inline XML vs {path, bytes}) and the on-device artifact lifecycle. Everything an agent needs to call it correctly and handle the result is present.

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?

Schema coverage is 100%, so the baseline is 3. The description still adds value by explaining the to_file branch in depth (on-device path pattern, returned shape {path, bytes} instead of inline text), going beyond the terse schema wording for that parameter.

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

Purpose5/5

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

States a specific verb and resource ('Dump the current view hierarchy of one device as uiautomator XML') and enumerates the payload it captures (bounds, resource ids, text, clickability). An agent can distinguish this inspection tool from tap/type_text/shell siblings without opening the schema.

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

Usage Guidelines5/5

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

Explicitly prescribes the use case ('find stable selectors before driving the UI through shell (input tap/text)') and names the alternatives. It also lays out the downstream workflow with pull_file for retrieval and the shell rm for cleanup, so when-to-use and follow-on actions are fully covered.

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