$git clone https://github.com/minhalvp/android-mcp-serverAn MCP (Model Context Protocol) server that provides programmatic control over Android devices through ADB (Android Debug Bridge). This server exposes various Android device management capabilities that can be accessed by MCP clients like [Claude desktop](https://modelcontextprot
| 1 | # Android MCP Server |
| 2 | |
| 3 | An MCP (Model Context Protocol) server that provides programmatic control over |
| 4 | Android devices through ADB (Android Debug Bridge). This server exposes |
| 5 | various Android device management capabilities that can be accessed by MCP |
| 6 | clients like [Claude desktop](https://modelcontextprotocol.io/quickstart/user) |
| 7 | and Code editors |
| 8 | (e.g. [Cursor](https://docs.cursor.com/context/model-context-protocol)) |
| 9 | |
| 10 | ## Features |
| 11 | |
| 12 | - 🔧 ADB Command Execution |
| 13 | - 📸 Device Screenshot Capture |
| 14 | - 🎯 UI Layout Analysis |
| 15 | - 📱 Device Package Management |
| 16 | |
| 17 | ## Prerequisites |
| 18 | |
| 19 | - Python 3.x |
| 20 | - ADB (Android Debug Bridge) installed and configured |
| 21 | - Android device or emulator (not tested) |
| 22 | |
| 23 | ## Installation |
| 24 | |
| 25 | 1. Clone the repository: |
| 26 | |
| 27 | ```bash |
| 28 | git clone https://github.com/minhalvp/android-mcp-server.git |
| 29 | cd android-mcp-server |
| 30 | ``` |
| 31 | |
| 32 | 2. Install dependencies: |
| 33 | This project uses [uv](https://github.com/astral-sh/uv) for project |
| 34 | management via various methods of |
| 35 | [installation](https://docs.astral.sh/uv/getting-started/installation/). |
| 36 | |
| 37 | ```bash |
| 38 | uv python install 3.11 |
| 39 | uv sync |
| 40 | ``` |
| 41 | |
| 42 | ## Configuration |
| 43 | |
| 44 | The server supports flexible device configuration with multiple usage scenarios. |
| 45 | |
| 46 | ### Device Selection Modes |
| 47 | |
| 48 | **1. Automatic Selection (Recommended for single device)** |
| 49 | |
| 50 | - No configuration file needed |
| 51 | - Automatically connects to the only connected device |
| 52 | - Perfect for development with a single test device |
| 53 | |
| 54 | **2. Manual Device Selection** |
| 55 | |
| 56 | - Use when you have multiple devices connected |
| 57 | - Specify exact device in configuration file |
| 58 | |
| 59 | ### Configuration File (Optional) |
| 60 | |
| 61 | The configuration file (`config.yaml`) is **optional**. If not present, the server will automatically select the device if only one is connected. |
| 62 | |
| 63 | #### For Automatic Selection |
| 64 | |
| 65 | Simply ensure only one device is connected and run the server - no configuration needed! |
| 66 | |
| 67 | #### For Manual Selection |
| 68 | |
| 69 | 1. Create a configuration file: |
| 70 | |
| 71 | ```bash |
| 72 | cp config.yaml.example config.yaml |
| 73 | ``` |
| 74 | |
| 75 | 2. Edit `config.yaml` and specify your device: |
| 76 | |
| 77 | ```yaml |
| 78 | device: |
| 79 | name: "your-device-serial-here" # Device identifier from 'adb devices' |
| 80 | ``` |
| 81 | |
| 82 | **For auto-selection**, you can use any of these methods: |
| 83 | |
| 84 | ```yaml |
| 85 | device: |
| 86 | name: null # Explicit null (recommended) |
| 87 | # name: "" # Empty string |
| 88 | # name: # Or leave empty/comment out |
| 89 | ``` |
| 90 | |
| 91 | ### Finding Your Device Serial |
| 92 | |
| 93 | To find your device identifier, run: |
| 94 | |
| 95 | ```bash |
| 96 | adb devices |
| 97 | ``` |
| 98 | |
| 99 | Example output: |
| 100 | |
| 101 | ``` |
| 102 | List of devices attached |
| 103 | 13b22d7f device |
| 104 | emulator-5554 device |
| 105 | ``` |
| 106 | |
| 107 | Use the first column value (e.g., `13b22d7f` or `emulator-5554`) as the device name. |
| 108 | |
| 109 | ### Usage Scenarios |
| 110 | |
| 111 | | Scenario | Configuration Required | Behavior | |
| 112 | |----------|----------------------|----------| |
| 113 | | Single device connected | None | ✅ Auto-connects to the device | |
| 114 | | Multiple devices, want specific one | `config.yaml` with `device.name` | ✅ Connects to specified device | |
| 115 | | Multiple devices, no config | None | ❌ Shows error with available devices | |
| 116 | | No devices connected | N/A | ❌ Shows "no devices" error | |
| 117 | |
| 118 | **Note**: If you have multiple devices connected and don't specify which one to use, the server will show an error message listing all available devices. |
| 119 | |
| 120 | ## Usage |
| 121 | |
| 122 | An MCP client is needed to use this server. The Claude Desktop app is an example |
| 123 | of an MCP client. To use this server with Claude Desktop: |
| 124 | |
| 125 | 1. Locate your Claude Desktop configuration file: |
| 126 | |
| 127 | - Windows: `%APPDATA%\Claude\claude_desktop_config.json` |
| 128 | - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json` |
| 129 | |
| 130 | 2. Add the Android MCP server configuration to the `mcpServers` section: |
| 131 | |
| 132 | ```json |
| 133 | { |
| 134 | "mcpServers": { |
| 135 | "android": { |
| 136 | "command": "path/to/uv", |
| 137 | "args": ["--directory", "path/to/android-mcp-server", "run", "server.py"] |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | ``` |
| 142 | |
| 143 | Replace: |
| 144 | |
| 145 | - `path/to/uv` with the actual path to your `uv` executable |
| 146 | - `path/to/android-mcp-server` with the absolute path to where you cloned this |
| 147 | repository |
| 148 | |
| 149 | <https://github.com/user-attachments/assets/c45bbc17-f698-43e7-85b4-f1b39b8326a8> |
| 150 | |
| 151 | ### Availabl |