layout-inspector
Provides tools to inspect and interact with UI on real Android devices, including dumping view and accessibility semantics trees, finding and tapping elements, taking screenshots, analyzing layout/accessibility issues, and diffing snapshots.
Reuses a local Android Studio installation's transport daemon, JVMTI agent, and inspector protocol to retrieve Jetpack Compose layout inspector data from debuggable Android apps.
Enables inspection of Jetpack Compose UI trees with Composable names, source file and line numbers, bounds, parameters/text, flags, and recomposition or skip counts.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Android Layout MCP
An MCP server and coding-agent plugin that lets an agent see the live Android screen — and find the code behind it.
Coding agents read repositories well but cannot look at the phone. This project gives them that view. It captures the current screen over ADB, normalizes four Android data sources into one node tree with short refs, and answers questions about it:
What is on this screen? →
dump_uiWhere is this element, and is it clickable? →
find_elements/hit_testDoes the layout have issues? →
analyze_uiwith 12 rulesWhich Compose or XML file, and which business logic, renders it? →
locate_codeplus the bundled skills
Highlights
Highlight | What it means for you |
Four sources, one tree | View hierarchy (JDWP), accessibility semantics (uiautomator), |
Zero-config | Picks per screen: View for XML, semantics for Compose, both for mixed screens. No flags to remember for everyday use. |
Works on release builds |
|
UI → source without an index |
|
Available where you work | 9 MCP tools, a coding-agent plugin (5 skills + 5 commands + gate hook), and documented configs for 20 MCP clients. |
No native dependencies | Pure JavaScript, Node ≥ 20. Screenshots are downscaled in JS; nothing to compile but the optional Compose helper. |
Related MCP server: artemis
Requirements
Node.js ≥ 20 (the MCP server runs on Node)
adbonPATH(orALM_ADB/ADB_PATH), with a device or emulator and USB debugging onA debuggable app for the
viewandcomposesources;semanticsanddumpsyswork on any appAndroid Studio + Java only for the
composesource (~8–12 s per capture)
Install and connect
Coding agent plugin (recommended)
In Claude Code:
/plugin marketplace add Jayvinz/android-layout-mcp
/plugin install android-layout@jayvinz-toolsThe plugin starts the MCP server automatically and adds the skills, commands, and gate hook. After installing, /mcp should list android-layout and /help should list the /android-layout:* commands. Restart Claude Code once so the hook loads.
Offline alternatives:
# Release bundle (self-contained, includes production node_modules)
claude --plugin-dir ./android-layout-mcp-<version>.zip
# Local checkout (build first; a local-path marketplace does not install deps for you)
npm install && npm run build
claude --plugin-dir E:/repo/android-layout-mcpAny other MCP client
The server speaks plain stdio MCP, so any client can start it. Clone the repository, build once, and point the client at dist/mcp.js:
{
"mcpServers": {
"android-layout": {
"command": "node",
"args": ["<your-clone>/dist/mcp.js"]
}
}
}Add --serial, --adb, --timeout, or the Compose flags (--studio, --java, --compose-version) to args to pin a device or toolchain. VS Code, Codex, Zed, Goose, OpenCode, Amp, and other clients use a different envelope — docs/mcp.md lists all 20 ids and the shape for each.
To get the five skills as well, copy them into the directory your agent reads:
node scripts/sync-agent-skills.mjs --dest <your-android-project>
# --codebuddy, --workbuddy, --both, --global, --check, --dry-runCursor and VS Code read .claude/skills/ directly, so they need no copy. Claude Code is the only client with slash commands and the enforced gate; elsewhere the gate is the rule written in each skill body.
Names: the repository and npm package are android-layout-mcp; the MCP server key and plugin slug are android-layout. The package is not published to the registry — install the plugin or load the release zip.
First run
/mcp # confirm the android-layout server is loaded
/android-layout:capture # capture the current screenOr just ask: "当前界面有什么?" A dump_ui(source="auto", format="tree") reply looks like this:
device <serial> (Pixel 7) android 13 (sdk 33)
screen 1080x2400 @ 440dpi (2.75x) portrait
target com.example.app.debug pid=9597 activity=...MainActivity debuggable
primary source: view (captured: view, semantics)
ui kind: xml
view window: .../android.view.ViewRootImpl@60b9a5d (100ms)
semantics rotation=0 (900ms)
v0 DecorView [0,0][1080,2400] 1080x2400 @(540,1200)
v1 FrameLayout [0,0][1080,2400] 1080x2400 @(540,1200)
v2 FrameLayout id/content [0,0][1080,2400] 1080x2400 @(540,1200)Then put the app on the page you care about and ask:
Locate the Me button on the current screen and trace it to its related code logic.
Or run /android-layout:trace-view Me. The agent confirms the foreground app, captures the tree, locks onto the node, scans for file:line candidates, and reads the code. For a whole block, say "分析这块区域的业务逻辑" (or "analyze this block's logic"): the block becomes the entry point, and the agent traces back to the business code and logic that produce it — UI → state → data, with file:line for each hop.
Upper-layer components
Skills, commands, and MCP tools are layers over one shared core.
MCP tools (9)
Tool | Answers | Key parameters |
| Which devices are connected? | — |
| Screen, foreground app, pid, ViewRootImpl windows |
|
| What is the whole tree? |
|
| Where is this text / id / class / ref? |
|
| What is at (x, y)? |
|
| Which source file renders this element? |
|
| Does the layout have issues? |
|
| What does it look like? |
|
| Activity / Fragment structure |
|
Recommended call order: get_state → dump_ui(source="auto", format="tree") → find_elements or hit_test → optional screenshot / analyze_ui. Call locate_code only when the user asks for source. Full reference: docs/mcp.md.
Skills (Claude Code and other agents)
Five skills split on two axes — granularity and intent — so each cell has exactly one owner:
Facts | Property values | Source code | Defects | |
One element |
|
|
| — |
One section | — | — |
| — |
Whole screen |
| — | — |
|
Skill | Ask it for | Typical prompt |
| Structure, Activity, | "当前界面有什么", "抓取当前页面布局" |
| One View's margins, padding, measured size, text metrics, background, RTL | "这个按钮的边距是多少" |
| One element's class, click handler, visibility rule, content injection | "这个按钮在哪实现的" |
| The business code and logic behind one UI block — the block is the entry point, the answer is UI → state → data with | "这块区域的业务逻辑", "从这块 UI 追到业务代码" |
| Defect judgments, each tied to the XML/Composable that causes it | "有没有重叠", "布局有没有问题" |
Slash commands (Claude Code)
Command | Argument |
| optional block or package |
| element text / id / ref |
| element text / id / ref |
| the UI block that starts the trace |
| alias of |
| optional block |
Commands are thin entry points: they bind $ARGUMENTS, name their skill, and carry one gate pointer. The rules live in the skills, never in both places.
Gate hook
All nine device-touching tools are Android-project gated. The plugin's PreToolUse hook denies them in a non-Android workspace unless the latest user prompt explicitly asks about the device screen or mentions Android. locate_code is stricter: it needs an Android project or an explicit Android mention. Detection uses settings.gradle(.kts), gradlew(.bat), a module applying com.android.*, or AndroidManifest.xml. A connected device does not make a repository Android. Set ALM_GATE_DEBUG=1 to log decisions.
Scripts
# Rank source candidates from UI anchors, no npm install needed
node scripts/locate-code.mjs --root . --text "登录" --id "login_btn" --compose-name "LoginScreen" --json
# Copy the five skills into another agent's skill directory
node scripts/sync-agent-skills.mjs --dest ../my-android-app --bothlocate-code.mjs only ranks candidates; always open the files to confirm. It never modifies the repository.
How it reads the screen
Source | Requires | Gives | Cost |
| Debuggable app | Real View classes, resource ids, text, padding/margins, layout params, visibility | ~100 ms |
| Nothing | Text, content descriptions, clickable bounds — accessibility roles instead of real classes | ~0.5–3 s |
| Nothing | Real View classes, resource ids, window bounds, Activity/Fragment records; text merged in from semantics | ~100–300 ms |
| Debuggable app + Android Studio + Java | Composable names, | ~8–12 s |
On a Compose screen the view source stops at AndroidComposeView — that is why auto switches to semantics, and why source=compose exists for Composable-level answers. Details and measured per-source results: docs/data-sources.md.
Things to know
Refs are per capture.
v*(view),s*(semantics),d*(dumpsys),c*(compose) are valid only for the capture that produced them. To compare before/after, match on source, resource id, class, text, and path.Artifacts are local. The capture workflow writes
.alm/capture.json,.alm/capture.png, and.alm/capture.xml. Add.alm/to.gitignore; dumps can contain device serials, package names, and screen text. Android Studio's Layout Inspector cannot open these files (.liis private).Image coordinates ≠ device coordinates. A downscaled screenshot reports
coordinateMapping.imageToDevice; multiply before hit-testing or quoting a position. Values fromfind_elements/hit_testare already device coordinates.Screenshots are a fallback, not the source of truth. When structured capture fails, a downscaled
alm-fallback-<time>.pngis saved and returned as image content. Disable withALM_NO_FALLBACK_SCREENSHOT=1.Common environment variables:
ALM_ADB/ADB_PATH,ANDROID_SERIAL,ALM_ANDROID_STUDIO,ALM_JAVA,ALM_COMPOSE_VERSION,ALM_NO_FALLBACK_SCREENSHOT. Full table: docs/cli.md.JDWP allows one debugger at a time. Attach can fail while Android Studio is debugging the same app.
Canvas-drawn pixels have no nodes. Custom
Canvasdrawing,SurfaceView, andWebViewcontent expose no children or text; the semantics tree only shows what the app reports to accessibility.Limits:
dump_uicaps JSON at 800 nodes and the tree at 1500 unless you raisemaxNodes;savePathwrites the untrimmed dump. Thecomposesource needs Android Studio + Java 17+ and takes ~8–12 s.Contributing:
dist/is intentionally committed (marketplace installs run it without a build), andpackage.jsonis the only version source. Runnpm run buildafter changingsrc/and commitdist/in the same change. See AGENTS.md and docs/development.md.
Documentation
Document | Contents |
Coding-agent plugin: install paths, bundle, release | |
Tool reference, client configs, defaults, limits, call order | |
Analysis rules, environment variables, shared flags | |
How each tree is read and where it stops | |
All 20 clients, skill portability, verified runs | |
Development, tests, packaging constraints | |
Two-part walkthrough: getting started, and how the capture works |
Chinese counterparts are docs/*.zh.md.
License
MIT — see LICENSE. The TypeScript implementation is independent. Protocol and hit-testing behavior follow CoXier/LayoutInspectorV2-Pro (Apache-2.0) and AOSP android.view.ViewDebug / DdmHandleViewDebug / ddmlib; the Compose tree reads the transport, JVMTI agent, and androidx.compose.ui:ui-inspection from a local Android Studio at runtime. NOTICE records all of it.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Drive real devices from your AI Coding tool. Embed a client SDK (Unity, Godot, Flutter, iOS/macOS, Android, React Native, Web) in your app, then capture screenshots, traverse the UI tree, inject taps and key events, and run automated test tasks on the physical device over a secure relay.
remote debug iOS/Android/Unity/Godot/Flutter/RN/Web on real-device.ui-tree/screenshots/taps,tests.
Investigate iOS and Android crashes and failed UI tests from your coding agent.
Browse, inspect and render Jetpack Compose Material 3 and Wear component catalogs.
Related MCP Servers
- AlicenseBqualityCmaintenanceEnables AI agents to measure the real geometry of a live Android UI over adb and uiautomator, reporting overlapping views, clipping, touch targets under 48dp, occluded or unlabeled controls, and portrait/landscape diffs. Analysis also runs against saved uiautomator dumps, so layouts can be checked in CI without a device attached.6MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI assistants and IDEs to drive real Android devices and emulators for cross-app UI automation, testing, and diagnostics, including collecting Logcat output and screenshots.Apache 2.0
- AlicenseAqualityCmaintenanceEnables agents that cannot accept image input to read a running Android app's UI as text — dumping the accessibility/semantics tree, auditing tap targets and overlaps, and rendering pixels as glyphs — and to drive it by tapping elements resolved from their labels. Works without a hosted vision API, using adb against a connected device.43MIT
- AlicenseBqualityBmaintenanceEnables an AI agent to drive an Android app under development on a local emulator or connected device through adb, observing the screen and performing taps, swipes, text entry, key presses, waits, screenshots, logcat and crash inspection. It is restricted to debug builds installed via Run in Android Studio, so agents can exercise only the app being developed.2313 npmMIT