SuperAPIAI Directory

android-mcp-server

github.com · AI developer platforms

android-mcp-server (android-pilot) is an MCP protocol-based server that controls Android physical devices or emulators via adb, allowing AI agents in MCP clients such as Claude Code, Codex, and OpenCode to read the screen and interact with it. It uses element references (e1, e2, ...) instead of pixel coordinates: snapshot returns a compact text snapshot in which every actionable element carries a ref, and interaction tools accept that ref directly; before executing, the server re-reads the screen and verifies that the element class, resource ID, and label at the same UI tree position match, refusing the operation and requiring a new snapshot if the screen has changed, thereby reducing the fragility of coordinate-based tapping.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsAndroid

About this tool

android-mcp-server (the runtime command is android-pilot) is an MCP server for letting AI agents operate an Android phone or emulator. It drives the device via adb, and any MCP client (such as Claude Code, Codex, OpenCode, etc.) can read the screen and interact with it.

Purpose and design approach Most adb wrapper solutions have the model read screenshots or XML dumps and then guess pixel coordinates. This project instead uses an element reference mechanism: snapshot returns compact text in which every actionable element carries a ref (e1, e2, ...), and interaction tools accept that ref. The model does not need to compute coordinates, and the server refuses to execute when the screen has changed before the operation. The materials cite AppAgent (CHI 2025) data illustrating the weakness of coordinate-based operations: GPT-4 completed 2.2% of Android tasks using raw coordinate actions, versus 48.9% using element ID actions.

Main capabilities

  • snapshot output: one line per element, arranged in screen order, containing only key states. eN is the ref passed to interaction tools.
  • Role: button, edit, switch, checkbox, radio, dropdown, tab, list (scrollable), or item (other clickable elements).
  • Label: the element's text or description, or constructed from child elements and resource ID; overly long labels are truncated.
  • Flags: appear only when deviating from the default, including checked/unchecked, focused, selected, disabled, password (field text omitted), scroll, long-click, and off-screen.
  • text "..." lines: non-interactive text, used to provide context.
  • Off-screen elements are omitted by default (browsers expose many); pass include_offscreen=true to include them, and the output will state how many were omitted.
  • Password fields: the text of fields that Android marks as passwords does not appear in snapshots or error messages, and is instead labeled with the description or resource ID; once the password is shown (e.g., via a "show password" toggle), Android removes that marking and the text is displayed like an ordinary field. Screenshots show the actual content on the screen.
  • ref validation: the ref belongs to the most recent snapshot. Before acting, the server re-reads the screen and checks whether the element at the same position in the UI tree still has the same class, resource ID, and label. If they match, the element's current position is used (clipped to the screen; for partially visible elements, the visible part is clicked), so small layout shifts will not cause the click to fail; if they do not match, the tool performs no action and requires a new snapshot instead of clicking a new element at the old position.
  • then_snapshot=true: every action can include this parameter to return the post-action screen in the same reply, saving a round trip.
  • Results are plain text only, with no duplicate structured copy; the workflow is explained once in the server description rather than in every tool description.

Usage Prerequisites: adb is in PATH; an Android device or emulator with USB debugging enabled. Add the server configuration to your MCP client configuration (most clients use this format; consult your client's documentation for the exact file location); there is also a corresponding way in Claude Code. Then confirm that adb can see the device; if it shows unauthorized, unlock the phone and accept the "Allow USB debugging" prompt. After restarting the client, you can ask the agent to perform tasks such as "open Settings and tell me which Wi-Fi network is currently connected." Optional parameters are added in args after "android-pilot". The server starts even if adb or the device is not yet ready, so you can start the client first and plug in the phone later; until then, tools return an error explaining what is missing, and the next call re-checks. An incorrect --adb-path (or ADB_PATH) will stop the server at startup. The selected device and adb binary are printed to stderr. To try a local checkout: use "command": "uv", "args": ["--directory", "/path/to/android-mcp-server", "run", "android-pilot"] in your client. See CHANGELOG.md for the change log.

Use cases Suitable for automation scenarios where an AI agent needs to read the interface, click, type, and scroll on a real Android device or emulator to complete tasks, especially MCP client integrations that want to avoid coordinate guessing and improve operation stability.

Limitations and security The shell tool gives the client full shell access to the device, and other tools can also click, type, and read the screen, so only connect trusted clients. adb itself is a high-trust program that can shell into all connected devices; it is recommended to pin a trusted binary via --adb-path rather than relying on PATH.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools