adb-mcp

adb-mcp

Drives an Android emulator or a physical device over adb. The agent screenshots, reads the UI hierarchy with true device-pixel coordinates, taps and types, manages app lifecycle, reads logcat, and runs Gradle builds and tests.

Category
访问服务器

README

<div align="center"> <img src="assets/android-head_flat.svg" width="72" alt="Android robot logo">

adb-mcp

An MCP server that drives Android emulators and devices over adb

Website Release CI Go MCP

</div>


Boot an AVD, screenshot, read the UI hierarchy, tap/swipe/type, set a device lock, read logcat, run Gradle builds and tests. 78 tools, from Claude Code, Cursor, VS Code, or any MCP client over stdio.

It is the Android counterpart to XcodeBuildMCP, built on the official Go MCP SDK.

<div align="center"> <img src="assets/demo.gif" width="600" alt="An agent driving a real emulator with adb-mcp: describe_ui finds the Chrome icon, tap_on_text taps it, and a screenshot confirms Chrome launched. The emulator screen is shown side by side with the actual tool call and result.">

describe_ui → tap_on_text → screenshot, driven live against a real emulator (emulator-5556), showing the actual tool calls and their actual output. </div>

Android is a trademark of Google LLC. adb-mcp is an independent, unofficial tool built for Android and is not affiliated with, sponsored, or endorsed by Google. The Android robot above is reproduced/modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.

Why

Driving Android by hand means a long runbook of raw adb commands, and it is easy to get wrong (stale tap coordinates, CRLF-corrupted screenshots, forgetting exec-out, guessing coordinates off a downscaled image). This server bakes that knowledge into its tools, so the agent doesn't have to relearn it:

  • Screenshots use exec-out screencap (no CRLF corruption) and are auto-downscaled so the image reader accepts them.
  • describe_ui returns each element's center in true device pixels (so taps land where you mean them to, no guessing off the image) and retries the transient "could not get idle state" failure on its own.

The workflow itself ships as readable resources the agent can pull up mid-task (the observe→act loop, native PIN/lock handling, crash triage, see below) instead of relearning them each session.

Getting started

