# Repository Briefing: minhalvp/android-mcp-server
> Source: https://repoforai.com/repo/minhalvp/android-mcp-server (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/minhalvp/android-mcp-server
- **Category**: Coding, Skills & MCP (AI 编程 / Skills / MCP)
- **Primary Language**: Python
- **License**: Apache-2.0
- **Engineering Health**: A (82/100 · Maintenance 35/35 · Adoption 16/25 · Releases 11/20 · License 20/20)
- **Review Snapshot**: 2026-12-04
- **Deployment / Stack Signals**: MCP, CLI, Local AI
- **Momentum**: 818 ★ total (+1 24h / +3 7d) · 93 forks
- **When to Use**: Best for: Exploratory Android QA, reproducing UI bugs, and checking app or system state on a trusted emulator or dedicated test phone, especially when the UI exposes usable element labels. Skip if: You need deterministic regression assertions, built-in non-ASCII text entry, or a least-privilege interface for untrusted clients or sensitive devices.

## Overview
```text
### Architecture & Core Mechanics
android-pilot is a local Python MCP server that exposes an Android phone or emulator to an MCP client through adb. The package requires Python 3.11 or later and declares `mcp>=2,<3` and `Pillow>=10`. Its entry point is `android-pilot`. `server.py` exposes the tools and holds the reference store; `screen.py` parses UI Automator XML, renders compact text, and checks element refs; `device.py` is the only module that executes external commands.

The interaction loop is observe, act, and refresh. A snapshot assigns `eN` refs to actionable controls. The client passes a ref to a tool instead of turning a visual position into coordinates. Before acting, the server checks that the target still resolves; it rejects a stale or ambiguous target rather than guessing. MCP is the integration boundary: Claude Code, Codex, and OpenCode are named client examples, and no model runs inside the server.

### Key Capabilities & Differentiators
The text snapshot reports screen size, static text for context, and actionable elements with roles, labels, and relevant states such as focus, checked, and disabled. Off-screen elements are omitted by default but can be requested with `include_offscreen=True`; password field text is omitted from snapshots. Clients can tap or long-press, swipe in four directions, type printable ASCII, and send a fixed set of navigation and editing keys. Text entry can focus a field by ref, clear it, or submit it.

When the UI hierarchy does not expose a usable target, `screenshot()` returns a JPEG scaled to 30% of device resolution, and `tap` accepts coordinates in screenshot pixels. `then_snapshot=true` lets a client get the resulting text snapshot in the action response rather than making a separate call. `shell(command)` provides a separate escape hatch for arbitrary adb shell commands; it is not constrained by element-reference checks.

### Trade-offs & Limitations
Against a raw adb wrapper, the text-and-ref layer gives an agent named controls and state instead of making it interpret XML or guess screenshot coordinates. This is most useful when the UI Automator hierarchy exposes useful labels and actionable nodes. Custom-drawn interfaces and poorly labeled controls push the client back to screenshots and coordinates. Ref checks reduce accidental actions but can require extra snapshots on rapidly changing screens or in lists with identical rows. The screenshot scale can obscure fine detail, and built-in text entry is limited to printable ASCII.

Compared with a scripted UI test suite, the server is better suited to exploratory or assisted navigation than to repeatable regression assertions. Its main operational constraint is trust: a connected client can read the screen, send input, and run arbitrary commands with adb shell permissions. Ref validation prevents some wrong-target taps, not unauthorized behavior, and omitting password field text from snapshots does not make other screen data private. Use trusted clients, a known adb binary, and dedicated test devices.

### Hardware & Deployment Guide
Install uv and Android Platform-Tools, make `adb` available to the client process, and connect an emulator or an authorized phone with USB debugging enabled. Register `uvx android-pilot` as the MCP command, or use `claude mcp add android -- uvx android-pilot` with Claude Code. Use `adb devices` to confirm that the target is ready. If multiple devices are attached, the default is the first listed device; specify `--device` to make the target explicit.

The server can start before adb or the device is ready and retry discovery on a later tool call. An invalid explicit `--adb-path` or `ADB_PATH`, by contrast, prevents startup. GUI clients that inherit a different PATH may need an absolute `uvx` path. A source checkout can be launched with `uv --directory /path/to/android-mcp-server run android-pilot`; development checks use pytest, Ruff, and ty. The manifest identifies version `0.2.0a3` as alpha, and no GitHub release is listed. Pin the version you validate before adopting it for a shared workflow.
```

## Key Capabilities
```text
- Module boundaries: `server.py` registers MCP tools and stores refs; `screen.py` parses UI Automator XML and validates refs; `device.py` is the only module that runs external commands.
- Element targeting: Snapshots assign `eN` refs to actionable elements. Changed, missing, or ambiguously moved targets require a fresh snapshot rather than a guessed tap.
- Tool-call efficiency: UI actions accept `then_snapshot=true`, returning the resulting screen state without a separate snapshot call.
- Visual fallback: `screenshot()` returns a JPEG at 30% of device resolution, and coordinate taps use screenshot pixels.
- Device lifecycle: The server can start before adb or a device is ready and retry discovery on the next tool call; `--device` selects a specific target.
- Permission boundary: `shell(command)` runs arbitrary adb shell commands with the Android shell's permissions; the client can also read and operate the UI.
```

## Quick Start / Clone
```bash
git clone https://github.com/minhalvp/android-mcp-server.git
cd android-mcp-server
uv sync               # installs the project and dev tools (pytest, ruff, ty)
uv run pytest
uv run ruff check .
uv run ty check
```
