AndroidMCP Framework

io.github.kshivam1177由 GitHub 帳號 kshivam1177 發布v0.1.12更新於 Nov 2, 2026

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

概覽

AI 產生的概覽

本機 MCP 伺服器兼 CLI,讓編碼助理透過 adb 建置、安裝、啟動與測試 Android 或 Flutter 應用程式,並操作裝置介面。

可以做什麼
  • 列出已連線的模擬器與實機,並檢查 Android 開發環境
  • 建置 Gradle 模組與變體,安裝、啟動、停止、解除安裝應用程式或清除應用程式資料
  • 執行儀器化測試或 JVM 單元測試,並支援 Flutter 測試
  • 檢視並操作畫面:UI 快照、點擊、滑動、拖曳、輸入文字、按鍵、手勢、截圖與等待
  • 在裝置與本機之間傳輸檔案,並送出原始觸控事件
  • 管理工作階段預設值與設定檔,啟用或停用工作流程
適用情境
適合讓助理端到端處理 Android 或 Flutter 專案:編譯並部署到模擬器或已連線的手機,透過語意化 UI 自動化操作應用程式,並在同一個工作階段中執行或規劃測試。
執行需求
以 stdio 在本機執行,通常透過 npx 或全域 npm 安裝,因此需要 Node.js 與 npm。需要 Android SDK platform-tools(adb)、Java、Gradle 與 build-tools,裝置相關工具還需模擬器或 USB 連線的裝置;doctor 工具可檢查這些條件。未宣告任何 API 金鑰或環境變數。
安裝前請注意
工具會操作真實裝置:安裝、啟動、強制停止、解除安裝應用程式、清除應用程式資料、推送與拉取檔案、送出輸入事件。解除安裝或清除資料會銷毀應用程式狀態。截圖、UI 快照與測試報告會寫入專案的 .androidmcp-framework 目錄。setup 會在儲存庫中寫入設定與技能檔案,遷移會複製舊資料且不會刪除原目錄。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 AndroidMCP Framework,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

AndroidMCP Framework

A Model Context Protocol (MCP) server and CLI that gives coding agents Android development capabilities: build, install, and launch on emulators and physical devices; semantic UI automation; logcat/crash diagnostics; project discovery; change-aware testing intelligence.

Testing intelligence is enabled by default alongside device, ui-automation, session-management, doctor, and workflow-discovery. Tools such as analyze_test_project, audit_screen, save_test_case, and write_test_report are available without enabling another workflow. See workflow docs.

Install

bash
npm install -g androidmcp-framework@latestandroidmcp-framework doctor# Update to the latest global release and clear npm cacheamf update# Short alias (also installed by npm)amf doctor

Or run on demand with no global install: npx -y androidmcp-framework@latest mcp. The amf update command updates a global npm installation; if you use npx, rerun it with @latest to fetch the latest version. If an update is installed, the command clears only npm's _npx execution cache under the configured npm cache directory (normally ~/.npm/_npx on macOS/Linux); it does not clear the shared package-download cache.

Connect an MCP client

json
{  "mcpServers": {    "androidmcp-framework": {      "command": "npx",      "args": ["-y", "androidmcp-framework@latest", "mcp"]    }  }}

See coding agent setup for Claude Code, Codex, Gemini CLI, Antigravity, and VS Code/GitHub Copilot instructions. Android Studio's documented MCP client requires HTTP, while this server currently exposes stdio only; see supported clients.

Initialize an app project

From the Android or Flutter repository root:

bash
androidmcp-framework setup# Generate the agent skill later, without rerunning setupandroidmcp-framework skill-gen --agent claude

This creates .androidmcp-framework/config.yaml, asks which coding agent you use in an interactive terminal, and writes a project-local SKILL.md into that agent's skills folder. Supported choices include Claude Code, Codex, Gemini CLI, Antigravity, Cursor, GitHub Copilot, and a generic agent. Existing skill files are never overwritten. You can also run androidmcp-framework skill-gen or npx -y androidmcp-framework@latest skill-gen --agent codex independently. See coding-agent skills. If existing data remains under .android-build-mcp/ or .androidbuildmcp/, inspect it and run androidmcp-framework setup --migrate to copy files without overwriting existing content. The old directory is not deleted automatically.

All project-specific framework data is kept inside .androidmcp-framework/. Screenshots are saved under .androidmcp-framework/artifacts/screenshots/, raw accessibility hierarchy snapshots under .androidmcp-framework/artifacts/snapshots/, and other evidence under .androidmcp-framework/artifacts/. screenshot returns the absolute saved image path with the image; snapshot_ui saves the full tree and returns a compact summary by default. Test-case definitions and timestamped reports remain under testcases/ and test-reports/. The workspace root is discovered by walking upward to the nearest .androidmcp-framework/config.yaml or .git marker, with the current directory as fallback. Generated artifacts are local outputs and are ignored by Git by default.

Local checkout config

