adbmcp

v0.8.0
@yhuangsh/adbmcp Checked 2 days ago Published 19 days ago

MCP server exposing the Android Debug Bridge (adb) as tools, resources and prompts.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_devices List connected Android devices

List Android devices and emulators known to adb with their serial, connection state and model. Call this first to discover serials for the "device" parameter of other tools.

get_device_info Get device information

Read a curated set of build properties (model, Android version, SDK level, ABI) plus screen size and density for one device. Use it instead of shell getprop when you only need identity/build details.

ParameterTypeDescription
devicestringDevice serial from list_devices; optional when exactly one device is connected.

shell Run a device shell command

Escape hatch: run an arbitrary command through `adb shell` on one device and return stdout/stderr. Powerful but not read-only — destructive commands are refused by default (reboot, su, mkfs, wipe, rm of / including split/reordered flags and the /* glob, and pipelines into sh/bash such as `curl … | sh` or `… | sudo bash`). This is a guardrail, not a sandbox: a deliberately obfuscated command can still get through. Prefer the dedicated tools (list_packages, install_apk, get_ui_hierarchy, …) when they cover the job. A non-zero remote exit code is reported as `exit_code: N` in the output.…

ParameterTypeDescription
command *stringDevice shell command, e.g. "dumpsys battery" or "ls /sdcard/Download".
devicestringDevice serial from list_devices; optional when exactly one device is connected.
timeout_msintegerCommand timeout in milliseconds (default 30000).

list_packages List installed packages

List package names installed on one device (optionally filtered by a substring of the package name), e.g. filter "com.example" to find only the app you care about.

ParameterTypeDescription
devicestringDevice serial from list_devices; optional when exactly one device is connected.
filterstringSubstring filter passed to `pm list packages`, e.g. "example" or "com.android.chrome".

install_apk Install an APK

Install a local APK on one device via `adb install`. Fails with INSTALL_FAILED_* details from the device when the package cannot be installed.

ParameterTypeDescription
apk_path *stringPath to the APK on the host machine (not on the device).
devicestringDevice serial from list_devices; optional when exactly one device is connected.
replacebooleanPass -r to replace an already installed package (default false).
timeout_msintegerInstall timeout in milliseconds (default 120000; large APKs are slow).

uninstall_package Uninstall a package

Remove an application from one device via `adb uninstall`. Destructive: the app is deleted from the device (use keep_data to keep its data directory).

ParameterTypeDescription
package *stringPackage name to uninstall, e.g. "com.example.app".
devicestringDevice serial from list_devices; optional when exactly one device is connected.
keep_databooleanPass -k to keep the app data and cache directories (default false).
timeout_msintegerUninstall timeout in milliseconds (default 60000).

grant_permission Grant a runtime permission

Grant a runtime permission to an app (`pm grant <package> <permission>`). Destructive: it changes the permissions the app holds; revoke_permission reverses it. Only changeable runtime permissions work; on stock Android these can be granted to non-debuggable apps too, though some restricted permissions still reject the shell.

ParameterTypeDescription
package *stringPackage name, e.g. "com.example.app".
permission *stringPermission name, e.g. "android.permission.CAMERA".
devicestringDevice serial from list_devices; optional when exactly one device is connected.

revoke_permission Revoke a runtime permission

Revoke a runtime permission from an app (`pm revoke <package> <permission>`). Destructive: the app loses the permission immediately and may fail until it is granted again.

ParameterTypeDescription
package *stringPackage name, e.g. "com.example.app".
permission *stringPermission name, e.g. "android.permission.CAMERA".
devicestringDevice serial from list_devices; optional when exactly one device is connected.

clear_app_data Clear app data

Delete all data stored by an app (`pm clear <package>`). Destructive and allowlist-gated: the server refuses unless the package is listed in ADBMCP_CLEAR_ALLOWED_PACKAGES (comma-separated); an unset or empty value refuses every clear.

ParameterTypeDescription
package *stringPackage name to clear, e.g. "com.example.app".
devicestringDevice serial from list_devices; optional when exactly one device is connected.

logcat_snapshot Read a logcat snapshot

Dump the current logcat buffer (`adb logcat -d`) from one device, optionally filtered to a log tag. Bounded output; use the stream tools when you need to watch logs over time.

ParameterTypeDescription
devicestringDevice serial from list_devices; optional when exactly one device is connected.
filter_specstringlogcat filter spec, e.g. "AndroidRuntime:E *:S" or "ActivityManager:I *:S". Space separated, passed to adb logcat as-is.
max_linesintegerMaximum lines to return, most recent kept (default 200, max 5000).
timeout_msintegerTimeout in milliseconds (default 30000).

start_logcat_stream Start a logcat stream

Start a long-lived `adb logcat` process on one device and return a stream_id. Poll it with read_logcat_stream and release it with stop_logcat_stream. Streams are killed when the server shuts down.

ParameterTypeDescription
devicestringDevice serial from list_devices; optional when exactly one device is connected.
filter_specstringlogcat filter spec, e.g. "AndroidRuntime:E *:S" or "ActivityManager:I *:S". Space separated, passed to adb logcat as-is.

read_logcat_stream Read a logcat stream

Return buffered logcat output accumulated since the previous read of this stream. Output is capped per call; anything not returned stays buffered for the next read. Dropped bytes are reported when the ring buffer overflowed.

ParameterTypeDescription
stream_id *stringstream_id returned by start_logcat_stream.
max_bytesintegerMaximum bytes to return in this call (default 65536).

stop_logcat_stream Stop a logcat stream

Terminate a logcat stream and forget its stream_id. Up to max_bytes of output buffered but not yet read is returned in this result; any excess is discarded and reported.

ParameterTypeDescription
stream_id *stringstream_id returned by start_logcat_stream.
max_bytesintegerMaximum buffered bytes to return (default 65536).

screenshot Capture a screenshot

Capture the current screen of one device (`exec-out screencap -p`) and return it as a PNG image. Follow up with get_ui_hierarchy when you need element coordinates instead of pixels.

ParameterTypeDescription
devicestringDevice serial from list_devices; optional when exactly one device is connected.

pull_file Pull a file from the device

Copy a file from the device to the host machine (`adb pull`). Refuses to overwrite an existing host file unless overwrite is true. This writes to the host filesystem, so it is not a read-only tool.

ParameterTypeDescription
local_path *stringDestination path on the host machine (relative paths resolve against the server cwd).
remote_path *stringAbsolute path on the device, e.g. "/sdcard/Download/crash.log".
devicestringDevice serial from list_devices; optional when exactly one device is connected.
overwritebooleanAllow replacing an existing host file (default false).

push_file Push a file to the device

Copy a file from the host machine to the device (`adb push`). For safety the remote path must be inside the configured allowed roots (default /sdcard, /storage/emulated/0, /data/local/tmp).

ParameterTypeDescription
local_path *stringSource path on the host machine (relative paths resolve against the server cwd).
remote_path *stringDestination path on the device, e.g. "/sdcard/Download/app.apk".
devicestringDevice serial from list_devices; optional when exactly one device is connected.

forward_port Forward a host port to the device

Create a port forward from the host to the device (`adb forward`), e.g. local "tcp:8080" to remote "tcp:8080". Use it to reach a device-side server (app HTTP server, debug port) from host-only test tooling.

ParameterTypeDescription
local *stringHost-side spec, e.g. "tcp:8080".
remote *stringDevice-side spec, e.g. "tcp:8080" or "localabstract:webview_devtools_remote".
devicestringDevice serial from list_devices; optional when exactly one device is connected.
no_rebindbooleanPass --no-rebind to fail instead of replacing an existing forward (default false).

remove_forward Remove a port forward

Remove a port forward created with forward_port (`adb forward --remove <local>`).

ParameterTypeDescription
local *stringHost-side spec previously forwarded, e.g. "tcp:8080".
devicestringDevice serial from list_devices; optional when exactly one device is connected.

reverse_port Reverse a device port to the host

Create a reverse socket connection (`adb reverse`): the device listens on the remote spec and connections are forwarded to the local spec on the host machine. Use it to let device-side code (app under test, on-device scripts) reach a server running on your machine.

ParameterTypeDescription
local *stringHost-side target spec, e.g. "tcp:8080".
remote *stringDevice-side listen spec, e.g. "tcp:8080".
devicestringDevice serial from list_devices; optional when exactly one device is connected.
no_rebindbooleanPass --no-rebind to fail instead of replacing an existing reverse (default false).

remove_reverse Remove a reverse port forward

Remove a reverse socket connection created with reverse_port (`adb reverse --remove <remote>`).

ParameterTypeDescription
remote *stringDevice-side spec previously passed to reverse_port, e.g. "tcp:8080".
devicestringDevice serial from list_devices; optional when exactly one device is connected.

list_forwards List port forwards

List the forward socket connections of one device (`adb forward --list`) as a JSON array of {serial, local, remote} objects (empty array when there are none).

ParameterTypeDescription
devicestringDevice serial from list_devices; optional when exactly one device is connected.

list_reverses List reverse port forwards

List the reverse socket connections of one device (`adb reverse --list`) as a JSON array of {serial, remote, local} objects (empty array when there are none). remote is the device-side listen spec, local the host-side target.

ParameterTypeDescription
devicestringDevice serial from list_devices; optional when exactly one device is connected.

discover_wireless Discover wireless-debugging devices over mDNS

Run `adb mdns services` and return a JSON array of {name, type, address, port} candidates for the _adb-tls-pairing._tcp and _adb-tls-connect._tcp services a device advertises while Wireless debugging is enabled — the way to find pairing/connect targets without knowing host:port in advance. Pairing candidates (type containing "adb-tls-pairing") feed wireless_pair: host = address, pair_port = port — the six-digit code still has to come from the device screen. Connect candidates (type containing "adb-tls-connect") feed connect: address = "address:port". Entries with port: null are announced b…

connect Connect to a device over TCP/IP

Connect adb to a device over TCP/IP (`adb connect <host>:<port>`), e.g. "192.168.1.42:5555"; a successful connect adds the device to list_devices. Not device-scoped: the address selects the device, and no serial exists until the connection is established. IPv6 literals (e.g. "[::1]:5555") and a bare host without :port are not accepted; specify host:port explicitly. On Android 10+ enable Wireless debugging on the device first; on Android 11+ that also needs a one-time pairing first — call wireless_pair with the code from the Wireless debugging screen, then connect to the port shown there (the…

ParameterTypeDescription
address *stringDevice TCP address as "host:port", e.g. "192.168.1.42:5555" (the port is shown in the Wireless debugging settings).

disconnect Disconnect TCP/IP devices

Disconnect one TCP/IP-connected device (`adb disconnect <host>:<port>`) or, when address is omitted, every TCP/IP-connected device (`adb disconnect`). USB connections are unaffected. Not device-scoped: for a TCP/IP device the address itself is the serial.

ParameterTypeDescription
addressstringTCP address "host:port" to disconnect; omit to disconnect every TCP/IP device.

wireless_pair Pair a device for wireless debugging

Pair with an Android 11+ device for wireless debugging (`adb pair <host>:<pair_port> <code>`), using the pairing code from Settings > Developer options > Wireless debugging > "Pair device with pairing code". This is step one of a two-step flow: after "Successfully paired", call connect with the same host and the port shown on the main Wireless debugging screen — the temporary pairing port above is not that connect port. Pairing codes expire after a couple of minutes, so ask the user for a fresh code if this fails. When the host or pair port is unknown, call discover_wireless first: it return…

ParameterTypeDescription
host *stringHostname or IP shown in the Wireless debugging settings, e.g. "192.168.1.42" (no port).
pair_port *integerPairing port shown on the Wireless debugging pairing dialog — different from the port used by connect.
codestringSix-digit pairing code from the pairing dialog; an optional single hyphen is accepted, e.g. "123-456". Required for clients without multi-round-trip support; on 2026-07-28 clients with elicitation it…

reconnect_wireless Reconnect declared wireless targets

Re-run `adb connect` for every target declared in ADBMCP_WIRELESS_TARGETS and report per-target status as a JSON array of {address, label, status, cause, detail}: status "connected" (including "already connected to …") or "failed" with the typed adb failure cause and adb's output line. Use it after a Wi-Fi blip, a device reboot or an adb/host restart to re-establish the declared devices. Device resolution retries missing declared targets once automatically before failing with NO_DEVICE, so this tool is for explicit control and status checks. Targets are declared as "label=host:port" or "host…

start_activity Start an activity

Launch an activity on one device (`am start`) either by component ("com.example/.MainActivity") or by intent action ("android.intent.action.VIEW" with optional data/extras). Use wait: true to block until the activity is reported as displayed.

ParameterTypeDescription
actionstringIntent action, e.g. "android.intent.action.VIEW". Mutually exclusive with component.
componentstringExplicit component "package/activity". Mutually exclusive with action.
datastringIntent data URI (-d), e.g. "https://example.com/item/1".
devicestringDevice serial from list_devices; optional when exactly one device is connected.
extrasarrayRaw `am start` arguments appended as-is and shell-quoted, e.g. ["--es", "message", "hello world", "--ez", "debug", "true"].
force_stop_firstbooleanPass -S to force-stop the target app before starting it (default false).
packagestringRestrict the intent to a package (-p), e.g. "com.example.app".
timeout_msintegerTimeout in milliseconds (default 30000; raise it when wait is true).
waitbooleanPass -W and wait for launch to complete (default false).

launch_package Launch an app by package id

Launch an installed app by package id: resolve its LAUNCHER activity (`cmd package resolve-activity --brief`) and start it (`am start -n`, with -W when wait is true). Returns the resolved component so later calls can use start_activity without re-resolving. The `monkey -p <package> 1` one-liner exists, but this keeps everyday launches off the shell escape hatch.

ParameterTypeDescription
package *stringPackage name to launch, e.g. "com.android.settings".
devicestringDevice serial from list_devices; optional when exactly one device is connected.
timeout_msintegerTimeout in milliseconds (default 30000; raise it when wait is true).
waitbooleanPass -W and wait for the launch to be reported as displayed (default false).

force_stop_app Force-stop an app

Stop all processes of a package on one device (`am force-stop`). Idempotent; safe to call when the app is not running.

ParameterTypeDescription
package *stringPackage name to stop, e.g. "com.example.app".
devicestringDevice serial from list_devices; optional when exactly one device is connected.

get_ui_hierarchy Get the UI hierarchy

Dump the current view hierarchy of one device as uiautomator XML (`uiautomator dump`), including bounds, resource ids, text and clickability. Use it to find stable selectors before driving the UI through shell (input tap/text). With to_file: true the XML is kept on the device at /data/local/tmp/adbmcp-ui-<timestamp>.xml and returned as {path, bytes} instead of inline text, so large dumps stay structurally valid; retrieve it with pull_file. Dumps accumulate at that prefix by design — remove them with the shell tool (rm <path>) after pulling.

ParameterTypeDescription
devicestringDevice serial from list_devices; optional when exactly one device is connected.
timeout_msintegerTimeout in milliseconds for the dump (default 30000).
to_filebooleanWrite the dump to /data/local/tmp/adbmcp-ui-<timestamp>.xml and return {path, bytes} instead of inline XML (default false).

tap Tap the screen

Tap a point on the device screen (`input tap X Y`). Coordinates are device pixels: read them from get_ui_hierarchy bounds or get_device_info screen_size, and screenshot after the tap to verify the result (screenshot → decide → act loop). If the display is off, wake it first with key_event WAKEUP — input events are dropped while the screen is off.

ParameterTypeDescription
x *integerX in device pixels (non-negative integer).
y *integerY in device pixels (non-negative integer).
devicestringDevice serial from list_devices; optional when exactly one device is connected.

swipe Swipe the screen

Swipe from (x1, y1) to (x2, y2) (`input swipe X1 Y1 X2 Y2 [duration_ms]`), e.g. to scroll a list or dismiss a card. duration_ms is the gesture time in milliseconds (device default 300 when omitted); a longer duration drags more slowly. Coordinates are device pixels; screenshot afterwards to verify the result.

ParameterTypeDescription
x1 *integerStart X in device pixels (non-negative integer).
x2 *integerEnd X in device pixels (non-negative integer).
y1 *integerStart Y in device pixels (non-negative integer).
y2 *integerEnd Y in device pixels (non-negative integer).
devicestringDevice serial from list_devices; optional when exactly one device is connected.
duration_msintegerGesture duration in milliseconds; omit for the device default (300 ms).

type_text Type text

Type text into the focused input field (`input text <text>`). Spaces are encoded as %s (adb's space form) and shell metacharacters are quoted, so the text reaches the device intact; note that a literal "%s" in text still becomes a space on the device. Non-ASCII text (e.g. CJK) cannot go through `input text` (ASCII-only): when a broadcast-capable IME is active — ADB Keyboard, `com.android.adbkeyboard/.AdbIME` — it is typed via the `ADB_INPUT_B64` broadcast instead. If no capable IME is active the call fails with `[IME_UNAVAILABLE]` (install/enable/select AdbIME, then retry); with `ADBMCP_TY…

ParameterTypeDescription
text *stringText to type, e.g. "hello world" or "user@example.com".
devicestringDevice serial from list_devices; optional when exactly one device is connected.

key_event Send a key event

Send one key event to the device (`input keyevent <code>`). Pass a named key (HOME, BACK, ENTER, DEL, MENU, POWER, VOLUME_UP, VOLUME_DOWN, TAB, ESCAPE, APP_SWITCH, WAKEUP, SLEEP) or a raw Android keycode 0-300. Use WAKEUP (or POWER) before driving a screen that may be off, and BACK/HOME to navigate.

ParameterTypeDescription
key *Android keycode 0-300, or a named key: HOME, BACK, ENTER, DEL, MENU, POWER, VOLUME_UP, VOLUME_DOWN, TAB, ESCAPE, APP_SWITCH, WAKEUP, SLEEP.
devicestringDevice serial from list_devices; optional when exactly one device is connected.

dumpsys_query Query a dumpsys service

Read a curated Android system service dump (`dumpsys <service> [args...]`): "battery" for charge/level, "activity" for tasks and activities, "window" for windows and display state, "connectivity" for network state. Output can be huge — "activity" especially — so it is capped (64 KB maximum) with a head+tail truncation marker where bytes were dropped; pass extra_args to narrow it (e.g. "activities" or "windows"). Other dumpsys services are intentionally not exposed; use shell for those.

ParameterTypeDescription
service *stringCurated service to dump: "battery", "activity", "window" or "connectivity".
devicestringDevice serial from list_devices; optional when exactly one device is connected.
extra_argsstringOptional arguments appended after the service, e.g. "activities com.example.app" or "windows"; token-split on whitespace and quoted for the device shell.
timeout_msintegerTimeout in milliseconds (default 30000).

adb_server_restart Restart the adb server

Recover from adb server version conflicts by running `adb kill-server` followed by `adb start-server`, then report the device list. Affects the shared adb server on this host (Android Studio and other tools use it too), so call it only when adb reports a server/version problem or a device is stuck.