Skip to main content
Glama

get_ui_hierarchy

Dump the complete UI hierarchy as XML to show all visible elements, their properties, bounds, and content descriptions for Android device inspection.

Instructions

Dump the complete UI hierarchy as XML. Shows all visible elements, their properties, bounds, and content descriptions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_serialNo

Implementation Reference

  • The handler function for the 'get_ui_hierarchy' tool, decorated with @mcp.tool() for automatic registration in the FastMCP server. It dumps the UI hierarchy using ADB uiautomator, reads the XML file, cleans up, and returns the XML string.
    @mcp.tool() def get_ui_hierarchy(device_serial: str | None = None) -> str: """ Dump the complete UI hierarchy as XML. Shows all visible elements, their properties, bounds, and content descriptions. """ run_adb(["shell", "uiautomator", "dump", "/sdcard/ui_dump.xml"], device_serial) output = run_adb(["shell", "cat", "/sdcard/ui_dump.xml"], device_serial) run_adb(["shell", "rm", "/sdcard/ui_dump.xml"], device_serial) return output

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/rahulkr/r_adb_mcp_server'

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