AndroidMCP Framework

v0.1.12
io.github.kshivam1177/androidmcp-framework Checked 14 hours ago Published 1 month ago

MCP server and CLI for Android development and change-aware Android and Flutter testing workflows.

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

list_devices List Devices

List every connected Android target - booted emulators and physical devices together, the same way `adb devices -l` does. Each entry reports id (adb serial), type ('emulator'|'physical'), state, and avdName when resolvable.

build_device Build (Device)

Compile-only build for a Gradle module + variant (assemble<Variant>). Does not install or launch. Works identically whether you plan to target an emulator or a physical device - both use the same adb, unlike Xcode's simulator/device split.

ParameterTypeDescription
extraArgsarrayExtra raw Gradle CLI args, e.g. ["--stacktrace"].
modulestringGradle module path, e.g. ":app". Falls back to sessionDefaults.module.
projectPathstringGradle project root. Falls back to sessionDefaults.projectPath.
variantstringBuild variant, e.g. "debug" or "devDebug". Falls back to sessionDefaults.variant.

build_run_device Build, Install, and Launch

One-shot: build a module + variant, install it, and launch it. Resolves the target automatically - an explicit targetId wins, then the active session default, then whichever single emulator/device is connected; if more than one is connected without a pin, this fails with the candidate list instead of guessing. Launches via the default launcher activity unless `activity` is given.

ParameterTypeDescription
activitystringFully-qualified activity to launch, e.g. "com.example.app.MainActivity". Defaults to the app's launcher activity.
extraArgsarray
modulestring
projectPathstring
targetIdstringadb serial. Auto-resolved if omitted.
variantstring

install_app_device Install App

Install an already-built APK for a module + variant onto the resolved target. Does not rebuild - run build_device first if sources changed. Pass apkPath directly to skip variant lookup entirely.

ParameterTypeDescription
apkPathstringExplicit path to a .apk, bypassing module/variant lookup.
modulestring
projectPathstring
reinstallbooleanPass -r to adb install to keep existing app data. Default true.
targetIdstring
variantstring

launch_app_device Launch App

Launch an already-installed app on the resolved target. Provide packageId directly, or module/variant to look it up from the last build's APK. Uses the app's default launcher activity unless `activity` is given.

ParameterTypeDescription
activitystring
modulestring
packageIdstringApplication id, e.g. "com.example.app". Resolved from the built APK if omitted.
projectPathstring
targetIdstring
variantstring

stop_app_device Stop App

Force-stop a running app on the resolved target (adb shell am force-stop).

ParameterTypeDescription
packageId *stringApplication id, e.g. "com.example.app".
targetIdstring

uninstall_app_device Uninstall App

Uninstall an app (and its data) from the resolved target.

ParameterTypeDescription
packageId *string
keepDatabooleanPass -k to adb uninstall to keep app data/cache. Default false.
targetIdstring

clear_app_data_device Clear App Data

Reset an app to first-install state on the resolved target (adb shell pm clear) - wipes the app's data and cache without uninstalling it.

ParameterTypeDescription
packageId *string
targetIdstring

test_device Test (Device)

Run tests for a module + variant. `instrumented` (default) runs connected<Variant>AndroidTest against the resolved target via ANDROID_SERIAL - needs an emulator or device attached. `unit` runs test<Variant>UnitTest on the JVM instead and needs no target at all.

ParameterTypeDescription
extraArgsarray
kindstringDefaults to "instrumented".
modulestring
projectPathstring
targetIdstring
variantstring

push_file_device Push File

Copy a local file or directory onto the resolved target (adb push).

ParameterTypeDescription
localPath *string
remotePath *string
targetIdstring

pull_file_device Pull File

Copy a file or directory off the resolved target onto the local filesystem (adb pull).

ParameterTypeDescription
localPath *string
remotePath *string
targetIdstring

snapshot_ui Snapshot UI

Capture a semantic UI hierarchy for the current screen - every element gets a short-lived elementRef (e1, e2, ...) that tap/long_press/type_text can target directly. Saves the captured hierarchy as JSON under .androidmcp-framework/artifacts/ui-snapshots/ by default.

ParameterTypeDescription
interactiveOnlybooleanDefault true: only clickable/focusable/scrollable/checkable elements or ones with text/content-desc. false returns the full raw tree.
projectPathstringProject root for the saved JSON snapshot; defaults to the current working directory.
targetIdstring

tap Tap

Tap either a raw (x, y) point or an elementRef from the latest snapshot_ui output. Prefer elementRef - it survives minor layout shifts that would break a hard-coded coordinate.

ParameterTypeDescription
elementRefstring
targetIdstring
xnumber
ynumber

long_press Long Press

Long-press either a raw (x, y) point or an elementRef from the latest snapshot_ui output.

ParameterTypeDescription
durationMsnumberDefault 600.
elementRefstring
targetIdstring
xnumber
ynumber

swipe Swipe

Swipe either by explicit start/end coordinates, or a screen-relative direction ("up"|"down"|"left"|"right") computed from the current screen size.

