Skip to main content
Glama

get_ui_hierarchy

Retrieve Android screen XML hierarchy to locate elements, read text, or find resource IDs for UI interaction.

Instructions

Returns the current Android screen as an XML UI hierarchy.

Use this when you need to locate element coordinates, read text, or find resource IDs to interact with. Do not call this after every action — only call it when you actually need to read screen content. To check if the screen changed after an action, use snapshot_ui before the action and detect_ui_change after.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_serialNoAndroid device serial (e.g. 'emulator-5554' or '192.168.1.10:5555'). Omit only when a single device is connected. If the tool returns a multi-device error: STOP. Present the device list to the user verbatim and wait for their explicit choice. Do NOT retry with a guessed or inferred serial — this is a hard requirement. Once the user provides a serial, use it for every subsequent call in this session. To switch devices mid-session, ask the user first.

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/Neverlow512/agent-droid-bridge'

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