androidbuild-mcp
v0.1.1Build, deploy, drive and debug Android apps: Gradle, emulators, adb, logcat, UI automation
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
doctor Doctor
Check the Android development environment: SDK location, adb, emulator, avdmanager, Java, and connected devices. Run this first if any other tool fails with a missing-binary error.
session_set_defaults Set session defaults
Set default projectDir/module/variant/serial/appId used by other tools when the corresponding argument is omitted. Set these once after discovering the project.
| Parameter | Type | Description |
|---|---|---|
appId | string | Application id (package name) |
module | string | Gradle module, e.g. 'app' |
projectDir | string | Absolute path to the Gradle project root |
serial | string | adb device serial, e.g. emulator-5554 |
variant | string | Build variant, e.g. 'debug' |
session_show_defaults Show session defaults
Show the current session defaults.
session_clear_defaults Clear session defaults
Clear all session defaults, or only the listed keys.
| Parameter | Type | Description |
|---|---|---|
keys | array | Keys to clear; omit to clear everything |
discover_projects Discover Gradle projects
Find Android/Gradle projects (directories with settings.gradle[.kts]) under a path. Use the result to session_set_defaults projectDir.
| Parameter | Type | Description |
|---|---|---|
searchPath * | string | Directory to search from |
maxDepth | integer | Max directory depth (default 3) |
list_modules List Gradle modules
List modules declared in settings.gradle(.kts) of the project.
| Parameter | Type | Description |
|---|---|---|
projectDir | string | Project root (defaults to session) |
list_variants List build variants
List build variants of a module by inspecting its Gradle assemble tasks (runs './gradlew <module>:tasks').
| Parameter | Type | Description |
|---|---|---|
module | string | Module name, e.g. 'app' (defaults to session) |
projectDir | string | Project root (defaults to session) |
get_app_id Get application id
Get the applicationId (package name) of a module, parsed from its build.gradle(.kts). Needed by install/launch/log tools.
| Parameter | Type | Description |
|---|---|---|
module | string | Module name (defaults to session) |
projectDir | string | Project root (defaults to session) |
variant | string | Variant, used to warn about applicationIdSuffix |
show_gradle_config Show Gradle config
Show toolchain versions: Gradle (from wrapper properties) and everything in the version catalog (AGP, Kotlin, Compose, ...).
| Parameter | Type | Description |
|---|---|---|
projectDir | string | Project root (defaults to session) |
build_app Build app
Build an APK with Gradle (assemble<Variant>). On failure returns compact compiler errors with file:line. On success returns the APK path.
| Parameter | Type | Description |
|---|---|---|
module | string | Gradle module, e.g. 'app' (defaults to session) |
projectDir | string | Project root (defaults to session) |
variant | string | Build variant, e.g. 'debug' (defaults to session) |
build_run Build, install and run
Build the APK, install it on a device/emulator (adb install -r), and launch the app. Needs appId (session default or argument) to launch.
| Parameter | Type | Description |
|---|---|---|
appId | string | Application id to launch (defaults to session) |
module | string | Gradle module, e.g. 'app' (defaults to session) |
projectDir | string | Project root (defaults to session) |
serial | string | Device serial (defaults to session or the only device) |
variant | string | Build variant, e.g. 'debug' (defaults to session) |
test_app Run unit tests
Run local JVM unit tests (test<Variant>UnitTest) and return a parsed pass/fail summary with failure messages.
| Parameter | Type | Description |
|---|---|---|
module | string | Gradle module, e.g. 'app' (defaults to session) |
projectDir | string | Project root (defaults to session) |
tests | string | Filter passed to --tests, e.g. 'com.foo.MyTest' or '*MyTest*' |
variant | string | Build variant, e.g. 'debug' (defaults to session) |
test_instrumented Run instrumented tests
Run instrumented tests on a connected device/emulator (connected<Variant>AndroidTest) and return a parsed summary. Requires a booted device.
| Parameter | Type | Description |
|---|---|---|
module | string | Gradle module, e.g. 'app' (defaults to session) |
projectDir | string | Project root (defaults to session) |
variant | string | Build variant, e.g. 'debug' (defaults to session) |
lint Run Android Lint
Run Android Lint (lint<Variant>) and return the textual report summary.
| Parameter | Type | Description |
|---|---|---|
module | string | Gradle module, e.g. 'app' (defaults to session) |
projectDir | string | Project root (defaults to session) |
variant | string | Build variant, e.g. 'debug' (defaults to session) |
clean Clean build
Run gradle clean for the project.
| Parameter | Type | Description |
|---|---|---|
projectDir | string | Project root (defaults to session) |
get_apk_path Get APK path
Locate the most recent built APK for a module/variant without building.
| Parameter | Type | Description |
|---|---|---|
module | string | Gradle module, e.g. 'app' (defaults to session) |
projectDir | string | Project root (defaults to session) |
variant | string | Build variant, e.g. 'debug' (defaults to session) |
stop_gradle Stop Gradle daemons
Stop the project's Gradle daemons (use when a build hangs or to free memory).
| Parameter | Type | Description |
|---|---|---|
projectDir | string | Project root (defaults to session) |
list_devices List devices
List connected devices and emulators with serial, state, model, Android version and API level.
install_app Install app
Install an APK on a device/emulator (adb install -r).
| Parameter | Type | Description |
|---|---|---|
apkPath * | string | Path to the APK (from build_app / get_apk_path) |
serial | string | Device serial (defaults to session or the only device) |
launch_app Launch app
Launch an app by application id (resolves the launcher activity automatically).
| Parameter | Type | Description |
|---|---|---|
appId | string | Application id (defaults to session) |
serial | string | Device serial (defaults to session or the only device) |
stop_app Stop app
Force-stop a running app (am force-stop).
| Parameter | Type | Description |
|---|---|---|
appId | string | Application id (defaults to session) |
serial | string | Device serial (defaults to session or the only device) |
uninstall_app Uninstall app
Uninstall an app from a device/emulator.
| Parameter | Type | Description |
|---|---|---|
appId | string | Application id (defaults to session) |
serial | string | Device serial (defaults to session or the only device) |
clear_app_data Clear app data
Clear all data of an app (pm clear) — resets it to a fresh-install state.
| Parameter | Type | Description |
|---|---|---|
appId | string | Application id (defaults to session) |
serial | string | Device serial (defaults to session or the only device) |
get_app_info Get app info
Get installed-app info from the device: version, target/min SDK, install path, running PID.
| Parameter | Type | Description |
|---|---|---|
appId | string | Application id (defaults to session) |
serial | string | Device serial (defaults to session or the only device) |
list_avds List AVDs
List available Android Virtual Devices and which ones are currently running.
boot_emulator Boot emulator
Boot an AVD in the background and wait until Android finishes booting. Returns the adb serial. Set wipeData to factory-reset the AVD on boot.
| Parameter | Type | Description |
|---|---|---|
avdName * | string | AVD name from list_avds |
timeoutSeconds | integer | Boot timeout (default 180) |
wipeData | boolean | Factory-reset the AVD (erases all data) |
kill_emulator Kill emulator
Shut down a running emulator (adb emu kill).
| Parameter | Type | Description |
|---|---|---|
serial | string | Emulator serial (defaults to session or the only device) |
create_avd Create AVD
Create an AVD from an installed system image (e.g. 'system-images;android-35;google_apis;arm64-v8a'). If systemImage is omitted, lists the installed images to choose from.
| Parameter | Type | Description |
|---|---|---|
name * | string | Name for the new AVD |
device | string | Device profile, e.g. 'pixel_7' (default: generic) |
systemImage | string | Installed system-images package id |
delete_avd Delete AVD
Delete an AVD permanently.
| Parameter | Type | Description |
|---|---|---|
name * | string | AVD name to delete |
set_emulator_location Set emulator location
Set the GPS location of a running emulator.
| Parameter | Type | Description |
|---|---|---|
latitude * | number | Latitude in decimal degrees |
longitude * | number | Longitude in decimal degrees |
serial | string | Emulator serial (defaults to session or the only device) |
set_appearance Set dark/light mode
Switch a device/emulator between dark and light mode (cmd uimode night).
| Parameter | Type | Description |
|---|---|---|
mode * | string | Appearance to set |
serial | string | Emulator serial (defaults to session or the only device) |
statusbar_demo_mode Status bar demo mode
Enable clean status bar for screenshots (fixed clock, full battery, full signal) or disable it.
| Parameter | Type | Description |
|---|---|---|
enabled * | boolean | true to enter demo mode, false to exit |
clock | string | Clock as hhmm, e.g. '1200' (default 1200) |
serial | string | Emulator serial (defaults to session or the only device) |
record_video_start Start screen recording
Start recording the device screen (adb screenrecord, max 3 minutes). Returns a recordingId for record_video_stop.
| Parameter | Type | Description |
|---|---|---|
serial | string | Emulator serial (defaults to session or the only device) |
timeLimitSeconds | integer | Auto-stop after (default 180) |
record_video_stop Stop screen recording
Stop a screen recording and pull the MP4 to the local machine.
| Parameter | Type | Description |
|---|---|---|
recordingId * | string | Id from record_video_start |
start_log_capture Start log capture
Start capturing logcat to a file in the background. Filter by app (via its pid) and/or tag. Returns a sessionId for stop_log_capture. The app must be running to filter by appId.
| Parameter | Type | Description |
|---|---|---|
appId | string | Only capture logs of this app (defaults to session appId; must be running) |
clear | boolean | Clear the log buffer first (default true) |
serial | string | Device serial (defaults to session or the only device) |
tag | string | Only capture this log tag (logcat '<tag>:V *:S') |
stop_log_capture Stop log capture
Stop a log capture session and return the file path plus the last lines.
| Parameter | Type | Description |
|---|---|---|
sessionId * | string | Session id from start_log_capture |
tailLines | integer | Lines of tail to inline (default 60) |
get_logs Get recent logs
One-shot dump of recent logcat lines, optionally filtered by app (must be running) and/or tag.
| Parameter | Type | Description |
|---|---|---|
appId | string | Filter to this app (defaults to session appId if running) |
lines | integer | Max lines (default 200) |
serial | string | Device serial (defaults to session or the only device) |
tag | string | Filter to this log tag |
get_crash_logs Get crash logs
Dump the crash log buffer (Java exceptions, native crashes, ANRs).
| Parameter | Type | Description |
|---|---|---|
lines | integer | Max lines (default 300) |
serial | string | Device serial (defaults to session or the only device) |
screenshot Screenshot
Take a screenshot of the device/emulator screen and return it as an image. With annotate: true (needs the Google android CLI), UI elements get numbered bounding boxes — including text inside images/WebViews that snapshot_ui cannot see.
| Parameter | Type | Description |
|---|---|---|
annotate | boolean | Draw labeled bounding boxes around UI elements (vision-based) |
serial | string | Device serial (defaults to session or the only device) |
snapshot_ui Snapshot UI hierarchy
Dump the current UI as a compact list of actionable elements (text, id, content-desc, tap coordinates). Use the @(x,y) centers with tap/long_press. Text-heavy screens are capped; pass 'filter' to search within them.
| Parameter | Type | Description |
|---|---|---|
filter | string | Only include elements whose text/desc/id contains this (case-insensitive) |
serial | string | Device serial (defaults to session or the only device) |
tap Tap
Tap the screen. Coordinates from snapshot_ui are exact device pixels — prefer them over estimating positions by looking at a screenshot image. Instead of pixels you can pass screen percentages (0-1): safer when estimating positions from a screenshot image.
| Parameter | Type | Description |
|---|---|---|
serial | string | Device serial (defaults to session or the only device) |
x | integer | X in device pixels |
xPct | number | X as fraction of screen width (0-1) |
y | integer | Y in device pixels |
yPct | number | Y as fraction of screen height (0-1) |
tap_element Tap annotated element
Tap element #N from the most recent screenshot { annotate: true } capture — no coordinate math needed. The mapping is exact even if your client displays the image scaled. Re-capture after the UI changes: element numbers go stale.
| Parameter | Type | Description |
|---|---|---|
element * | integer | Element number from the annotated screenshot |
serial | string | Device serial (defaults to session or the only device) |
scroll Scroll
Scroll the screen in a direction (computes a safe swipe in the middle of the screen, avoiding the status bar and navigation areas). Prefer this over raw swipe for scrolling.
| Parameter | Type | Description |
|---|---|---|
direction * | string | 'down' reveals content below (finger moves up), 'up' reveals content above |
amount | number | Fraction of screen to scroll (default 0.5) |
serial | string | Device serial (defaults to session or the only device) |
long_press Long press
Long-press the screen at coordinates. Instead of pixels you can pass screen percentages (0-1): safer when estimating positions from a screenshot image.
| Parameter | Type | Description |
|---|---|---|
durationMs | integer | Press duration (default 1000ms — launchers ignore shorter holds) |
serial | string | Device serial (defaults to session or the only device) |
x | integer | X in device pixels |
xPct | number | X as fraction of screen width (0-1) |
y | integer | Y in device pixels |
yPct | number | Y as fraction of screen height (0-1) |
swipe Swipe
Swipe from one point to another (scrolling, dismissing). For drag-and-drop use drag instead. Instead of pixels you can pass screen percentages (0-1): safer when estimating positions from a screenshot image.
| Parameter | Type | Description |
|---|---|---|
durationMs | integer | Swipe duration (default 300ms) |
serial | string | Device serial (defaults to session or the only device) |
x1 | integer | Start X in device pixels |
x1Pct | number | Start X as fraction of width (0-1) |
x2 | integer | End X in device pixels |
x2Pct | number | End X as fraction of width (0-1) |
y1 | integer | Start Y in device pixels |
y1Pct | number | Start Y as fraction of height (0-1) |
y2 | integer | End Y in device pixels |
y2Pct | number | End Y as fraction of height (0-1) |
drag Drag and drop
Drag an element from one point to another (input draganddrop). Instead of pixels you can pass screen percentages (0-1): safer when estimating positions from a screenshot image.
| Parameter | Type | Description |
|---|---|---|
durationMs | integer | Drag duration (default 800ms) |
serial | string | Device serial (defaults to session or the only device) |
x1 | integer | Start X in device pixels |
x1Pct | number | Start X as fraction of width (0-1) |
x2 | integer | End X in device pixels |
x2Pct | number | End X as fraction of width (0-1) |
y1 | integer | Start Y in device pixels |
y1Pct | number | Start Y as fraction of height (0-1) |
y2 | integer | End Y in device pixels |
y2Pct | number | End Y as fraction of height (0-1) |
type_text Type text
Type ASCII text into the focused field. Waits for the soft keyboard first, so it is safe to call right after tapping a field. Options: clear the field first, press ENTER after. Non-ASCII characters are not supported by adb input.
| Parameter | Type | Description |
|---|---|---|
text * | string | Text to type (ASCII) |
clear | boolean | Clear the field before typing (select-all + delete) |
serial | string | Device serial (defaults to session or the only device) |
submit | boolean | Press ENTER after typing |
key_press Press key
Press a hardware/navigation key: BACK, HOME, ENTER, TAB, DELETE, ESCAPE, MENU, APP_SWITCH, DPAD_*, or any KEYCODE_ name.
| Parameter | Type | Description |
|---|---|---|
key * | string | Key name |
serial | string | Device serial (defaults to session or the only device) |
key_sequence Press key sequence
Press several keys in order (same names as key_press).
| Parameter | Type | Description |
|---|---|---|
keys * | array | Keys in press order |
serial | string | Device serial (defaults to session or the only device) |
wait_for_ui Wait for UI
Poll the UI until an element containing the given text / content-desc / resource-id appears. Returns its tap coordinates.
| Parameter | Type | Description |
|---|---|---|
match * | string | Substring to look for in text, content-desc or resource-id |
serial | string | Device serial (defaults to session or the only device) |
timeoutSeconds | integer | Give up after this long (default 15) |
get_coverage_report Get coverage report
Run a coverage Gradle task (Kover or Jacoco) and summarize line coverage per package. Tries koverXmlReport<Variant> by default; pass 'task' for a custom one (e.g. jacocoTestReport). The project must apply a coverage plugin.
| Parameter | Type | Description |
|---|---|---|
module | string | Module (defaults to session) |
projectDir | string | Project root (defaults to session) |
skipRun | boolean | Only parse an existing report without running Gradle |
task | string | Coverage task to run, e.g. 'koverXmlReportDebug' |
get_file_coverage Get file coverage
Show covered/uncovered line numbers of one source file from the latest coverage report (run get_coverage_report first).
| Parameter | Type | Description |
|---|---|---|
file * | string | Source file name, e.g. 'BookRepository.kt' |
module | string | Module (defaults to session) |
projectDir | string | Project root (defaults to session) |
scaffold_android_project Scaffold Android project
Create a new minimal Jetpack Compose app project (single module, version catalog, Gradle wrapper included) ready to build with build_app.
| Parameter | Type | Description |
|---|---|---|
appName * | string | App name, e.g. 'My Notes' |
directory * | string | Directory to create the project in (must not exist or be empty) |
packageName * | string | Application id, e.g. 'com.example.mynotes' |