Skip to main content
Glama

inspect_view_hierarchy

Inspect an Android Activity's view tree for custom View classes, resource IDs, and hidden nodes, with filters to narrow output. Requires ROMs whose dumpsys activity top returns view data.

Instructions

【仅用于已知能吐出 View 树的 ROM】通过 dumpsys activity top 取 Activity/Task 记录。 注意:本机 HyperOS(Android 16)实测该命令不返回任何 View 层级——mID=、mText、 android:text 均为 0 行,微信整份输出只有 776 字节。所以在该机型上它拿不到控件信息, 需要理解界面请直接用 ui_describe(OS 语义,非 OCR)。 在确实支持 AOSP 式 dumpsys activity top 的 ROM 上,本工具可能额外给出:

  1. 真实的自定义 View 类名;2. 16 进制资源 ID 锚点;3. 被隐藏的 GONE/INVISIBLE 节点。

Input Schema

NameRequiredDescriptionDefault
keywordNo可选过滤关键词(如自定义 View 类名、0x7f 资源号、id 名称),留空返回顶层起全部视图
max_linesNo最大返回视图行数,默认 180
visibility_filterNo可见性过滤:'ALL'(全部,含 GONE/INVISIBLE 隐藏广告锚点)、'VISIBLE'(仅可见)、'GONE'(仅隐藏)ALL

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.0.0

TDQS

A4.3/5.0
Behavior4/5

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

With no annotations provided, the description carries the full burden and does substantial work: it discloses the underlying shell command, a concrete known-failure case (zero `mID=`/`mText` lines, 776-byte output for WeChat), and what data is only conditionally available. It does not state whether root/shell privileges are required to run `dumpsys activity top`, which is the main remaining behavioral gap.

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?

Front-loads the applicability restriction and the negative result first, then the upside, which is the right order for an agent deciding whether to call it. The WeChat/776-byte anecdote is slightly more forensic detail than needed, but it substantiates the warning rather than padding.

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, so return values need not be explained, and the description covers mechanism, applicability, failure mode, and fallback. Missing only operational prerequisites (privilege level, expected latency) for a shell-backed inspection tool.

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%, so the schema already documents all three parameters including the enum-like values for `visibility_filter` and the default for `max_lines`. The description's mention of resource IDs and hidden nodes loosely maps to `keyword` and `visibility_filter` but adds no syntax or format detail beyond the schema, so 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 mechanism (`dumpsys activity top`) and resource (Activity/Task records / View hierarchy), and enumerates the three extra data classes it can surface: custom View class names, hex resource IDs, and GONE/INVISIBLE nodes. It is clearly distinguishable from the UI-inspection siblings because it names `ui_describe` as the different path.

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 scopes use to ROMs that emit AOSP-style View trees, explicitly excludes the current device (HyperOS / Android 16) with measured evidence, and redirects the agent to `ui_describe` for interface understanding. Both the when and the when-not, plus the alternative, are spelled out.

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