Android MCP Server
# Android MCP Server
> π€ An MCP (Model Context Protocol) server designed for Android development, enabling AI assistants to directly control Android devices for screenshots, UI analysis, app management, and more.
[δΈζζζ‘£](./README_zh.md)
---
## Table of Contents
- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Configuration](#configuration)
- [Tools](#tools)
- [Debugging](#debugging)
- [References](#references)
---
## Introduction
This project is built on the [FastMCP](https://github.com/jlowin/fastmcp) framework and communicates with Android devices via ADB (Android Debug Bridge). It exposes **19 practical tools** to AI assistants (such as Claude, CodeBuddy, etc.), covering the complete Android development and debugging workflow:
```
Screenshot β UI Analysis β Interaction β Logcat β App Management β File Transfer
```
---
## Prerequisites
- Python >= 3.11
- [uv](https://docs.astral.sh/uv/) package manager
- ADB installed and added to PATH (`adb --version` works)
- Android device connected or emulator running (`adb devices` recognizes it)
- **USB Debugging** enabled on the Android device
---
## Installation
```bash
# Clone the project
git clone https://github.com/huarangmeng/AndroidMcpServer
cd AndroidMcpServer
# Install dependencies
uv sync
```
**Dependencies**
| Package | Version | Purpose |
|---|---|---|
| `mcp[cli]` | >= 1.2.0 | MCP framework |
| `Pillow` | >= 10.3.0 | Screenshot processing |
---
## Configuration
### CodeBuddy
Add the following to `~/.codebuddy/mcp.json`:
```json
{
"mcpServers": {
"android_mcp": {
"command": "/Users/<your-username>/.local/bin/uv",
"args": [
"run",
"--project", "/path/to/AndroidMcpServer",
"python",
"/path/to/AndroidMcpServer/main.py",
"--mode", "stdio",
"--temp-dir", "/tmp/android_mcp"
],
"transportType": "stdio"
}
}
}
```
### Claude Desktop
Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
```json
{
"mcpServers": {
"android_mcp": {
"command": "uv",
"args": [
"run",
"--project", "/path/to/AndroidMcpServer",
"python",
"/path/to/AndroidMcpServer/main.py",
"--mode", "stdio",
"--temp-dir", "/tmp/android_mcp"
]
}
}
}
```
### HTTP Mode
```bash
# Start HTTP server
uv run main.py --mode streamable-http --temp-dir /tmp/android_mcp --port 3001
# Service URL: http://localhost:3001/mcp
```
---
## Tools
A total of **19 tools** in 5 categories:
### πΈ Screenshot & UI Analysis
| Tool | Description |
|---|---|
| `get_screenshot` | Capture device screenshot (auto-scaled to 50%) |
| `get_ui_dump` | Get XML UI hierarchy with attribute filtering |
### π±οΈ Interaction
| Tool | Parameters | Description |
|---|---|---|
| `tap_screen` | `x`, `y` | Tap at coordinates |
| `swipe_screen` | `x1`,`y1`,`x2`,`y2`,`duration_ms` | Swipe gesture |
| `long_press` | `x`, `y`, `duration_ms` | Long press |
| `send_text` | `text_to_send` | Send text to focused input (English only) |
| `perform_system_action` | `action` | System keys: BACK / HOME / RECENT_APPS |
### π± App Management
| Tool | Parameters | Description |
|---|---|---|
| `launch_app` | `package_name` | Launch app |
| `force_stop_app` | `package_name` | Force stop app |
| `clear_app_data` | `package_name` | Clear app data |
| `install_apk` | `apk_path`, `replace_existing` | Install APK |
| `get_app_list` | `include_system_apps` | List installed apps |
| `grant_permission` | `package_name`, `permission` | Grant runtime permission |
### π Debugging & Diagnostics
| Tool | Parameters | Description |
|---|---|---|
| `get_logcat_output` | `app_package`, `log_level` | Get last 100 logcat lines |
| `get_device_info` | β | Get device model, OS version, etc. |
| `get_current_activity` | β | Get current foreground Activity |
| `get_memory_info` | `package_name` | View app memory usage |
### π File Operations
| Tool | Parameters | Description |
|---|---|---|
| `pull_file` | `device_path`, `local_path` | Pull file from device |
| `push_file` | `local_path`, `device_path` | Push file to device |
---
## Debugging
Use [MCP Inspector](https://github.com/modelcontextprotocol/inspector) for local debugging:
```bash
# Install MCP Inspector
npm install -g @modelcontextprotocol/inspector
# Start with config file
npx @modelcontextprotocol/inspector --config mcp-inspector-config.json --server android-stdio
```
Or start manually:
```bash
# stdio mode
uv run main.py --mode stdio --temp-dir /tmp/android_mcp
# HTTP mode
uv run main.py --mode streamable-http --temp-dir /tmp/android_mcp --port 3001
```
---
## References
- [Model Context Protocol](https://modelcontextprotocol.io/)
- [FastMCP](https://github.com/jlowin/fastmcp)
- [Android Debug Bridge (ADB)](https://developer.android.com/tools/adb)
TDQS
Scored across 19 tools
Each tool targets a distinct device operation with clear boundaries: gestures (tap/long_press/swipe), file transfer (push/pull), app lifecycle (launch/force_stop/clear_data/install), and info gathering (device/memory/logcat/activity) do not overlap. The descriptions even disambiguate similar tools like get_ui_dump vs get_screenshot, directing agents to the right one.
All names are snake_case and verb-first, following a predictable verb_noun pattern (get_device_info, push_file, launch_app, clear_app_data). Minor variation like long_press/tap_screen still fits the scheme cleanly.
19 tools is slightly above the ideal 3-15 band but each earns its place in a device-automation surface. The set is cohesive rather than padded, so it's a minor overage rather than a scope mismatch.
Strong coverage of input, app lifecycle, file transfer, permissions, and introspection for Android automation. Minor gaps exist (no uninstall/revoke_permission, no element-text convenience, no waiting/rotation), but core workflows are fully supported.