Android Studio MCP

Android Studio MCP

Enables Claude to operate Android Studio and the entire Android toolchain: build, test, lint, run on devices/emulators, analyze APKs, scaffold projects, inspect code, and drive the live IDE via 73 tools.

Category
访问服务器

README

<div align="center">

Android Studio MCP

Let Claude operate Android Studio and the entire Android toolchain — not just talk about it.

A professional Model Context Protocol server that turns Claude (Claude Code / Claude Desktop) into a real Android operator: build, test, lint, run on devices & emulators, analyse APKs, scaffold projects, inspect code headlessly, and drive the live IDE.

Platform Python FastMCP Tools License

</div>


Why this exists

Android Studio is an IntelliJ‑based IDE. The reliable way to operate it programmatically is not to pixel‑click the GUI — it's to drive the same tools the IDE drives. This server is built stable‑first: the bulk of the power comes from the rock‑solid command‑line toolchain, with the live‑IDE bridge and UI automation as additional layers that degrade gracefully.

Layer Mechanism Covers Robustness
1. Build / SDK CLI gradlew, adb, emulator, avdmanager, sdkmanager, apkanalyzer, apksigner, aapt2, bundletool build, test, lint, deps, signing, devices, emulators, APK/AAB analysis ★★★★★ headless, deterministic
2. Headless IDE CLI studio64.exe inspect / format / diff, open project/file full code inspection reports, reformat, navigation ★★★★☆
3. Live IDE built‑in HTTP server (:63342) + stdioMcpServer MCP bridge open‑in‑IDE, IDE state, IDE actions — while the IDE runs ★★★☆☆
4. UI fallback native Win32 focus + SendKeys + screenshot any action via "Find Action", visual verification ★★☆☆☆

Everything in layers 1–2 works whether or not the IDE is open and needs no plugins.


Highlights

  • 🟢 One‑shot "Run" buttonas_run_app: build → install → launch → capture logs → detect crashes → screenshot, in a single call.
  • 🔨 Full Gradle control — assemble APK/AAB, unit & instrumented tests, lint, dependencies, signing report — with structured findings (lint XML & JUnit XML parsed into file/line/severity).
  • 🩺 Self‑healing builds — failing builds return a remediation list mapping the error to the exact next tool to call (license → accept, missing platform → install, no device → start emulator).
  • 📱 Devices & emulators — list/create/start/stop AVDs, install/uninstall, streaming logcat you can poll, screenshots, screen recording, input injection.
  • 🏗️ Project scaffolding — generate a real, buildable Views or Compose project (bundled Gradle wrapper, correct AGP/Kotlin/SDK levels).
  • 🔍 Headless code inspection — run the IDE's offline "Inspect Code" engine and get structured problems back.
  • 📦 APK / AAB analysis — package/version/permissions, method counts, sizes, signature verification, APK diff, AAB → installable APK set.
  • 🔒 Safety‑first — workspace path allow‑list, confirmation gating for destructive actions, automatic backups, secret redaction, hardened device‑shell.
  • 🧪 Tested — 73 tools, real APK built end‑to‑end, 15 parser unit tests, security‑gate regression, adversarial multi‑agent code review.

Requirements

  • Windows (the server is Windows‑targeted; paths and process control use Win32).
  • Android Studio (tested against build AI‑261, 2026.1.x) — autodiscovered at C:\Program Files\Android\Android Studio.
  • Android SDK with command‑line tools, platform‑tools, emulator and build‑tools — autodiscovered at %LOCALAPPDATA%\Android\Sdk.
  • Python ≥ 3.10 and uv.

All paths are autodiscovered but can be overridden (see Configuration).


Install

git clone https://github.com/MauricePutinas/Android-Studio-MCP-Claude-Code.git
cd Android-Studio-MCP-Claude-Code
uv sync

