Skip to main content
Glama
android-mcp-server

android-mcp-server

by Shekhar23

android-mcp-server

CI License: MIT

An MCP server that gives Claude Code, and any other MCP client, access to your Android device and build. It can read logcat, pull crash stack traces and ANRs, run Gradle tasks, install APKs and take screenshots.

"The app crashes when I open settings. Find out why and fix it."

Claude can now do the whole loop itself: launch the app, read the crash, open the file, fix it, rebuild, reinstall and confirm it's gone.

All screenshots were captured by the server's own screenshot tool on an Android emulator.

Why

Debugging Android with an AI assistant usually means copying logcat into the chat by hand. Logcat is noisy, stack traces get cut off, ANR traces are buried in dumpsys dropbox, and Gradle errors sit at the bottom of 2,000 lines of output. This server turns each of those into a tool call that returns structured, trimmed results.

Related MCP server: phone-control

Tools

Tool

What it does

list_devices

Connected devices and emulators with state and model

logcat

Recent logs, filtered by app package (its PID), minimum priority, tag or text

get_crashes

One record per FATAL EXCEPTION from the crash buffer, with process and full stack trace

list_anrs

ANRs from the system dropbox, with subject and the main thread stack

gradle_build

Runs any task with the project's gradlew. Returns compiler errors, "What went wrong" and the output tail

launch_app

Starts an app's launcher activity

screenshot

Device screen as a PNG image

install_apk

adb install -r an APK

clear_logcat

Clears the main, system and crash buffers so the next read shows only new output

adb_shell

Runs any adb shell command

Start the server with --read-only to turn off install_apk, clear_logcat and adb_shell.

What the tools return

Real output from an emulator run.

get_crashes: one record per FATAL EXCEPTION, with the full stack trace instead of a truncated logcat paste.

get_crashes output

gradle_build: a failing build reduced to the part that matters, instead of 2,000 lines of Gradle output.

gradle_build output

logcat: only the lines from the app's running process.

logcat output

list_anrs output

list_devices output

Install

Requirements: Node 20+, and adb (Android SDK platform-tools) on PATH or in $ANDROID_HOME/platform-tools.

git clone https://github.com/shekharpande/android-mcp-server
cd android-mcp-server
npm install && npm run build

Claude Code

claude mcp add android -- node /absolute/path/to/android-mcp-server/dist/index.js
# or read-only:
claude mcp add android -- node /absolute/path/to/android-mcp-server/dist/index.js --read-only

Claude Desktop, Cursor and other MCP clients

{
  "mcpServers": {
    "android": {
      "command": "node",
      "args": ["/absolute/path/to/android-mcp-server/dist/index.js"]
    }
  }
}

Using it with your app

1. Connect a device or emulator

Start an emulator from Android Studio's Device Manager, or from the command line:

emulator -list-avds          # names of your virtual devices
emulator -avd Pixel_8 &      # start one

A physical phone works too: turn on Developer options → USB debugging and plug it in, or use Wireless debugging and adb pair / adb connect. Check that it shows up:

adb devices
# emulator-5554   device

If more than one device is connected, tell Claude which one to use (e.g. "use emulator-5554"). Every tool takes an optional serial.

2. Find your app's package name

Tools that target an app need its package name (the applicationId), not the app's display name:

grep applicationId app/build.gradle*        # from your project
adb shell pm list packages -3               # apps you installed on the device

Debug builds often have a suffix such as .debug, so com.example.app installs as com.example.app.debug. Use the name that's actually installed.

3. Open Claude Code in your app's project

cd ~/AndroidStudioProjects/MyApp
claude

Starting Claude in the project folder lets it read and edit your source, and pass the right projectDir to gradle_build. Run /mcp to check that the android server is connected.

4. Ask in plain language

Claude picks the tools for you. Some prompts that work well:

Goal

Prompt

Fix a crash

"Launch com.example.app, open the settings screen, then use get_crashes to find out why it crashes and fix it."

Investigate a crash that already happened

"Check get_crashes for com.example.app and explain the most recent one."

Build, install and run

"Build the debug APK, install it on the emulator and launch it. Take a screenshot when it's open."

Fix build errors

"Run assembleDebug and fix whatever fails."

Run tests or lint

"Run testDebugUnitTest and fix the failing tests." / "Run lint and fix the errors."

Debug a freeze

"The app froze earlier. Check list_anrs for com.example.app and tell me what the main thread was blocked on."

Read logs

"Show me warnings and errors from com.example.app's logcat since I tapped Login."

Check the UI

"Take a screenshot and tell me if the layout looks broken."

A typical fix loop

  1. Reproduce: clear_logcat, then launch_app, then trigger the bug yourself on the device or tell Claude what to tap via adb_shell input ....

  2. Diagnose: get_crashes (or list_anrs / logcat) returns the exception and stack trace. Claude maps the frames to files in your project.

  3. Fix: Claude edits the source.

  4. Verify: gradle_build (assembleDebug), install_apk with app/build/outputs/apk/debug/app-debug.apk, then launch_app again. Claude repeats the steps and confirms with get_crashes that the crash is gone.

Tips

  • logcat with package only sees a running app. It filters by the app's current process ID. If the app has crashed or isn't open, launch it first, or leave out package and use grep instead.

  • Clear before reproducing. Run clear_logcat first so get_crashes and logcat only show what happened during this attempt.

  • The first Gradle build is slow. A cold build can take several minutes while Gradle downloads dependencies. Later builds use the cache. Raise timeoutMinutes for big projects.

  • Use --read-only on a personal phone. It still lets Claude read logs, crashes and screenshots, but not install apps or run shell commands.

  • Release builds: stack traces from minified (R8/ProGuard) builds are obfuscated. Debug builds give readable traces.

Configuration

Env var

Default

Purpose

ADB_PATH

$ANDROID_HOME/platform-tools/adb, then adb

adb binary to use

ANDROID_MCP_READ_ONLY

unset

Set to 1 to do the same as --read-only

ANDROID_MCP_MAX_OUTPUT

40000

Max characters returned per tool call (longer output is cut, keeping the end)

Architecture

Architecture

  • exec.ts runs every command through execFile with an argument array. Nothing goes through sh on the host, so tool arguments can't inject host commands.

  • parsers.ts contains pure functions that turn adb devices -l, the crash buffer, dumpsys dropbox and Gradle output into typed records. They are unit-tested without a device.

  • tools.ts registers the tools, validates input with zod (package names, Gradle task names and flags are checked with regexes) and keeps output within the context budget.

Safety notes

  • adb_shell runs whatever command it's given on the device. Your MCP client asks for approval before each call, but use --read-only if you don't want that tool available at all.

  • gradle_build only runs the gradlew in the directory you pass. Task names and flags are restricted to safe characters.

Development

npm test          # parser unit tests (vitest)
npm run typecheck
npm run dev       # tsc --watch

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables MCP-compatible agents to control an Android device over the network via ADB, providing tools for shell commands, screen capture, UI inspection, file operations, and input simulation.
      11 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables controlling an Android device from an MCP client via ADB, including wireless debugging discovery, UI-tree inspection, and performing taps, swipes, typing, app actions, and shell commands without relying on screen coordinates.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables coding agents to build, install, and launch Android apps on emulators and physical devices, automate UI interactions, inspect logcat/crash diagnostics, measure JaCoCo coverage, and discover or scaffold projects through an MCP server.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP clients to control an Android phone by reading the screen, taking screenshots, tapping, typing, swiping, opening apps, and running multi-step tasks. It also supports on-device Android app testing and optional adb commands.
      2,285 npm
      9
      MIT