androidbuild-mcp

v0.1.1
io.github.dev-jackson/androidbuild-mcp Checked 9 hours ago Published 4 months ago

Build, 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.

ParameterTypeDescription
appIdstringApplication id (package name)
modulestringGradle module, e.g. 'app'
projectDirstringAbsolute path to the Gradle project root
serialstringadb device serial, e.g. emulator-5554
variantstringBuild 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.

ParameterTypeDescription
keysarrayKeys 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.

ParameterTypeDescription
searchPath *stringDirectory to search from
maxDepthintegerMax directory depth (default 3)

list_modules List Gradle modules

List modules declared in settings.gradle(.kts) of the project.

ParameterTypeDescription
projectDirstringProject 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').

ParameterTypeDescription
modulestringModule name, e.g. 'app' (defaults to session)
projectDirstringProject 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.

ParameterTypeDescription
modulestringModule name (defaults to session)
projectDirstringProject root (defaults to session)
variantstringVariant, 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, ...).

ParameterTypeDescription
projectDirstringProject 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.

ParameterTypeDescription
modulestringGradle module, e.g. 'app' (defaults to session)
projectDirstringProject root (defaults to session)
variantstringBuild 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.

ParameterTypeDescription
appIdstringApplication id to launch (defaults to session)
modulestringGradle module, e.g. 'app' (defaults to session)
projectDirstringProject root (defaults to session)
serialstringDevice serial (defaults to session or the only device)
variantstringBuild 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.

ParameterTypeDescription
modulestringGradle module, e.g. 'app' (defaults to session)
projectDirstringProject root (defaults to session)
testsstringFilter passed to --tests, e.g. 'com.foo.MyTest' or '*MyTest*'
variantstringBuild 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.

ParameterTypeDescription
modulestringGradle module, e.g. 'app' (defaults to session)
projectDirstringProject root (defaults to session)
variantstringBuild variant, e.g. 'debug' (defaults to session)

lint Run Android Lint

Run Android Lint (lint<Variant>) and return the textual report summary.

ParameterTypeDescription
modulestringGradle module, e.g. 'app' (defaults to session)
projectDirstringProject root (defaults to session)
variantstringBuild variant, e.g. 'debug' (defaults to session)

clean Clean build

Run gradle clean for the project.

ParameterTypeDescription
projectDirstringProject root (defaults to session)

get_apk_path Get APK path

Locate the most recent built APK for a module/variant without building.

ParameterTypeDescription
modulestringGradle module, e.g. 'app' (defaults to session)
projectDirstringProject root (defaults to session)
variantstringBuild 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).

ParameterTypeDescription
projectDirstringProject 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).

ParameterTypeDescription
apkPath *stringPath to the APK (from build_app / get_apk_path)
serialstringDevice serial (defaults to session or the only device)

launch_app Launch app

Launch an app by application id (resolves the launcher activity automatically).

ParameterTypeDescription
appIdstringApplication id (defaults to session)
serialstringDevice serial (defaults to session or the only device)

stop_app Stop app

Force-stop a running app (am force-stop).

ParameterTypeDescription
appIdstringApplication id (defaults to session)
serialstringDevice serial (defaults to session or the only device)

uninstall_app Uninstall app

Uninstall an app from a device/emulator.

ParameterTypeDescription
appIdstringApplication id (defaults to session)
serialstringDevice 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.

ParameterTypeDescription
appIdstringApplication id (defaults to session)
serialstringDevice 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.

ParameterTypeDescription
appIdstringApplication id (defaults to session)
serialstringDevice 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.

ParameterTypeDescription
avdName *stringAVD name from list_avds
timeoutSecondsintegerBoot timeout (default 180)
wipeDatabooleanFactory-reset the AVD (erases all data)

kill_emulator Kill emulator

Shut down a running emulator (adb emu kill).

ParameterTypeDescription
serialstringEmulator 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.

ParameterTypeDescription
name *stringName for the new AVD
devicestringDevice profile, e.g. 'pixel_7' (default: generic)
systemImagestringInstalled system-images package id

delete_avd Delete AVD

Delete an AVD permanently.

ParameterTypeDescription
name *stringAVD name to delete

set_emulator_location Set emulator location

Set the GPS location of a running emulator.

ParameterTypeDescription
latitude *numberLatitude in decimal degrees
longitude *numberLongitude in decimal degrees
serialstringEmulator 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).

ParameterTypeDescription
mode *stringAppearance to set
serialstringEmulator 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.