1. Prerequisites

  • Android SDK with platform-tools (adb) and emulator. The server finds it via $ANDROID_HOME / $ANDROID_SDK_ROOT, else the platform default (~/Library/Android/sdk on macOS). If your MCP client launches the server without those set, pass --sdk /path/to/sdk in the client config's args (the server then exports it, so Gradle finds the SDK too). doctor prints the location it resolved.
  • At least one AVD (create one in Android Studio's Device Manager).

Go is not required: releases ship prebuilt binaries, and it's only needed to build from source.

2. Install

On macOS/Linux:

curl -fsSL https://raw.githubusercontent.com/iksnerd/adb-mcp/main/install.sh | sh

The script (install.sh) picks the right archive for your OS/architecture, verifies its SHA-256 against the release's checksums.txt, and installs to ~/.local/bin (override with BIN_DIR=...; pin a version with VERSION=v0.17.0).

Prefer to grab the binary yourself? Every platform's archive (macOS, Linux, and Windows, amd64 and arm64) is on the Releases page, each with a checksum in checksums.txt. On Windows, download the windows_amd64 or windows_arm64 zip and put adb-mcp.exe somewhere on your PATH.

Once installed, stay current with the built-in updater. It fetches the latest release, verifies its checksum, and swaps the binary in place:

adb-mcp update

The registration below launches the server by the bare name adb-mcp, so it must be on your $PATH (which adb-mcp should resolve; the installer warns if ~/.local/bin isn't on it). Otherwise point the client at the absolute path to the binary instead.

3. Register with your MCP client

Claude Code:

claude mcp add adb -- adb-mcp

(When working inside this repo itself, the bundled .mcp.json is picked up automatically, no registration needed.)

Cursor / VS Code: one-click install (assumes adb-mcp is on your PATH from step 2):

<img src="https://cursor.com/deeplink/mcp-install-dark.svg" alt="Install in Cursor" height="20"> <img src="https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=flat-square" alt="Install in VS Code" height="20">

Any other client (Windsurf, Codex, …): run adb-mcp over stdio. The usual config shape:

{
  "mcpServers": {
    "adb": { "command": "adb-mcp" }
  }
}

To confirm it's wired up, ask your agent to "boot an emulator and take a screenshot".

From source (Go 1.26+)

make install                 # builds ./bin/adb-mcp and copies it to ~/.local/bin
# or:
go build -o bin/adb-mcp ./cmd/adb-mcp
# or straight from the module (note the /cmd/adb-mcp suffix):
go install github.com/iksnerd/adb-mcp/cmd/adb-mcp@latest

Tools

78 tools across ten areas. Every device-facing tool takes an optional serial (adb -s). Omit it with one device attached, or pass one from list_devices with several. Full reference: docs/TOOLS.md.

  • Emulator / device: boot, list, wait-for-boot, shut down, connect over Wi-Fi, adb_reverse port forwarding (Metro!)
  • Observe: screenshot to see (works on multi-display foldables, pick a panel with display), describe_ui for true-pixel element centers, with the focused top window (spot a biometric prompt, or the wrong app entirely, occluding your target via optional package), filter/query/compact modes, and a hidden-node count so absence is trustworthy
  • Interact: tap, tap_on_text/tap_element (id-addressed), swipe, drag, long-press, type, key combos, PIN pads, wait, run_sequence (batch steps + guards in one call, which keeps native-timer flows from being perturbed by per-step round-trips); opt-in verify_change tells you whether a tap/key actually changed the UI; opt-in via_accessibility on tap_on_text/tap_element (EXPERIMENTAL) dispatches a real accessibility click for native views a coordinate tap can't reach, see bridge/README.md
  • Lock / Keystore / Biometrics: set/clear a secure lock screen, check lock state, has_biometric_enrolled + fingerprint_touch/finger_remove to satisfy a BiometricPrompt on the emulator
  • Extended Controls (emulator): send_sms (OTP/2FA), phone_call, set_battery (also works on real devices via dumpsys), cellular (roaming/weak-signal/throttled), set_sensor (accelerometer/light/…), rotate_screen, avd_snapshot, driving the emulator's console-only panel that describe_ui can't see
  • App lifecycle: install/uninstall, launch/stop, app_state (running pid(s) + Metro-vs-embedded bundle), launch_dev_client (Expo dev build → Metro, skipping the Dev Launcher), reload_app/open_dev_menu, clear data, permissions, deep links, push/pull files, last_crash
  • Logs & capture: one-shot or streaming logcat (substring/priority/tag filters, since time window, opt-in redact to mask tokens/passwords/API keys before output), clear_logcat, last_crash, screen recording
  • Environment & diagnostics: dark mode, mock location, clean status bar, stay_awake (stop a doze-happy screen blanking your screenshots), doctor
  • Gradle build & test: assembleDebug, unit tests, instrumented tests, JVM unit-test coverage via JaCoCo (get_coverage_report/get_file_coverage), task + variant + module discovery (list_gradle_variants/list_gradle_projects), one-shot build_and_run
  • Session defaults: pin project_dir/serial once (session_set_defaults) so a multi-module/multi-flavor project or multi-device session doesn't need them repeated on every call

The driving know-how itself ships as five MCP resources (android://guide/*) the client can list and read. See docs/TOOLS.md for the URIs, or jump straight to android://guide/driving for the core loop below.

The core loop

observe → locate → act → re-observe. screenshot to see, describe_ui to get true-pixel centers, tap/tap_on_text/swipe/input_text to act, then screenshot again to confirm. Read android://guide/driving for the full loop and the gotchas that waste turns.

Development

make check     # go vet + go test (unit tests need no emulator)
make run       # run over stdio for manual JSON-RPC poking

Layout:

cmd/adb-mcp/main.go        entry: subcommands (update/version) or serve MCP over stdio
internal/tools/            thin MCP tool bindings
internal/adb/              the device layer: an adb.Client whose methods are the commands
internal/gradle/           host-side Gradle: build, find APKs, parse test reports
internal/uiauto/           pure uiautomator-hierarchy model + parsing (unit-tested)
internal/sdk/              resolves the Android SDK (adb/emulator paths, PATH env)
internal/concurrent/       RunAll/RunIndexed: fan out independent I/O calls, join, done
internal/guides/           the skill guides, embedded and served as MCP resources
internal/selfupdate/       the `adb-mcp update` release fetch/verify/swap
internal/bridgeupdate/     the `adb-mcp bridge install` release fetch/verify/install

Dependencies point inward only (tools → adb, gradle, uiauto → sdk), and each internal/tools/<domain>.go adapter mirrors an execution file of the same name (device commands are adb.Client methods). Full map, the package graph, and the rules for adding a tool: ARCHITECTURE.md.

Documentation

Contributing

See CONTRIBUTING.md for setup and conventions. Found a security issue? See SECURITY.md instead of opening a public issue. Licensed under MIT.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选