interacting-with-android-device
FreeNo executable scriptsNot checkedInstructions for capturing UI state, comparing with mocks, and interacting with an Android device using MCP tools backed by ADB.
by bitwarden★ 9,728 GitHub starsAbout this skill
Interacting with Android Device
Quick Start: MCP Tools
The android-device MCP server provides 6 tools for device interaction. These replace the previous shell scripts with proper XML parsing, structured dumpsys parsing, and native obstruction detection.
Available tools:
capture— Capture UI hierarchy XML and/or screenshot. Params:{ xml?: boolean, screenshot?: boolean }. Default: both.find_element— Find element bytextorcontent-desc, return coordinates with obstruction detection. Params:{ text: string }. Returns JSON with coordinates, bounds, and obstruction status.tap_at— Tap at specific coordinates, wait, capture screenshot. Params:{ x, y, waitSeconds? }.tap_element— Find, tap, and capture in one call (recommended). Params:{ text, waitSeconds? }. Auto-adjusts coordinates when obstructed.navigate— Navigation actions: home, back, app-drawer. Params:{ action, waitSeconds? }. Captures screenshot after action.input_text— Type text into the focused field. Params:{ text, clear? }. Setclear: trueto erase existing content first.
Use these MCP tools instead of raw ADB commands to save tokens, get structured results, and benefit from automatic obstruction detection.
1. Capturing Current State
To understand what is currently on the device, use the capture tool:
- It saves
view.xml(UI hierarchy) andscreen.png(screenshot) to the working directory - Read
view.xmlto find coordinates (bounds) and properties (liketextorresource-id) of UI elements - Use
screen.pngfor visual verification against design mocks
2. Interacting with the Device
Using MCP Tools (Recommended)
Find and tap an element by text — use
tap_element: This finds the element, detects obstructions, taps (with adjusted coordinates if needed), and captures a screenshot — all in one call.Tap at specific coordinates — use
tap_at: When you already have coordinates fromfind_elementor manual inspection.Navigate (home, back, app-drawer) — use
navigate: Performs the action and captures a screenshot.Find element without tapping — use
find_element: Returns coordinates and full element info. Useful when you need to inspect before acting.Type text into a field — use
input_text: Types text into the currently focused field. Setclear: trueto erase existing content first. Tap the field before calling this if it isn't already focused.
Raw ADB Commands (When MCP Tools Aren't Sufficient)
- Key Events:
- Back:
adb shell input keyevent 4 - Home:
adb shell input keyevent 3 - Enter:
adb shell input keyevent 66
- Back:
- Scrolling/Swiping: Use
adb shell input swipe <x1> <y1> <x2> <y2> <duration_ms>where:(x1, y1)= starting point(x2, y2)= ending pointduration_ms= duration in milliseconds (1000ms is typical; adjust for speed/distance)- Note: For expanding containers/drawers, use large distances (e.g., 2400->300 for a 2992px tall screen)
3. Obstruction Detection
The find_element and tap_element tools automatically detect when another element would intercept the tap. This catches:
- System overlays (Layer 1): TalkBack floating menu, PiP windows, accessibility services — detected via
dumpsys window windowstouchable regions - In-app elements (Layer 2): FABs, dialogs, bottom sheets, snackbars — detected by finding the topmost clickable element at the tap point in the UI hierarchy
When obstruction is detected:
- Coordinates are auto-adjusted to the center of the largest unobstructed strip (top/bottom/left/right of the obstructor)
- The response includes the obstructor identity, bounds, and visible region info
- If fully obscured (no visible region), the original center is returned as best-effort
- Compose parent wrapper pattern (identical bounds) is recognized as non-obstruction
4. Verification Workflow
Follow these steps for a complete UI test:
- Build and Install: Ensure the latest version of the app is running:
./gradlew installDebug. - Inspect: Use
captureto dump the UI hierarchy and take a screenshot. - Compare: Check the current UI against any mock image files in the project.
- Interact: Use
tap_elementto tap a UI element by text. The tool handles coordinate calculation and obstruction detection automatically. - Verify: Use
captureagain to confirm the UI has updated as expected (e.g., a new screen is shown, or a success message appeared).
5. Examples
Example: Navigate to Settings and Check for Updates
# Go to home screen
navigate({ action: "home" })
# Open app drawer
navigate({ action: "app-drawer" })
# Find and tap through settings
tap_element({ text: "Settings", waitSeconds: 2 })
tap_element({ text: "System", waitSeconds: 2 })
tap_element({ text: "Software updates", waitSeconds: 2 })
tap_element
Install interacting-with-android-device in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
mcp__android-device__capturemcp__android-device__find_elementmcp__android-device__tap_atmcp__android-device__tap_elementmcp__android-device__navigatemcp__android-device__input_textBash(adb:*)Bash(sleep:*)Bash(./gradlew install*:*)ReadGlobFAQ
What does the interacting-with-android-device skill do?
Instructions for capturing UI state, comparing with mocks, and interacting with an Android device using MCP tools backed by ADB.
How do I install the interacting-with-android-device skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the interacting-with-android-device skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic