Skip to main content
Glama

get_ui_tree

Extracts the current Android screen’s semantic UI control tree, returning indexed elements with text, IDs, coordinates, and interaction flags so agents can target taps precisely without screenshots.

Instructions

【核心感知工具 - 替代慢速截图】通过高速 RPC 提取当前屏幕的语义化 UI 控件树。 返回每个元素的 [#index] 编号、类名、文本 (text)、描述 (desc)、id、中心坐标与可交互标志 (flags)。 后续可直接调用 tap_element(index=N) 或 tap_element(text="...") 精准操作!

Input Schema

NameRequiredDescriptionDefault
keywordNo可选过滤关键词(匹配 text、desc、resource-id 或类名),留空返回全部
max_elementsNo最多返回的元素数量,默认 100
only_interactiveNo是否只返回有文本或可交互(可点击/可输入/可滚动)的控件。默认 True 过滤无意义布局容器

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.0.0

TDQS

A4.2/5.0
Behavior4/5

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

No annotations are supplied, so the description carries the full burden and does disclose that extraction happens over a fast RPC path and that returned elements carry [#index] handles for later targeting. It does not cover failure modes (missing accessibility service, empty trees) or read-only guarantees, but the behavioral picture is substantially richer than the name alone.

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?

Three short lines, front-loaded with the core purpose, then the return shape, then the next-step affordance. Almost no wasted tokens despite the marketing framing.

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

Completeness4/5

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

An output schema exists, and the description still summarizes the payload (index, class, text, desc, id, coordinates, flags), which is more than required. The remaining gap is disambiguation from the crowded set of sibling perception tools, which the definition never addresses.

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

Parameters3/5

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

Schema description coverage is 100% and all three parameters (keyword, max_elements, only_interactive) are self-documented in the schema. The description mentions none of them, so it adds no meaning beyond the structured fields and the baseline 3 applies.

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 (extract the semantic UI control tree of the current screen) and explicitly positions itself against a named alternative mechanism ('replaces slow screenshots'), so an agent can tell what it gets and why it beats screenshot_annotated.

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

Usage Guidelines4/5

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

Clear usage context: use this for perception, then call tap_element(index=N) or tap_element(text=...) for the follow-up action. It stops short of distinguishing itself from the many overlapping perception siblings (ui_snapshot, inspect_view_hierarchy, find_elements, ui_describe, ui_query), so the agent must still guess among those.

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