Skip to main content
Glama
Mobile Device Farm MCP

Mobile Device Farm MCP

adb_get_ui_hierarchy

Retrieves the current Android UI hierarchy as XML to inspect on-screen elements and find their coordinates.

Instructions

Get the current UI hierarchy (XML) to inspect elements and find coordinates.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "adb_get_ui_hierarchy"
  }
}

Input Schema

NameRequiredDescriptionDefault
deviceIdNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

B3/5.0
Behavior2/5

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

No annotations are provided, so the description carries the full disclosure burden, yet it only mentions that output is XML. It does not say whether the device must be unlocked or the app foregrounded, whether the tree can be large/slow, whether system UI is included, or which device is targeted when deviceId is omitted.

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?

One well-formed, front-loaded sentence with no filler. It is appropriately sized, though its brevity is partly what leaves usage and parameter gaps unaddressed.

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?

For a one-parameter read tool with no output schema, naming the XML return format covers the essentials. It still leaves device selection semantics and access preconditions unexplained, which an agent needs before calling it in a multi-device session.

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 single optional parameter deviceId gets zero explanation in either the schema (0% coverage) or the description. An agent cannot tell whether omitting it defaults to the only connected device, errors when multiple devices exist, or accepts a name versus a serial.

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?

States a specific verb ('Get') plus resource ('current UI hierarchy') and discloses the return format (XML) and the reason to call it ('inspect elements and find coordinates'). It is clearly distinguishable from action siblings like adb_tap or adb_screenshot, though it never names a sibling explicitly.

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

Usage Guidelines3/5

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

The phrase 'to inspect elements and find coordinates' implies the workflow (find a coordinate, then use adb_tap/adb_swipe), but that linkage is never spelled out. There are no exclusions or stated preconditions for when this is the wrong tool.

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