ParameterTypeDescription
enabled *booleantrue to enter demo mode, false to exit
clockstringClock as hhmm, e.g. '1200' (default 1200)
serialstringEmulator 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.

ParameterTypeDescription
serialstringEmulator serial (defaults to session or the only device)
timeLimitSecondsintegerAuto-stop after (default 180)

record_video_stop Stop screen recording

Stop a screen recording and pull the MP4 to the local machine.

ParameterTypeDescription
recordingId *stringId 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.

ParameterTypeDescription
appIdstringOnly capture logs of this app (defaults to session appId; must be running)
clearbooleanClear the log buffer first (default true)
serialstringDevice serial (defaults to session or the only device)
tagstringOnly 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.

ParameterTypeDescription
sessionId *stringSession id from start_log_capture
tailLinesintegerLines 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.

ParameterTypeDescription
appIdstringFilter to this app (defaults to session appId if running)
linesintegerMax lines (default 200)
serialstringDevice serial (defaults to session or the only device)
tagstringFilter to this log tag

get_crash_logs Get crash logs

Dump the crash log buffer (Java exceptions, native crashes, ANRs).

ParameterTypeDescription
linesintegerMax lines (default 300)
serialstringDevice 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.

ParameterTypeDescription
annotatebooleanDraw labeled bounding boxes around UI elements (vision-based)
serialstringDevice 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.

ParameterTypeDescription
filterstringOnly include elements whose text/desc/id contains this (case-insensitive)
serialstringDevice 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.

ParameterTypeDescription
serialstringDevice serial (defaults to session or the only device)
xintegerX in device pixels
xPctnumberX as fraction of screen width (0-1)
yintegerY in device pixels
yPctnumberY 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.

ParameterTypeDescription
element *integerElement number from the annotated screenshot
serialstringDevice 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.

ParameterTypeDescription
direction *string'down' reveals content below (finger moves up), 'up' reveals content above
amountnumberFraction of screen to scroll (default 0.5)
serialstringDevice 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.

ParameterTypeDescription
durationMsintegerPress duration (default 1000ms — launchers ignore shorter holds)
serialstringDevice serial (defaults to session or the only device)
xintegerX in device pixels
xPctnumberX as fraction of screen width (0-1)
yintegerY in device pixels
yPctnumberY 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.

ParameterTypeDescription
durationMsintegerSwipe duration (default 300ms)
serialstringDevice serial (defaults to session or the only device)
x1integerStart X in device pixels
x1PctnumberStart X as fraction of width (0-1)
x2integerEnd X in device pixels
x2PctnumberEnd X as fraction of width (0-1)
y1integerStart Y in device pixels
y1PctnumberStart Y as fraction of height (0-1)
y2integerEnd Y in device pixels
y2PctnumberEnd 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.

ParameterTypeDescription
durationMsintegerDrag duration (default 800ms)
serialstringDevice serial (defaults to session or the only device)
x1integerStart X in device pixels
x1PctnumberStart X as fraction of width (0-1)
x2integerEnd X in device pixels
x2PctnumberEnd X as fraction of width (0-1)
y1integerStart Y in device pixels
y1PctnumberStart Y as fraction of height (0-1)
y2integerEnd Y in device pixels
y2PctnumberEnd 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.

ParameterTypeDescription
text *stringText to type (ASCII)
clearbooleanClear the field before typing (select-all + delete)
serialstringDevice serial (defaults to session or the only device)
submitbooleanPress 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.

ParameterTypeDescription
key *stringKey name
serialstringDevice serial (defaults to session or the only device)

key_sequence Press key sequence

Press several keys in order (same names as key_press).

ParameterTypeDescription
keys *arrayKeys in press order
serialstringDevice 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.

ParameterTypeDescription
match *stringSubstring to look for in text, content-desc or resource-id
serialstringDevice serial (defaults to session or the only device)
timeoutSecondsintegerGive 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.

ParameterTypeDescription
modulestringModule (defaults to session)
projectDirstringProject root (defaults to session)
skipRunbooleanOnly parse an existing report without running Gradle
taskstringCoverage 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).

ParameterTypeDescription
file *stringSource file name, e.g. 'BookRepository.kt'
modulestringModule (defaults to session)
projectDirstringProject 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.

ParameterTypeDescription
appName *stringApp name, e.g. 'My Notes'
directory *stringDirectory to create the project in (must not exist or be empty)
packageName *stringApplication id, e.g. 'com.example.mynotes'