# sanity checks
uv run python -m android_studio_mcp --selfcheck     # resolved paths + tool count
uv run python -m android_studio_mcp --list-tools    # all 73 tools
uv run python scripts/smoke_test.py                 # 17/17 functional checks
uv run pytest tests -q                              # 15 parser unit tests

Wire into Claude

Claude Desktop%APPDATA%\Claude\claude_desktop_config.json:

{
  "mcpServers": {
    "android-studio": {
      "command": "C:\\Users\\<you>\\AppData\\Local\\hermes\\bin\\uv.exe",
      "args": ["--directory", "C:\\path\\to\\Android-Studio-MCP-Claude-Code", "run", "python", "-m", "android_studio_mcp"]
    }
  }
}

Claude Code (CLI):

claude mcp add android-studio --scope user -- uv --directory "C:\path\to\Android-Studio-MCP-Claude-Code" run python -m android_studio_mcp

One‑click bundle: build a .mcpb with powershell -File scripts\build_mcpb.ps1 and install it via Claude Desktop → Settings → Extensions → Install extension. See docs/CLAUDE_SETUP.md and docs/PACKAGING.md.

Note: the committed manifest.json / example configs are pre‑filled for the author's machine. Adjust the two absolute paths (project dir, uv.exe) to your setup.


Tool catalogue (73 tools)

All tools are prefixed as_ and return JSON with a status (ok | error | confirmation_required) and a human summary. Destructive tools require confirm=true.

<details open> <summary><b>Lifecycle & navigation</b></summary>

as_status · as_is_running · as_launch · as_close · as_restart · as_open_project · as_open_file · as_diff </details>

<details> <summary><b>Run & background processes</b></summary>

as_run_app (build→install→launch→logs→crash→screenshot) · as_logcat_watch_start / as_logcat_watch_read / as_logcat_watch_stop · as_proc_list / as_proc_stop </details>

<details> <summary><b>Gradle (build / test / lint)</b></summary>

as_gradle_tasks · as_gradle_assemble · as_gradle_bundle · as_gradle_test (structured JUnit) · as_gradle_lint (structured findings) · as_gradle_clean · as_gradle_dependencies · as_gradle_signing_report · as_gradle_run_task · as_gradle_stop </details>

<details> <summary><b>SDK manager</b></summary>

as_sdk_list · as_sdk_install · as_sdk_accept_licenses </details>

<details> <summary><b>Emulators / AVDs</b></summary>

as_avd_list · as_avd_create · as_avd_delete · as_avd_start · as_avd_stop </details>

<details> <summary><b>Devices (ADB)</b></summary>

as_adb_devices · as_adb_install · as_adb_uninstall · as_adb_logcat · as_adb_logcat_clear · as_adb_shell (guarded) · as_adb_screenshot · as_adb_input · as_adb_start_app · as_adb_stop_app · as_adb_pull · as_adb_push </details>

<details> <summary><b>Projects</b></summary>

as_project_create (real Views/Compose scaffold) · as_project_info (incl. version catalog) · as_project_validate · as_project_backup · as_project_list_recent </details>

<details> <summary><b>APK / AAB analysis</b></summary>

as_apk_info · as_apk_methods · as_apk_filesize · as_apk_verify_signature · as_apk_compare · as_aab_build_apks · as_aab_install </details>

<details> <summary><b>Headless IDE analysis</b></summary>

as_inspect_code (offline "Inspect Code" → structured problems) · as_format_code (reformat in place, backups first) </details>

<details> <summary><b>Extras</b></summary>

as_retrace (de‑obfuscate R8/ProGuard stack traces) · as_screenrecord (record device screen → mp4) </details>

<details> <summary><b>Live IDE bridge</b></summary>

as_ide_status · as_ide_list_mcp_tools · as_ide_call_mcp_tool </details>

<details> <summary><b>Native UI fallback</b></summary>

as_ui_screenshot · as_ui_focus · as_ui_send_keys · as_ui_invoke_action (any IDE action via "Find Action") </details>