ParameterTypeDescription
directionstring
distancenumberScreen-relative distance for direction mode, 0-1. Default 0.6.
durationMsnumberDefault 300.
endXnumber
endYnumber
startXnumber
startYnumber
targetIdstring

drag Drag

Press-and-drag from one point to another (adb shell input draganddrop) - for reordering list items or drag targets, where a quick swipe would be interpreted as a flick instead of a hold-and-move. Endpoints can be elementRefs from the latest snapshot_ui, or raw coordinates.

ParameterTypeDescription
durationMsnumberDefault 800.
endElementRefstring
endXnumber
endYnumber
startElementRefstring
startXnumber
startYnumber
targetIdstring

type_text Type Text

Type text into whatever field currently has focus. If elementRef is given, taps it first to focus it, then types. Only ASCII-range and common Latin text renders reliably through adb input text - non-Latin scripts and emoji generally need an IME-level workaround this tool does not attempt.

ParameterTypeDescription
text *string
elementRefstringTapped first to focus, if given.
targetIdstring

key_press Key Press

Send one hardware/software key event (adb shell input keyevent). Accepts either a symbolic Android keycode name (KEYCODE_BACK, KEYCODE_ENTER, KEYCODE_DEL, KEYCODE_TAB) or its numeric code. Prefer button for common hardware buttons (home/back/recents/power/volume) - it maps friendly names for you.

ParameterTypeDescription
keyCode *stringe.g. "KEYCODE_ENTER" or "66".
targetIdstring

button Hardware Button

Press a named hardware/system button: home, back, recents, power, volume_up, volume_down, menu, enter, camera.

ParameterTypeDescription
button *string
targetIdstring

gesture Gesture Preset

Named system gesture presets: expand_notifications, expand_quick_settings, collapse_statusbar (all via `cmd statusbar`, no coordinates needed), swipe_up_from_bottom (home/app-switcher gesture-nav swipe), swipe_down_from_top (notification-shade swipe as an alternative to expand_notifications on older API levels).

ParameterTypeDescription
preset *string
targetIdstring

screenshot Screenshot

Capture the current screen, return it as an image, and save a copy under .androidmcp-framework/artifacts/screenshots/ by default.

ParameterTypeDescription
outputPathstringOptional explicit screenshot file path. Defaults to the project artifacts folder.
projectPathstringProject root for the saved screenshot; defaults to the current working directory.
targetIdstring

wait_for_ui Wait For UI

Poll the UI until a condition holds, then record the latest snapshot (same caching as snapshot_ui - refs from the result are usable directly). With textContains/resourceId: waits for a matching element to appear (or disappear, if gone:true). With neither: waits for the hierarchy to stop changing between polls ("settled").

ParameterTypeDescription
gonebooleanWait for absence instead of presence. Default false.
pollIntervalMsnumberDefault 500.
resourceIdstring
targetIdstring
textContainsstring
timeoutMsnumberDefault 10000.

batch Batch

Run several same-screen UI actions in one call, resolving the target once and reusing it for every step. Use for multiple taps/toggles with no intermediate assertion needed - if you need to check state between steps, call the individual tools instead so you can inspect each result.

ParameterTypeDescription
steps *array
targetIdstring

touch Touch (raw down/up/move)

Send a raw touch event (adb shell input motionevent) rather than a full tap/swipe gesture. Use for composing custom multi-point sequences - e.g. DOWN, several MOVEs, then UP - that the higher-level tap/swipe/drag tools don't expose.

ParameterTypeDescription
action *string
x *number
y *number
targetIdstring

session_show_defaults Show Session Defaults

Show the active session-default profile and its resolved values (config.yaml sessionDefaults, overlaid with any runtime overrides from session_set_defaults). Call this before your first build/run/test call in a session - do not assume defaults are configured.

session_set_defaults Set Session Defaults

Set one or more session defaults for the active profile at runtime (in-memory + persisted under the state dir for this profile - not written back to config.yaml). Only the fields you pass are changed; everything else stays as-is.

ParameterTypeDescription
applicationIdstring
avdNamestring
gradleTaskPrefixstring
modulestring
projectPathstring
targetIdstring
variantstring

session_clear_defaults Clear Session Defaults

Clear runtime overrides for the active profile (or a named one) - falls back to config.yaml's static sessionDefaults on the next read, not to nothing.

ParameterTypeDescription
profilestring

session_use_defaults_profile Switch Session Defaults Profile

Switch the active session-defaults profile - useful in a monorepo with several Gradle projects, so each can keep its own remembered projectPath/module/variant/targetId without overwriting the others.

ParameterTypeDescription
profile *string

doctor Doctor

Check Android development prerequisites: adb, Java, Gradle, Android SDK, emulator, build-tools and the optional Google Android CLI integration. This framework does not require Python.

manage_workflows Manage Workflows

List every workflow and which of its tools are currently enabled, or enable/disable a workflow for this running server session. Session-only - it does not edit .android-build-mcp/config.yaml, so restart-persistent changes still belong in enabledWorkflows there.

ParameterTypeDescription
actionstringDefault "list".
workflowNamestringRequired for enable/disable.