the-android-mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +624 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +25 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +484 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +1145 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +797 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/adb.d.ts +163 -0
- package/dist/utils/adb.d.ts.map +1 -0
- package/dist/utils/adb.js +525 -0
- package/dist/utils/adb.js.map +1 -0
- package/dist/utils/error.d.ts +5 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +50 -0
- package/dist/utils/error.js.map +1 -0
- package/dist/utils/screenshot.d.ts +8 -0
- package/dist/utils/screenshot.d.ts.map +1 -0
- package/dist/utils/screenshot.js +49 -0
- package/dist/utils/screenshot.js.map +1 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 The Android MCP
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,624 @@
|
|
|
1
|
+
# The Android MCP
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/the-android-mcp)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://typescriptlang.org)
|
|
6
|
+
[](https://nodejs.org)
|
|
7
|
+
|
|
8
|
+
ADB-powered Model Context Protocol server that lets AI coding agents install, launch, and control Android apps, capture screenshots, and wire hot-reload ports. Built for iterative UI refinement, automated test flows, and hands-on app navigation with Expo, React Native, Flutter, and native Android projects.
|
|
9
|
+
|
|
10
|
+
**Keywords:** android mcp server, adb automation, android app testing, hot reload, android ui control, ai agent android, expo, react native, flutter
|
|
11
|
+
|
|
12
|
+
## Quick Demo
|
|
13
|
+
|
|
14
|
+
See the MCP server in action with real-time Android UI analysis and control:
|
|
15
|
+
|
|
16
|
+
| MCP Server Status | Live Development Workflow |
|
|
17
|
+
| ----------------------------------- | ------------------------------------------ |
|
|
18
|
+
|  |  |
|
|
19
|
+
| Server ready with many tools | AI agent analyzing Android UI in real-time |
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
**Real-Time Development Workflow**
|
|
24
|
+
|
|
25
|
+
- Live screenshot capture during app development with Expo, React Native, Flutter
|
|
26
|
+
- Instant visual feedback for AI agents on UI changes and iterations
|
|
27
|
+
- Seamless integration with development servers and hot reload workflows
|
|
28
|
+
- Support for both physical devices and emulators during active development
|
|
29
|
+
- ADB-driven app install, launch, input control, and port reverse for hands-on testing
|
|
30
|
+
|
|
31
|
+
**AI Agent Integration**
|
|
32
|
+
|
|
33
|
+
- MCP protocol support for Claude Desktop, GitHub Copilot, and Gemini CLI
|
|
34
|
+
- Enable AI agents to see your app UI and provide contextual suggestions
|
|
35
|
+
- Perfect for iterative UI refinement and design feedback loops
|
|
36
|
+
- Visual context for AI-powered code generation and UI improvements
|
|
37
|
+
|
|
38
|
+
**Developer Experience**
|
|
39
|
+
|
|
40
|
+
- Zero-configuration setup with running development environments
|
|
41
|
+
- Docker deployment for team collaboration and CI/CD pipelines
|
|
42
|
+
- Comprehensive error handling with helpful development suggestions
|
|
43
|
+
- Secure stdio communication with timeout management
|
|
44
|
+
|
|
45
|
+
## Table of Contents
|
|
46
|
+
|
|
47
|
+
- [AI Agent Configuration](#ai-agent-configuration)
|
|
48
|
+
- [Installation](#installation)
|
|
49
|
+
- [Development Workflow](#development-workflow)
|
|
50
|
+
- [Prerequisites](#prerequisites)
|
|
51
|
+
- [Development Environment Setup](#development-environment-setup)
|
|
52
|
+
- [Docker Deployment](#docker-deployment)
|
|
53
|
+
- [Available Tools](#available-tools)
|
|
54
|
+
- [Usage Examples](#usage-examples)
|
|
55
|
+
- [Troubleshooting](#troubleshooting)
|
|
56
|
+
- [Development](#development)
|
|
57
|
+
|
|
58
|
+
## AI Agent Configuration
|
|
59
|
+
|
|
60
|
+
This MCP server works with AI agents that support the Model Context Protocol. Configure your preferred agent to enable real-time Android UI analysis:
|
|
61
|
+
|
|
62
|
+
### Claude Code
|
|
63
|
+
```bash
|
|
64
|
+
# CLI Installation
|
|
65
|
+
claude mcp add the-android-mcp -- npx the-android-mcp
|
|
66
|
+
|
|
67
|
+
# Local Development
|
|
68
|
+
claude mcp add the-android-mcp -- node "D:\\projects\\the-android-mcp\\dist\\index.js"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Claude Desktop
|
|
72
|
+
Add to `%APPDATA%\Claude\claude_desktop_config.json`:
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"mcpServers": {
|
|
76
|
+
"the-android-mcp": {
|
|
77
|
+
"command": "npx",
|
|
78
|
+
"args": ["the-android-mcp"],
|
|
79
|
+
"timeout": 10000
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### GitHub Copilot (VS Code)
|
|
86
|
+
Add to `.vscode/settings.json`:
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"github.copilot.enable": {
|
|
90
|
+
"*": true
|
|
91
|
+
},
|
|
92
|
+
"mcp.servers": {
|
|
93
|
+
"the-android-mcp": {
|
|
94
|
+
"command": "npx",
|
|
95
|
+
"args": ["the-android-mcp"],
|
|
96
|
+
"timeout": 10000
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Gemini CLI
|
|
103
|
+
```bash
|
|
104
|
+
# CLI Installation
|
|
105
|
+
gemini mcp add the-android-mcp npx the-android-mcp
|
|
106
|
+
|
|
107
|
+
# Configuration
|
|
108
|
+
# Create ~/.gemini/settings.json with:
|
|
109
|
+
{
|
|
110
|
+
"mcpServers": {
|
|
111
|
+
"the-android-mcp": {
|
|
112
|
+
"command": "npx",
|
|
113
|
+
"args": ["the-android-mcp"]
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Installation
|
|
120
|
+
|
|
121
|
+
### Package Manager Installation
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
npm install -g the-android-mcp
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Source Installation
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
git clone https://github.com/meinzeug/the-android-mcp
|
|
131
|
+
cd the-android-mcp
|
|
132
|
+
npm install && npm run build
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Installation Verification
|
|
136
|
+
|
|
137
|
+
After installation, verify the package is available:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
the-android-mcp --version
|
|
141
|
+
# For npm installation
|
|
142
|
+
npx the-android-mcp --version
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Development Workflow
|
|
146
|
+
|
|
147
|
+
This MCP server transforms how you develop Android UIs by giving AI agents real-time visual access to your running application. Here's the typical workflow:
|
|
148
|
+
|
|
149
|
+
1. **Start Your Development Environment**: Launch Expo, React Native Metro, Flutter, or Android Studio with your app running
|
|
150
|
+
2. **Connect the MCP Server**: Configure your AI agent (Claude, Copilot, Gemini) to use this MCP server
|
|
151
|
+
3. **Iterative Development**: Ask your AI agent to analyze the current UI, suggest improvements, or help implement changes
|
|
152
|
+
4. **Real-Time Feedback**: The AI agent takes screenshots to see the results of code changes immediately
|
|
153
|
+
5. **Refine and Repeat**: Continue the conversation with visual context for better UI development
|
|
154
|
+
|
|
155
|
+
**Perfect for:**
|
|
156
|
+
|
|
157
|
+
- Expo development with live preview and hot reload
|
|
158
|
+
- React Native development with Metro bundler
|
|
159
|
+
- Flutter development with hot reload
|
|
160
|
+
- Native Android development with instant run
|
|
161
|
+
- UI testing and visual regression analysis
|
|
162
|
+
- Collaborative design reviews with AI assistance
|
|
163
|
+
- Accessibility testing with visual context
|
|
164
|
+
- Cross-platform UI consistency checking
|
|
165
|
+
|
|
166
|
+
## Prerequisites
|
|
167
|
+
|
|
168
|
+
| Component | Version | Installation |
|
|
169
|
+
| --------- | ------- | ------------------------------------------------------------------------------------------ |
|
|
170
|
+
| Node.js | 18.0+ | [Download](https://nodejs.org) |
|
|
171
|
+
| npm | 8.0+ | Included with Node.js |
|
|
172
|
+
| ADB | Latest | [Android SDK Platform Tools](https://developer.android.com/studio/releases/platform-tools) |
|
|
173
|
+
|
|
174
|
+
### Android Device Setup
|
|
175
|
+
|
|
176
|
+
1. Enable Developer Options: Settings > About Phone > Tap "Build Number" 7 times
|
|
177
|
+
2. Enable USB Debugging: Settings > Developer Options > USB Debugging
|
|
178
|
+
3. Verify connection: `adb devices`
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
## Development Environment Setup
|
|
182
|
+
|
|
183
|
+
### Expo Development
|
|
184
|
+
|
|
185
|
+
1. Start your Expo development server:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
npx expo start
|
|
189
|
+
# or
|
|
190
|
+
npm start
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
2. Open your app on a connected device or emulator
|
|
194
|
+
3. Ensure your device appears in `adb devices`
|
|
195
|
+
4. Your AI agent can now take screenshots during development
|
|
196
|
+
|
|
197
|
+
### React Native Development
|
|
198
|
+
|
|
199
|
+
1. Start Metro bundler:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
npx react-native start
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
2. Run on Android:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
npx react-native run-android
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
3. Enable hot reload for instant feedback with AI analysis
|
|
212
|
+
|
|
213
|
+
### Flutter Development
|
|
214
|
+
|
|
215
|
+
1. Start Flutter in debug mode:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
flutter run
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
2. Use hot reload (`r`) and hot restart (`R`) while getting AI feedback
|
|
222
|
+
3. The AI agent can capture UI states after each change
|
|
223
|
+
|
|
224
|
+
### Native Android Development
|
|
225
|
+
|
|
226
|
+
1. Open project in Android Studio
|
|
227
|
+
2. Run app with instant run enabled
|
|
228
|
+
3. Connect device or start emulator
|
|
229
|
+
4. Enable AI agent integration for real-time UI analysis
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
## Docker Deployment
|
|
233
|
+
|
|
234
|
+
### Docker Compose
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
cd docker
|
|
238
|
+
docker-compose up --build -d
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Configure AI platform for Docker:
|
|
242
|
+
|
|
243
|
+
```json
|
|
244
|
+
{
|
|
245
|
+
"mcpServers": {
|
|
246
|
+
"the-android-mcp": {
|
|
247
|
+
"command": "docker",
|
|
248
|
+
"args": ["exec", "the-android-mcp", "node", "/app/dist/index.js"],
|
|
249
|
+
"timeout": 15000
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Manual Docker Build
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
docker build -t the-android-mcp .
|
|
259
|
+
docker run -it --rm --privileged -v /dev/bus/usb:/dev/bus/usb the-android-mcp
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Available Tools
|
|
263
|
+
|
|
264
|
+

|
|
265
|
+
|
|
266
|
+
| Tool | Description | Parameters |
|
|
267
|
+
| ------------------------- | ----------------------------------------- | -------------------------------------------------------------------------- |
|
|
268
|
+
| `take_android_screenshot` | Captures device screenshot | `deviceId` (optional) |
|
|
269
|
+
| `list_android_devices` | Lists connected devices | None |
|
|
270
|
+
| `find_android_apk` | Finds the most recent APK in a project | `projectRoot` (optional) |
|
|
271
|
+
| `install_android_apk` | Installs an APK on a device | `apkPath` (optional), `deviceId` (optional), install flags, `timeoutMs` |
|
|
272
|
+
| `uninstall_android_app` | Uninstalls an app by package name | `packageName`, `deviceId` (optional), `keepData` (optional) |
|
|
273
|
+
| `start_android_app` | Starts an app (optionally activity) | `packageName`, `activity` (optional), `deviceId` (optional) |
|
|
274
|
+
| `stop_android_app` | Force-stops an app | `packageName`, `deviceId` (optional) |
|
|
275
|
+
| `clear_android_app_data` | Clears app data | `packageName`, `deviceId` (optional) |
|
|
276
|
+
| `tap_android_screen` | Sends a tap event | `x`, `y`, `deviceId` (optional) |
|
|
277
|
+
| `swipe_android_screen` | Sends a swipe gesture | `startX`, `startY`, `endX`, `endY`, `durationMs` (optional), `deviceId` |
|
|
278
|
+
| `input_android_text` | Types text into focused input | `text`, `deviceId` (optional) |
|
|
279
|
+
| `send_android_keyevent` | Sends an Android keyevent | `keyCode`, `deviceId` (optional) |
|
|
280
|
+
| `reverse_android_port` | Reverse TCP port (device → host) | `devicePort`, `hostPort` (optional), `deviceId` (optional) |
|
|
281
|
+
| `forward_android_port` | Forward TCP port (host → device) | `devicePort`, `hostPort`, `deviceId` (optional) |
|
|
282
|
+
| `get_android_logcat` | Fetch recent logcat output | `lines` (optional), filters, `deviceId` (optional) |
|
|
283
|
+
| `list_android_activities` | List activities for a package | `packageName`, `deviceId` (optional) |
|
|
284
|
+
| `hot_reload_android_app` | Reverse ports + install/start for hot dev | `packageName`, `reversePorts`, install/start options, `deviceId` (optional)|
|
|
285
|
+
|
|
286
|
+
### Tool Schemas
|
|
287
|
+
|
|
288
|
+
**take_android_screenshot**
|
|
289
|
+
|
|
290
|
+
```json
|
|
291
|
+
{
|
|
292
|
+
"name": "take_android_screenshot",
|
|
293
|
+
"description": "Capture a screenshot from an Android device or emulator",
|
|
294
|
+
"inputSchema": {
|
|
295
|
+
"type": "object",
|
|
296
|
+
"properties": {
|
|
297
|
+
"deviceId": {
|
|
298
|
+
"type": "string",
|
|
299
|
+
"description": "Optional device ID. If not provided, uses the first available device"
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**list_android_devices**
|
|
307
|
+
|
|
308
|
+
```json
|
|
309
|
+
{
|
|
310
|
+
"name": "list_android_devices",
|
|
311
|
+
"description": "List all connected Android devices and emulators with detailed information",
|
|
312
|
+
"inputSchema": {
|
|
313
|
+
"type": "object",
|
|
314
|
+
"properties": {}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
**find_android_apk**
|
|
320
|
+
|
|
321
|
+
```json
|
|
322
|
+
{
|
|
323
|
+
"name": "find_android_apk",
|
|
324
|
+
"description": "Find the most recent APK in a project directory",
|
|
325
|
+
"inputSchema": {
|
|
326
|
+
"type": "object",
|
|
327
|
+
"properties": {
|
|
328
|
+
"projectRoot": {
|
|
329
|
+
"type": "string",
|
|
330
|
+
"description": "Optional project root to search for APKs"
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**install_android_apk**
|
|
338
|
+
|
|
339
|
+
```json
|
|
340
|
+
{
|
|
341
|
+
"name": "install_android_apk",
|
|
342
|
+
"description": "Install an APK on a connected Android device or emulator",
|
|
343
|
+
"inputSchema": {
|
|
344
|
+
"type": "object",
|
|
345
|
+
"properties": {
|
|
346
|
+
"apkPath": {
|
|
347
|
+
"type": "string",
|
|
348
|
+
"description": "Path to APK (optional; auto-detects if omitted)"
|
|
349
|
+
},
|
|
350
|
+
"deviceId": {
|
|
351
|
+
"type": "string",
|
|
352
|
+
"description": "Optional device ID"
|
|
353
|
+
},
|
|
354
|
+
"reinstall": {
|
|
355
|
+
"type": "boolean",
|
|
356
|
+
"description": "Reinstall if already installed (-r)"
|
|
357
|
+
},
|
|
358
|
+
"grantPermissions": {
|
|
359
|
+
"type": "boolean",
|
|
360
|
+
"description": "Grant runtime permissions at install time (-g)"
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
**start_android_app**
|
|
368
|
+
|
|
369
|
+
```json
|
|
370
|
+
{
|
|
371
|
+
"name": "start_android_app",
|
|
372
|
+
"description": "Start an Android app by package name",
|
|
373
|
+
"inputSchema": {
|
|
374
|
+
"type": "object",
|
|
375
|
+
"properties": {
|
|
376
|
+
"packageName": {
|
|
377
|
+
"type": "string",
|
|
378
|
+
"description": "Android application package name"
|
|
379
|
+
},
|
|
380
|
+
"activity": {
|
|
381
|
+
"type": "string",
|
|
382
|
+
"description": "Optional activity to launch"
|
|
383
|
+
},
|
|
384
|
+
"deviceId": {
|
|
385
|
+
"type": "string",
|
|
386
|
+
"description": "Optional device ID"
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
**tap_android_screen**
|
|
394
|
+
|
|
395
|
+
```json
|
|
396
|
+
{
|
|
397
|
+
"name": "tap_android_screen",
|
|
398
|
+
"description": "Send a tap event to the device screen",
|
|
399
|
+
"inputSchema": {
|
|
400
|
+
"type": "object",
|
|
401
|
+
"properties": {
|
|
402
|
+
"x": {
|
|
403
|
+
"type": "number",
|
|
404
|
+
"description": "Tap X coordinate in pixels"
|
|
405
|
+
},
|
|
406
|
+
"y": {
|
|
407
|
+
"type": "number",
|
|
408
|
+
"description": "Tap Y coordinate in pixels"
|
|
409
|
+
},
|
|
410
|
+
"deviceId": {
|
|
411
|
+
"type": "string",
|
|
412
|
+
"description": "Optional device ID"
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
**reverse_android_port**
|
|
420
|
+
|
|
421
|
+
```json
|
|
422
|
+
{
|
|
423
|
+
"name": "reverse_android_port",
|
|
424
|
+
"description": "Reverse TCP port from device to host (useful for hot reload)",
|
|
425
|
+
"inputSchema": {
|
|
426
|
+
"type": "object",
|
|
427
|
+
"properties": {
|
|
428
|
+
"devicePort": {
|
|
429
|
+
"type": "number",
|
|
430
|
+
"description": "Device port to reverse"
|
|
431
|
+
},
|
|
432
|
+
"hostPort": {
|
|
433
|
+
"type": "number",
|
|
434
|
+
"description": "Host port to map to (defaults to devicePort)"
|
|
435
|
+
},
|
|
436
|
+
"deviceId": {
|
|
437
|
+
"type": "string",
|
|
438
|
+
"description": "Optional device ID"
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
**get_android_logcat**
|
|
446
|
+
|
|
447
|
+
```json
|
|
448
|
+
{
|
|
449
|
+
"name": "get_android_logcat",
|
|
450
|
+
"description": "Fetch recent logcat output (optionally filtered)",
|
|
451
|
+
"inputSchema": {
|
|
452
|
+
"type": "object",
|
|
453
|
+
"properties": {
|
|
454
|
+
"lines": {
|
|
455
|
+
"type": "number",
|
|
456
|
+
"description": "Number of log lines to return"
|
|
457
|
+
},
|
|
458
|
+
"tag": {
|
|
459
|
+
"type": "string",
|
|
460
|
+
"description": "Optional log tag filter"
|
|
461
|
+
},
|
|
462
|
+
"priority": {
|
|
463
|
+
"type": "string",
|
|
464
|
+
"description": "Minimum priority (V/D/I/W/E/F/S)"
|
|
465
|
+
},
|
|
466
|
+
"packageName": {
|
|
467
|
+
"type": "string",
|
|
468
|
+
"description": "Optional package name to filter by running PID"
|
|
469
|
+
},
|
|
470
|
+
"deviceId": {
|
|
471
|
+
"type": "string",
|
|
472
|
+
"description": "Optional device ID"
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
**list_android_activities**
|
|
480
|
+
|
|
481
|
+
```json
|
|
482
|
+
{
|
|
483
|
+
"name": "list_android_activities",
|
|
484
|
+
"description": "List activities for a package name",
|
|
485
|
+
"inputSchema": {
|
|
486
|
+
"type": "object",
|
|
487
|
+
"properties": {
|
|
488
|
+
"packageName": {
|
|
489
|
+
"type": "string",
|
|
490
|
+
"description": "Android application package name"
|
|
491
|
+
},
|
|
492
|
+
"deviceId": {
|
|
493
|
+
"type": "string",
|
|
494
|
+
"description": "Optional device ID"
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
**hot_reload_android_app**
|
|
502
|
+
|
|
503
|
+
```json
|
|
504
|
+
{
|
|
505
|
+
"name": "hot_reload_android_app",
|
|
506
|
+
"description": "Reverse ports, install (optional), and start an app for hot reload",
|
|
507
|
+
"inputSchema": {
|
|
508
|
+
"type": "object",
|
|
509
|
+
"properties": {
|
|
510
|
+
"packageName": {
|
|
511
|
+
"type": "string",
|
|
512
|
+
"description": "Android application package name"
|
|
513
|
+
},
|
|
514
|
+
"reversePorts": {
|
|
515
|
+
"type": "array",
|
|
516
|
+
"description": "Ports to reverse (defaults to 8081)"
|
|
517
|
+
},
|
|
518
|
+
"install": {
|
|
519
|
+
"type": "boolean",
|
|
520
|
+
"description": "Whether to install an APK before starting"
|
|
521
|
+
},
|
|
522
|
+
"start": {
|
|
523
|
+
"type": "boolean",
|
|
524
|
+
"description": "Whether to start the app after setup"
|
|
525
|
+
},
|
|
526
|
+
"deviceId": {
|
|
527
|
+
"type": "string",
|
|
528
|
+
"description": "Optional device ID"
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
## Usage Examples
|
|
536
|
+
|
|
537
|
+

|
|
538
|
+
|
|
539
|
+
_Example: AI agent listing devices, capturing screenshots, and providing detailed UI analysis in real-time_
|
|
540
|
+
|
|
541
|
+
### Real-Time UI Development
|
|
542
|
+
|
|
543
|
+
With your development environment running (Expo, React Native, Flutter, etc.), interact with your AI agent:
|
|
544
|
+
|
|
545
|
+
**Initial Analysis:**
|
|
546
|
+
|
|
547
|
+
- "Take a screenshot of my current app UI and analyze the layout"
|
|
548
|
+
- "Show me the current state of my login screen and suggest improvements"
|
|
549
|
+
- "Capture the app and check for accessibility issues"
|
|
550
|
+
|
|
551
|
+
**Iterative Development:**
|
|
552
|
+
|
|
553
|
+
- "I just changed the button color, take another screenshot and compare"
|
|
554
|
+
- "Help me adjust the spacing - take a screenshot after each change"
|
|
555
|
+
- "Take a screenshot and tell me if the new navigation looks good"
|
|
556
|
+
|
|
557
|
+
**Cross-Platform Testing:**
|
|
558
|
+
|
|
559
|
+
- "Capture screenshots from both my phone and tablet emulator"
|
|
560
|
+
- "Show me how the UI looks on device emulator-5554 vs my physical device"
|
|
561
|
+
|
|
562
|
+
**Development Debugging:**
|
|
563
|
+
|
|
564
|
+
- "List all connected devices and their status"
|
|
565
|
+
- "Take a screenshot from the specific emulator running my debug build"
|
|
566
|
+
- "Capture the current error state and help me fix the UI issue"
|
|
567
|
+
|
|
568
|
+
**App Installation & Interaction:**
|
|
569
|
+
|
|
570
|
+
- "Find the latest APK in this repo and install it"
|
|
571
|
+
- "Start com.example.app and open the main activity"
|
|
572
|
+
- "Tap the login button at (540, 1620) and type my test credentials"
|
|
573
|
+
- "Reverse port 8081 for hot reload, then relaunch the app"
|
|
574
|
+
- "Get the last 200 logcat lines for com.example.app"
|
|
575
|
+
|
|
576
|
+
## Troubleshooting
|
|
577
|
+
|
|
578
|
+
### ADB Issues
|
|
579
|
+
|
|
580
|
+
- **ADB not found**: Verify ADB is installed and in PATH
|
|
581
|
+
- **No devices**: Check USB connection and debugging authorization
|
|
582
|
+
- **Device unauthorized**: Disconnect/reconnect USB, check device authorization prompt
|
|
583
|
+
- **Screenshot failed**: Ensure device is unlocked and properly connected
|
|
584
|
+
|
|
585
|
+
### Connection Issues
|
|
586
|
+
|
|
587
|
+
- Verify `adb devices` shows your device as "device" status
|
|
588
|
+
- Restart ADB server: `adb kill-server && adb start-server`
|
|
589
|
+
- Check USB debugging permissions on device
|
|
590
|
+
|
|
591
|
+
## Development
|
|
592
|
+
|
|
593
|
+
### Build Commands
|
|
594
|
+
|
|
595
|
+
```bash
|
|
596
|
+
npm run build # Production build
|
|
597
|
+
npm test # Run tests
|
|
598
|
+
npm run lint # Code linting
|
|
599
|
+
npm run format # Code formatting
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
### Project Structure
|
|
603
|
+
|
|
604
|
+
```
|
|
605
|
+
src/
|
|
606
|
+
├── server.ts # MCP server implementation
|
|
607
|
+
├── types.ts # Type definitions
|
|
608
|
+
├── utils/
|
|
609
|
+
│ ├── adb.ts # ADB command utilities
|
|
610
|
+
│ ├── screenshot.ts # Screenshot processing
|
|
611
|
+
│ └── error.ts # Error handling
|
|
612
|
+
└── index.ts # Entry point
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
## Performance
|
|
616
|
+
|
|
617
|
+
- 5-second timeout on ADB operations
|
|
618
|
+
- In-memory screenshot processing
|
|
619
|
+
- Stdio communication for security
|
|
620
|
+
- Minimal privilege execution
|
|
621
|
+
|
|
622
|
+
## License
|
|
623
|
+
|
|
624
|
+
MIT License - see LICENSE file for details.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const server_1 = require("./server");
|
|
5
|
+
async function main() {
|
|
6
|
+
try {
|
|
7
|
+
const server = new server_1.AndroidMcpServer();
|
|
8
|
+
await server.run();
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
console.error('Failed to start server:', error);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
main();
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,qCAA4C;AAE5C,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,yBAAgB,EAAE,CAAC;QACtC,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;QAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare class AndroidMcpServer {
|
|
2
|
+
private server;
|
|
3
|
+
constructor();
|
|
4
|
+
private setupToolHandlers;
|
|
5
|
+
private takeScreenshot;
|
|
6
|
+
private listDevices;
|
|
7
|
+
private findApk;
|
|
8
|
+
private installApk;
|
|
9
|
+
private uninstallApp;
|
|
10
|
+
private startApp;
|
|
11
|
+
private stopApp;
|
|
12
|
+
private clearAppData;
|
|
13
|
+
private tapScreen;
|
|
14
|
+
private swipeScreen;
|
|
15
|
+
private inputText;
|
|
16
|
+
private sendKeyevent;
|
|
17
|
+
private reversePort;
|
|
18
|
+
private forwardPort;
|
|
19
|
+
private getLogcat;
|
|
20
|
+
private listActivities;
|
|
21
|
+
private hotReload;
|
|
22
|
+
run(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export { AndroidMcpServer };
|
|
25
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAmFA,cAAM,gBAAgB;IACpB,OAAO,CAAC,MAAM,CAAS;;IAkBvB,OAAO,CAAC,iBAAiB;YAqVX,cAAc;YAiBd,WAAW;YAoBX,OAAO;YAOP,UAAU;YAeV,YAAY;YAUZ,QAAQ;YAOR,OAAO;YAOP,YAAY;YAOZ,SAAS;YAOT,WAAW;YAcX,SAAS;YAOT,YAAY;YAOZ,WAAW;YAOX,WAAW;YAOX,SAAS;YAgBT,cAAc;YAOd,SAAS;IAsBjB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAK3B;AAGD,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|