Build with npm ci && npm run build, then configure the MCP client to launch the built entry point build/cli/index.js mcp. Use an absolute path to your own checkout; do not copy machine-specific paths from examples.

How it's built

  • UI automation: JavaScript/TypeScript plus Android SDK platform-tools (adb) only. The optional Python uiautomator2 bridge has been removed; no Python runtime or scripts/ directory is required.
  • Device targeting: emulators and physical devices are unified through ADB. Explicit target, session default, then single connected target are tried in that order.
  • MCP transport: stdio for local coding agents. Streamable HTTP is not implemented yet.
  • Tools: one TypeScript module per tool under src/tools/<workflow>/.

Development

bash
npm cinpm run buildnpm run typechecknpm test

TypeScript compiles from src/ to generated build/. Do not commit generated build/ or stale dist/ output.

Testing framework

The testing-intelligence workflow is enabled by default: it analyzes Native Android and Flutter workspaces, discovers nested Flutter packages, saves custom instructions and test cases, audits screens, and writes timestamped Markdown/JSON reports under .androidmcp-framework/test-reports/YYYY-MM-DD/HHmmss/. test_device routes Flutter unit/widget tests through flutter test (kind: "unit") and can run device integration tests with flutter test -d <device-id> integration_test when integration_test/ exists. See Testing Framework, Autonomous test intelligence and execution reliability, Change-aware autonomous test planning, Unified E2E run and device regression, Phases 11–15, Phases 16–20, and Phases 24–30, and Phases 31–40, and Phases 41–50, and Phases 51–60. validate_test_evidence_bundle checks multiple reports for freshness, matching Git HEAD provenance, clean working-tree state, required suites, and passing outcomes. The run_unified_test_run tool coordinates selected native/Flutter suites and saved UI cases under one resumable run ID and writes one strict-gated report. The inspect_test_runtime tool provides a read-only overview of project config, run-lock metadata, resumable manifests, and the latest report. The plan_change_aware_test_run tool connects Git changes, saved test cases, project instructions, and recent failures to produce a reviewable plan and identify unmapped changed files without executing tests. The analyze_test_quality tool combines test-matrix inventory, changed-file LCOV coverage, historical flaky-test signals, and optional baseline regression comparison in one read-only report. evaluate_test_quality_gate applies optional changed-file coverage thresholds and baseline regression policy. run_test_suite_matrix previews or sequentially executes selected project-native Flutter/Gradle suites, with execution opt-in and timestamped evidence.

Runtime selector maintenance is also available through approve_selector_repair: it validates a proposed selector against a fresh accessibility hierarchy, requires explicit approval before changing a saved test, creates a backup and audit record, and still requires a real rerun for pass/fail evidence. See runtime-verified selector repair.

License

MIT

Autonomous test lifecycle

For the recommended change-aware flow from Git analysis through reviewed test candidates, explicit approval, unified execution, and evidence-backed reporting, see Autonomous test lifecycle. The framework keeps candidate, approved, and executed states separate and falls back to broad regression when explicit test mappings do not cover changed files.

來源:README.md,提交 c67e69c

工具

30

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.

輸入參數modulevariantextraArgsprojectPath

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.

輸入參數modulevariantactivitytargetIdextraArgsprojectPath

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.

輸入參數moduleapkPathvarianttargetIdreinstallprojectPath

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.

輸入參數modulevariantactivitytargetIdpackageIdprojectPath

stop_app_device

Stop App

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

輸入參數targetIdpackageId必填

uninstall_app_device

Uninstall App

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

輸入參數keepDatatargetIdpackageId必填

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.

輸入參數targetIdpackageId必填

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.

輸入參數kindmodulevarianttargetIdextraArgsprojectPath

push_file_device

Push File

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

輸入參數targetIdlocalPath必填remotePath必填

pull_file_device

Pull File

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

輸入參數targetIdlocalPath必填remotePath必填

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.

輸入參數targetIdprojectPathinteractiveOnly

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.

輸入參數xytargetIdelementRef

long_press

Long Press

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

輸入參數xytargetIddurationMselementRef

swipe

Swipe

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

輸入參數endXendYstartXstartYdistancetargetIddirectiondurationMs

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.

輸入參數endXendYstartXstartYtargetIddurationMsendElementRefstartElementRef

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.

輸入參數text必填targetIdelementRef

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.

輸入參數keyCode必填targetId

button

Hardware Button

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

輸入參數button必填targetId

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

輸入參數preset必填targetId

screenshot

Screenshot

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

輸入參數targetIdoutputPathprojectPath

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").

輸入參數gonetargetIdtimeoutMsresourceIdtextContainspollIntervalMs

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.

輸入參數steps必填targetId

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.

輸入參數x必填y必填action必填targetId

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.

輸入參數moduleavdNamevarianttargetIdprojectPathapplicationIdgradleTaskPrefix

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.

輸入參數profile

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.

輸入參數profile必填

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.

輸入參數actionworkflowName

版本歷史

1
  1. v0.1.12最新Oct 26, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分