<details> <summary><b>Reports / logs / safety</b></summary>

as_report_health · as_logs_ide · as_logs_mcp · as_config · as_backup_file · as_restore_backup </details>

Resources: asmcp://config · asmcp://idea-log · asmcp://projects/recent Prompts: run_app · diagnose_build


Safety model

  • Path allow‑list — write/delete operations must target a path inside a configured workspace root (default: E:\Projekte + home). Override with ASMCP_WORKSPACE_ROOTS.
  • Confirmation gating — destructive tools (as_close --force, as_adb_uninstall, as_avd_delete, as_format_code, as_sdk_install, as_restore_backup, …) return confirmation_required unless called with confirm=true.
  • Backups first — files are backed up before being reformatted/overwritten; projects can be zipped with as_project_backup.
  • Guarded device shellas_adb_shell runs recognised read‑only commands freely but requires confirm=true for anything containing shell operators (;, |, &&, $(), …) or destructive markers.
  • Secret redaction — keystore/store/key passwords and tokens are masked in all captured output and logs.
  • stdio‑safe logging — all logs go to stderr + a rotating file, never stdout.

Configuration

Resolution order for every setting: env var → config.json → autodiscovery → default.

Setting Env var Default
Android Studio home ASMCP_STUDIO_HOME / STUDIO_HOME C:\Program Files\Android\Android Studio
Android SDK ASMCP_ANDROID_SDK / ANDROID_HOME / ANDROID_SDK_ROOT %LOCALAPPDATA%\Android\Sdk
Workspace roots (allow‑list) ASMCP_WORKSPACE_ROOTS (;‑separated) E:\Projekte;%USERPROFILE%
Built‑in server port ASMCP_BUILTIN_SERVER_PORT 63342
bundletool jar ASMCP_BUNDLETOOL auto‑downloaded on first use

See config.example.json.


Architecture

src/android_studio_mcp/
├── app.py            FastMCP instance
├── config.py         toolchain autodiscovery + settings
├── runner.py         safe subprocess execution (env, .bat, timeouts, redaction)
├── safety.py         path allow‑list, confirmation gating, backups
├── procregistry.py   background process registry (logcat watch, …)
├── parsers.py        Gradle / ADB / AVD / SDK / aapt output parsers
├── report_parsers.py lint XML, JUnit XML, version catalog
├── diagnostics.py    build‑failure → remediation rules
├── scaffold.py       project templates (Views / Compose)
├── ide_http.py       built‑in IDE server (:63342) client
├── mcp_bridge.py     stdioMcpServer bridge
├── winauto.py        native Win32 UI automation
└── tools/            73 @mcp.tool definitions, grouped by domain

Testing

Suite What Result
scripts/smoke_test.py env checks, gating, path allow‑list, scaffold round‑trip 17/17
scripts/build_test.py real gradlew assembleDebug → signed APK → analysis BUILD SUCCESSFUL
scripts/security_test.py adb‑shell injection/chaining gate 6/6
pytest tests pure parser functions 15/15
evals/android_studio_eval.xml 10 read‑only eval Q&A (mcp‑builder format)

A full capability/risk matrix is in docs/QUALITY.md.


Limitations

  • The official live‑IDE MCP (stdioMcpServer) needs the MCP Server plugin (com.intellij.mcpServer). On a stock Android Studio it may not be installed — as_ide_status tells you, and the CLI tools cover everything regardless.
  • Headless inspect indexes the project first, so it can take minutes; don't run it while the same project is open in a running IDE (config‑dir contention).
  • UI automation (SendKeys) is best‑effort and English‑keymap oriented; always verify via the returned screenshot.
  • The server is Windows‑only by design.

License

MIT © Maurice Putinas — see LICENSE.

Built with FastMCP. Not affiliated with Google or JetBrains. "Android" and "Android Studio" are trademarks of Google LLC.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选