uiautomator2-mcp-server 0.1.2__py3-none-any.whl → 0.2.0__py3-none-any.whl

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.
@@ -0,0 +1,738 @@
1
+ Metadata-Version: 2.4
2
+ Name: uiautomator2-mcp-server
3
+ Version: 0.2.0
4
+ Summary: uiautomator2 mcp server
5
+ Author-email: tanbro <tanbro@163.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: homepage, https://github.com/tanbro/uiautomator2-mcp-server
8
+ Project-URL: documentation, https://github.com/tanbro/uiautomator2-mcp-server/blob/main/README.md
9
+ Project-URL: repository, https://github.com/tanbro/uiautomator2-mcp-server.git
10
+ Project-URL: issues, https://github.com/tanbro/uiautomator2-mcp-server/issues
11
+ Project-URL: changelog, https://github.com/tanbro/uiautomator2-mcp-server/blob/main/CHANGELOG.md
12
+ Keywords: uiautomator2,mcp,fastmcp,adb,android,adbutils
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: fastmcp<3.0,>=2.11
23
+ Requires-Dist: typing_extensions>=4.12; python_version < "3.12"
24
+ Requires-Dist: uiautomator2<4.0,>=3.5
25
+ Dynamic: license-file
26
+
27
+ # uiautomator2-mcp-server
28
+
29
+ [![PyPI](https://img.shields.io/pypi/v/uiautomator2-mcp-server)](https://pypi.org/project/uiautomator2-mcp-server/)
30
+ [![CI](https://github.com/tanbro/uiautomator2-mcp-server/actions/workflows/ci.yml/badge.svg)](https://github.com/tanbro/uiautomator2-mcp-server/actions/workflows/ci.yml)
31
+ [![Codecov](https://img.shields.io/codecov/c/gh/tanbro/uiautomator2-mcp-server)](https://codecov.io/gh/tanbro/uiautomator2-mcp-server)
32
+ [![GitHub release](https://img.shields.io/github/v/release/tanbro/uiautomator2-mcp-server)](https://github.com/tanbro/uiautomator2-mcp-server/releases)
33
+ [![Language](https://img.shields.io/badge/lang-English-blue)](README.md)
34
+ [![Language](https://img.shields.io/badge/lang-中文-red)](README.zh-CN.md)
35
+
36
+ **Code of Conduct:** Please follow our [Code of Conduct](CODE_OF_CONDUCT.md) when participating in this project.
37
+
38
+ > **Note:** If you need Mainland China-specific download acceleration (pip/uv mirrors), see the Chinese README for details: [README.zh-CN.md](README.zh-CN.md).
39
+
40
+ An [MCP](https://modelcontextprotocol.io/) server that provides tools for controlling Android devices using [uiautomator2](https://github.com/openatx/uiautomator2).
41
+
42
+ > Use AI to automate your Android device: take screenshots, tap/swipe, manage apps, send text, and more.
43
+
44
+ ## Migration from v0.1.x
45
+
46
+ **If you're upgrading from v0.1.3 or earlier:** The CLI now requires an explicit subcommand. Change your command from:
47
+
48
+ ```bash
49
+ # Old (v0.1.3 and earlier)
50
+ u2mcp
51
+
52
+ # New (v0.2.0+)
53
+ u2mcp stdio
54
+ ```
55
+
56
+ All other commands remain the same (just add the transport subcommand).
57
+
58
+ ## Prerequisites
59
+
60
+ - [Python][] 3.11+
61
+ - `adb` in your PATH (install via [Android SDK Platform Tools](https://developer.android.com/tools/releases/platform-tools))
62
+ - Android device with **USB debugging enabled**
63
+
64
+ ### Installing `uv` (recommended for MCP clients)
65
+
66
+ Most MCP clients (like Claude Desktop) use `uvx` to run Python MCP servers. `uvx` is part of the [uv][] toolkit.
67
+
68
+ > **Why `uvx`?** `uvx` can run Python packages directly from PyPI without manual installation - just use `uvx package-name` and it handles the rest. This makes it perfect for MCP client configurations.
69
+
70
+ **macOS / Linux:**
71
+ ```bash
72
+ curl -LsSf https://astral.sh/uv/install.sh | sh
73
+ ```
74
+
75
+ **Windows (PowerShell):**
76
+ ```powershell
77
+ powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
78
+ ```
79
+
80
+ Or use `winget`:
81
+ ```powershell
82
+ winget install --id=astral-sh.uv -e
83
+ ```
84
+
85
+ Verify installation:
86
+ ```bash
87
+ uv --version
88
+ uvx --version
89
+ ```
90
+
91
+ ### Installing `pipx` (alternative)
92
+
93
+ [pipx][] is another tool for installing and running Python CLI applications in isolated environments.
94
+
95
+ > **`pipx` vs `uvx`:** Like `uvx`, `pipx` can also run packages directly with `pipx run package-name`. However, `uvx` is generally faster and is more commonly used in the MCP ecosystem.
96
+
97
+ **macOS / Linux:**
98
+ ```bash
99
+ python3 -m pip install --user pipx
100
+ python3 -m pipx ensurepath
101
+ ```
102
+
103
+ **Windows:**
104
+ ```powershell
105
+ python -m pip install --user pipx
106
+ python -m pipx ensurepath
107
+ ```
108
+
109
+ ## Installation
110
+
111
+ **Preferred (no-install):** Run directly from PyPI without installing using `uvx` (recommended) or `pipx`:
112
+
113
+ ```bash
114
+ # Run directly with uvx (recommended)
115
+ uvx uiautomator2-mcp-server stdio
116
+
117
+ # Or run directly with pipx
118
+ pipx run uiautomator2-mcp-server stdio
119
+ ```
120
+
121
+ **Or install globally** (if you want the command available system-wide):
122
+
123
+ ```bash
124
+ # Install using uv (tool-managed install)
125
+ uv tool install uiautomator2-mcp-server
126
+
127
+ # Or install with pipx
128
+ pipx install uiautomator2-mcp-server
129
+
130
+ # Or install with pip
131
+ pip install uiautomator2-mcp-server
132
+ ```
133
+
134
+ ### Running Modes
135
+
136
+ The MCP server can run in two modes:
137
+
138
+ #### STDIO Mode (for local MCP clients)
139
+
140
+ ```bash
141
+ u2mcp stdio
142
+ ```
143
+
144
+ This mode communicates via standard input/output and is typically used by MCP clients that spawn the server process directly.
145
+
146
+ #### HTTP Mode (for remote/network access)
147
+
148
+ ```bash
149
+ # Basic HTTP server
150
+ u2mcp http -H 0.0.0.0 -p 8000 -n
151
+
152
+ # With authentication token
153
+ u2mcp http -H 0.0.0.0 -p 8000 -t YOUR_SECRET_TOKEN
154
+ ```
155
+
156
+ The server will listen on `http://localhost:8000/mcp` (or your specified host/port).
157
+
158
+ ### CLI Utility Commands
159
+
160
+ The `u2mcp` CLI provides several utility commands for exploring available tools and tags:
161
+
162
+ ```bash
163
+ # List all available tools
164
+ u2mcp tools
165
+
166
+ # Show detailed information about a specific tool
167
+ u2mcp info screenshot
168
+
169
+ # Show tools matching a pattern (supports wildcards)
170
+ u2mcp info "device:*" # All device tools
171
+ u2mcp info "*screenshot*" # Tools with 'screenshot' in name
172
+
173
+ # List all available tool tags
174
+ u2mcp tags
175
+
176
+ # Show version information
177
+ u2mcp --version
178
+ ```
179
+
180
+ ### Tool Filtering
181
+
182
+ You can selectively expose tools using tag-based filtering. This reduces the number of tools available to the LLM, which can improve performance and reduce confusion.
183
+
184
+ ```bash
185
+ # Only expose device management tools
186
+ u2mcp stdio -i device:manage
187
+
188
+ # Only expose touch and gesture operations
189
+ u2mcp stdio -i action:touch,action:gesture
190
+
191
+ # Exclude screen mirroring tools
192
+ u2mcp stdio -e screen:mirror
193
+
194
+ # Only expose app lifecycle and element interaction tools
195
+ u2mcp stdio -i app:lifecycle,element:interact
196
+
197
+ # Exclude shell command tools (for security)
198
+ u2mcp stdio -e device:shell
199
+
200
+ # Only expose input-related tools
201
+ u2mcp stdio -i input:text,input:keyboard
202
+
203
+ # Combine include and exclude
204
+ u2mcp stdio -i device:info,action:touch -e screen:capture
205
+
206
+ # Wildcard patterns - include all device tools
207
+ u2mcp stdio -i "device:*"
208
+
209
+ # Wildcard patterns - include all touch and gesture tools
210
+ u2mcp stdio -i "action:to*"
211
+
212
+ # Wildcard patterns - exclude all screen tools
213
+ u2mcp stdio -e "screen:*"
214
+
215
+ # Wildcard patterns - exclude all mirror tools (screen:mirror, etc.)
216
+ u2mcp stdio -e "*:mirror"
217
+
218
+ # List all available tags
219
+ u2mcp tags
220
+ ```
221
+
222
+ **Short Options:**
223
+
224
+ All common options support short flags for convenience:
225
+ - `-l` / `--log-level` - Set log level
226
+ - `-i` / `--include-tags` - Include tools by tags
227
+ - `-e` / `--exclude-tags` - Exclude tools by tags
228
+ - `-H` / `--host` - Set host address (HTTP mode)
229
+ - `-p` / `--port` - Set port number (HTTP mode)
230
+ - `-t` / `--token` - Set authentication token (HTTP mode)
231
+ - `-n` / `--no-token` - Disable token verification (HTTP mode)
232
+
233
+ **Wildcard Support:**
234
+
235
+ The `--include-tags` and `--exclude-tags` options support wildcard patterns:
236
+ - `*` matches any characters
237
+ - `?` matches exactly one character
238
+ - `device:*` matches all device:* tags
239
+ - `*:mirror` matches all mirror tags (screen:mirror, etc.)
240
+ - `action:to*` matches action:touch, action:tool (if exists)
241
+
242
+ **Available Tags:**
243
+
244
+ | Tag | Description |
245
+ | ------------------ | ------------------------------------------------- |
246
+ | `device:manage` | Device connection, initialization, and management |
247
+ | `device:info` | Device information and status |
248
+ | `device:capture` | Screenshots and UI hierarchy |
249
+ | `device:shell` | Shell command execution |
250
+ | `action:touch` | Click and tap actions |
251
+ | `action:gesture` | Swipe and drag gestures |
252
+ | `action:key` | Physical key presses |
253
+ | `action:screen` | Screen control (on/off) |
254
+ | `app:manage` | Install and uninstall apps |
255
+ | `app:lifecycle` | Start and stop apps |
256
+ | `app:info` | App information and listing |
257
+ | `app:config` | App configuration (clear data, permissions) |
258
+ | `element:wait` | Wait for elements/activities |
259
+ | `element:interact` | Click and interact with elements |
260
+ | `element:query` | Get element info (text, bounds) |
261
+ | `element:modify` | Modify element (set text) |
262
+ | `element:gesture` | Element-specific gestures (swipe, scroll) |
263
+ | `element:capture` | Element screenshots |
264
+ | `input:text` | Text input and clearing |
265
+ | `input:keyboard` | Keyboard control |
266
+ | `clipboard:read` | Read clipboard |
267
+ | `clipboard:write` | Write clipboard |
268
+ | `screen:mirror` | Screen mirroring (scrcpy) |
269
+ | `screen:capture` | Screen screenshots |
270
+ | `util:delay` | Delay/sleep utility |
271
+
272
+ ## Testing and Debugging
273
+
274
+ ### Using MCP Inspector
275
+
276
+ [MCP Inspector](https://github.com/modelcontextprotocol/inspector) is a command-line tool for testing and debugging MCP servers without requiring an AI client.
277
+
278
+ ```bash
279
+ # Install MCP Inspector
280
+ npm install -g @modelcontextprotocol/inspector
281
+
282
+ # Inspect the server in STDIO mode
283
+ npx @modelcontextprotocol/inspector u2mcp stdio
284
+
285
+ # Or inspect the server in HTTP mode
286
+ # First start the server: u2mcp http --host 0.0.0.0 --port 8000
287
+ # Then run inspector with the URL
288
+ npx @modelcontextprotocol/inspector http://localhost:8000/mcp
289
+ ```
290
+
291
+ The inspector will display:
292
+ - Available tools and their parameters
293
+ - Server resources and prompts
294
+ - Real-time tool execution results
295
+ - Request/response logs
296
+
297
+ ### Using Postman
298
+
299
+ [Postman](https://www.postman.com/) has native MCP support for testing and debugging MCP servers.
300
+
301
+ 1. Open Postman and create a new **MCP Request**
302
+ 2. Enter the server connection details:
303
+
304
+ **STDIO Mode:**
305
+ ```
306
+ Command: u2mcp
307
+ Arguments: stdio
308
+ ```
309
+
310
+ **HTTP Mode:**
311
+ ```
312
+ URL: http://localhost:8000/mcp
313
+ ```
314
+ (First start the server: `u2mcp http --host 0.0.0.0 --port 8000`)
315
+
316
+ 3. Click **Load Capabilities** to connect and discover available tools
317
+ 4. Use the **Tools**, **Resources**, and **Prompts** tabs to interact with the server
318
+ 5. Click **Run** to execute tool calls and view responses
319
+
320
+ For more information, see the [Postman MCP documentation](https://learning.postman.com/docs/postman-ai/mcp-requests/overview/).
321
+
322
+ ### Using cURL
323
+
324
+ You can also test the HTTP endpoint using cURL with JSON-RPC 2.0 requests:
325
+
326
+ ```bash
327
+ # 1. Start the server first
328
+ u2mcp http --host 0.0.0.0 --port 8000
329
+
330
+ # 2. In another terminal, send MCP requests
331
+ curl -X POST http://localhost:8000/mcp \
332
+ -H "Content-Type: application/json" \
333
+ -d '{
334
+ "jsonrpc": "2.0",
335
+ "id": 1,
336
+ "method": "tools/list"
337
+ }'
338
+
339
+ # Call a tool (e.g., list devices)
340
+ curl -X POST http://localhost:8000/mcp \
341
+ -H "Content-Type: application/json" \
342
+ -d '{
343
+ "jsonrpc": "2.0",
344
+ "id": 2,
345
+ "method": "tools/call",
346
+ "params": {
347
+ "name": "device_list",
348
+ "arguments": {}
349
+ }
350
+ }'
351
+ ```
352
+
353
+ ## MCP Client Configuration
354
+
355
+ This MCP server can be used with any MCP-compatible client. Below are configuration instructions for popular clients.
356
+
357
+ ### Claude Desktop
358
+
359
+ Add to your Claude Desktop config file:
360
+
361
+ **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
362
+ **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
363
+
364
+ ```json
365
+ {
366
+ "mcpServers": {
367
+ "android": {
368
+ "command": "uvx",
369
+ "args": ["uiautomator2-mcp-server", "stdio"]
370
+ }
371
+ }
372
+ }
373
+ ```
374
+
375
+ If you installed the package globally, you can also use:
376
+
377
+ ```json
378
+ {
379
+ "mcpServers": {
380
+ "android": {
381
+ "command": "u2mcp",
382
+ "args": ["stdio"]
383
+ }
384
+ }
385
+ }
386
+ ```
387
+
388
+ ### Cursor
389
+
390
+ Cursor is an AI-powered code editor with native MCP support.
391
+
392
+ 1. Open Cursor Settings (Cmd/Ctrl + ,)
393
+ 2. Navigate to **MCP Servers**
394
+ 3. Add a new server:
395
+
396
+ ```json
397
+ {
398
+ "mcpServers": {
399
+ "android": {
400
+ "command": "u2mcp",
401
+ "args": ["stdio"]
402
+ }
403
+ }
404
+ }
405
+ ```
406
+
407
+ ### Cherry Studio
408
+
409
+ [Cherry Studio](https://cherry-ai.com/) is a cross-platform AI desktop client with full MCP support. Ideal for Android device automation tasks.
410
+
411
+ 1. Download and install [Cherry Studio](https://github.com/CherryHQ/cherry-studio)
412
+ 2. Open Settings and navigate to **MCP Servers**
413
+ 3. Click **Add Server** and configure:
414
+
415
+ **Option A: Using uvx (recommended)**
416
+ ```
417
+ Command: uvx
418
+ Arguments: uiautomator2-mcp-server stdio
419
+ ```
420
+
421
+ **Option B: Using installed u2mcp command**
422
+ ```
423
+ Command: u2mcp
424
+ Arguments: stdio
425
+ ```
426
+
427
+ **Option C: HTTP Mode**
428
+ First start the server:
429
+ ```bash
430
+ u2mcp http --host 0.0.0.0 --port 8000 --no-token
431
+ ```
432
+
433
+ Then in Cherry Studio, select HTTP mode and enter:
434
+ ```
435
+ URL: http://localhost:8000/mcp
436
+ ```
437
+
438
+ For detailed MCP configuration in Cherry Studio, see the [official documentation](https://docs.cherry-ai.com/docs/en-us/advanced-basic/mcp/config).
439
+
440
+ ### ChatMCP
441
+
442
+ [ChatMCP](https://github.com/daodao97/chatmcp) is an open-source AI chat client implementing the MCP protocol. Supports multiple LLM providers (OpenAI, Claude, Ollama).
443
+
444
+ 1. Download and install [ChatMCP](https://github.com/daodao97/chatmcp)
445
+ 2. Open Settings and navigate to **MCP Servers**
446
+ 3. Add a new server:
447
+
448
+ **Using uvx (recommended)**
449
+ ```
450
+ Command: uvx
451
+ Arguments: uiautomator2-mcp-server stdio
452
+ ```
453
+
454
+ **Using installed u2mcp command**
455
+ ```
456
+ Command: u2mcp
457
+ Arguments: stdio
458
+ ```
459
+
460
+ **HTTP Mode**
461
+ First start the server:
462
+ ```bash
463
+ u2mcp http --host 0.0.0.0 --port 8000 --no-token
464
+ ```
465
+
466
+ Then in ChatMCP, select HTTP mode and enter:
467
+ ```
468
+ URL: http://localhost:8000/mcp
469
+ ```
470
+
471
+ ### Cline
472
+
473
+ Cline is an AI coding assistant extension that supports MCP.
474
+
475
+ 1. Open Cline settings in your IDE
476
+ 2. Navigate to **MCP Servers** section
477
+ 3. Add the server configuration:
478
+
479
+ ```json
480
+ {
481
+ "android": {
482
+ "command": "u2mcp",
483
+ "args": ["stdio"]
484
+ }
485
+ }
486
+ ```
487
+
488
+ ### Continue
489
+
490
+ Continue is an AI pair programmer extension for VS Code and JetBrains.
491
+
492
+ 1. Install the [Continue extension](https://marketplace.visualstudio.com/items?itemName=Continue.continue)
493
+ 2. Open Continue settings
494
+ 3. Add to your MCP servers configuration:
495
+
496
+ ```json
497
+ {
498
+ "mcpServers": {
499
+ "android": {
500
+ "command": "u2mcp",
501
+ "args": ["stdio"]
502
+ }
503
+ }
504
+ }
505
+ ```
506
+
507
+ ### HTTP Mode Configuration
508
+
509
+ For clients that support HTTP connections (or for remote access), start the server first:
510
+
511
+ ```bash
512
+ u2mcp http --host 0.0.0.0 --port 8000 --no-token
513
+ ```
514
+
515
+ Then configure your client to connect to `http://localhost:8000/mcp`.
516
+
517
+ **Note:** Check your client's documentation for HTTP MCP server configuration, as the setup varies by client.
518
+
519
+ ### Other MCP Clients
520
+
521
+ The server follows the [Model Context Protocol](https://modelcontextprotocol.io/) specification and can be used with any MCP-compatible client, including:
522
+
523
+ - **Windsurf** - Development environment with MCP support
524
+ - **Zed** - Code editor with MCP capabilities
525
+ - **LibreChat** - Chat interface supporting MCP
526
+ - **Chainlit** - Platform for building AI applications
527
+
528
+ Refer to your client's documentation for specific configuration details.
529
+
530
+ ## Quick Start
531
+
532
+ 1. **Connect your Android device** via USB with USB debugging enabled
533
+ 2. **Initialize the device** (required first time):
534
+
535
+ > "Initialize my Android device"
536
+
537
+ 3. **Start automating**:
538
+
539
+ > "Take a screenshot"
540
+ > "Tap at coordinates 500, 1000"
541
+ > "Swipe up"
542
+ > "Open YouTube app"
543
+
544
+ ## AI-Driven UI Testing
545
+
546
+ This project includes an AI-driven UI testing framework using the `.skills/` system. The `android-ui-test` skill serves a dual purpose:
547
+
548
+ 1. **Educational Example**: Demonstrates best practices for MCP skill development
549
+ 2. **Production Testing**: Acts as the project's automated UI test suite for CI/CD
550
+
551
+ ### Skill Structure
552
+
553
+ ```
554
+ .skills/android-ui-test/
555
+ ├── SKILL.md # Core skill definition (YAML metadata)
556
+ ├── README.md # Architecture overview and quick start
557
+ ├── examples/ # Learning materials
558
+ │ └── usage-examples.md # Detailed usage patterns and examples
559
+ ├── references/ # Technical specifications
560
+ │ └── test-specification.md # Complete test specification (TC001-TC008)
561
+ └── (scripts/) # Executable scripts (in project root)
562
+ └── demo-android-test.py # Demonstration script
563
+ ```
564
+
565
+ ### Running UI Tests
566
+
567
+ Simply ask the AI to execute the UI test:
568
+
569
+ ```
570
+ Run the Android UI test suite on my connected device
571
+ ```
572
+
573
+ The AI will:
574
+ - Auto-detect and connect to the first available device
575
+ - Run comprehensive tests covering all device operations
576
+ - Provide a detailed test report with pass/fail/skip status
577
+
578
+ ### Test Coverage
579
+
580
+ | Category | Tests |
581
+ | --------- | --------------------------------------- |
582
+ | Device | Connection, Info, Screenshot, Hierarchy |
583
+ | Touch | Click, Long Click, Double Click |
584
+ | Gesture | Swipe, Drag, Key Press |
585
+ | App | List, Start, Wait, Info |
586
+ | Element | Wait, Bounds, Get Text, Click |
587
+ | Input | Text Input, Keyboard |
588
+ | Clipboard | Read/Write (with known limitations) |
589
+
590
+ ### Sample Test Report
591
+
592
+ ```
593
+ Android UI Test Summary
594
+ =======================
595
+
596
+ Device: UGAILFCIU88TT469 (PDKM00, Android 11, SDK 31)
597
+
598
+ Test Cases:
599
+ [PASS] TC001: Device Connection & Initialization
600
+ [PASS] TC002: Device Info & Capture
601
+ [PASS] TC003: Touch Actions
602
+ [PASS] TC004: Gesture Actions
603
+ [PASS] TC005: Application Management
604
+ [PASS] TC006: Element Operations
605
+ [PASS] TC007: Input & Keyboard
606
+ [SKIP] TC008: Clipboard Operations (Android security restriction)
607
+
608
+ Total: 7 passed, 1 skipped, 0 failed
609
+ ```
610
+
611
+ ### Creating Custom Skills
612
+
613
+ See [`.skills/android-ui-test/`](.skills/android-ui-test/) for a complete reference implementation.
614
+
615
+ Each skill directory contains:
616
+ - `SKILL.md` - YAML frontmatter with metadata and lightweight description
617
+ - `examples/` - Detailed usage patterns for learning
618
+ - `references/` - Technical specifications and test cases
619
+
620
+ ## Available Tools
621
+
622
+ ### Device
623
+ | Tool | Description |
624
+ | ----------------- | ------------------------------------------------------------------------------------------------------------- |
625
+ | `device_list` | List connected Adb devices |
626
+ | `init` | Install required resources to device (**run first**) |
627
+ | `purge` | Purge installed uiautomator resources from device |
628
+ | `connect` | Connect to a device (returns device info) |
629
+ | `disconnect` | Disconnect a device |
630
+ | `disconnect_all` | Disconnect all devices |
631
+ | `shell_command` | Run shell command on device (returns `(exit_code, output)`) |
632
+ | `window_size` | Get device window size (`width`, `height`) |
633
+ | `screenshot` | Take screenshot (returns `width`, `height`, `image` where `image` is a data URL `data:image/jpeg;base64,...`) |
634
+ | `save_screenshot` | Save screenshot to file (returns file path, format determined by file extension) |
635
+ | `dump_hierarchy` | Get UI hierarchy XML |
636
+ | `info` | Get device information |
637
+
638
+ ### Actions
639
+ | Tool | Description |
640
+ | -------------- | ------------------------------ |
641
+ | `click` | Tap at coordinates |
642
+ | `long_click` | Long press at coordinates |
643
+ | `double_click` | Double tap at coordinates |
644
+ | `swipe` | Swipe from point A to B |
645
+ | `swipe_points` | Swipe through multiple points |
646
+ | `drag` | Drag from point A to B |
647
+ | `press_key` | Press a key (home, back, etc.) |
648
+ | `screen_on` | Turn screen on |
649
+ | `screen_off` | Turn screen off |
650
+
651
+ ### Input
652
+ | Tool | Description |
653
+ | --------------- | --------------------------------- |
654
+ | `send_text` | Type text (supports `clear` flag) |
655
+ | `clear_text` | Clear text field |
656
+ | `hide_keyboard` | Hide virtual keyboard |
657
+
658
+ ### Apps
659
+ | Tool | Description |
660
+ | ---------------------------- | -------------------------------------------- |
661
+ | `app_install` | Install APK (file path or url) |
662
+ | `app_uninstall` | Uninstall an app |
663
+ | `app_uninstall_all` | Uninstall many apps (with excludes) |
664
+ | `app_start` | Launch an app |
665
+ | `app_wait` | Wait until app launched (`timeout`, `front`) |
666
+ | `app_stop` | Stop an app |
667
+ | `app_stop_all` | Stop all third-party apps (with excludes) |
668
+ | `app_clear` | Clear app data |
669
+ | `app_info` | Get app info (`versionName`, `versionCode`) |
670
+ | `app_current` | Get current foreground app |
671
+ | `app_list` | List installed apps (supports `filter`) |
672
+ | `app_list_running` | List running apps |
673
+ | `app_auto_grant_permissions` | Auto grant runtime permissions to app |
674
+
675
+ ### Clipboard
676
+ | Tool | Description |
677
+ | ----------------- | ------------------------------- |
678
+ | `read_clipboard` | Read clipboard text from device |
679
+ | `write_clipboard` | Write text to device clipboard |
680
+
681
+ ### Element
682
+ | Tool | Description |
683
+ | -------------------------- | ------------------------------------------------------------------- |
684
+ | `activity_wait` | Wait until an activity appears |
685
+ | `element_wait` | Wait until element found |
686
+ | `element_wait_gone` | Wait until element gone |
687
+ | `element_click` | Find element by xpath and click (waits) |
688
+ | `element_click_nowait` | Click element without waiting |
689
+ | `element_click_until_gone` | Click until element disappears |
690
+ | `element_long_click` | Long click element |
691
+ | `element_screenshot` | Take element screenshot (returns same image format as `screenshot`) |
692
+ | `element_get_text` | Get element text |
693
+ | `element_set_text` | Set element text |
694
+ | `element_bounds` | Get element bounds (left, top, right, bottom) |
695
+ | `element_swipe` | Swipe inside an element |
696
+ | `element_scroll` | Scroll an element (`forward`/`backward`) |
697
+ | `element_scroll_to` | Scroll to element with max swipes |
698
+
699
+ ### Scrcpy
700
+ | Tool | Description |
701
+ | -------------- | -------------------------------------------------------- |
702
+ | `start_scrcpy` | Start `scrcpy` in background and return process id (pid) |
703
+ | `stop_scrcpy` | Stop a running `scrcpy` process by pid |
704
+
705
+ > **Notes:**
706
+ > - `screenshot` and `element_screenshot` return image data in a JPEG data URL (`data:image/jpeg;base64,...`) along with `width`/`height`.
707
+ > - `shell_command` returns a tuple `(exit_code, output)`.
708
+ > - `start_scrcpy` returns a background process id (pid) which can be passed to `stop_scrcpy`.
709
+
710
+ ## Example Usage
711
+
712
+ ```txt
713
+ You: Take a screenshot
714
+ Claude: [Uses screenshot tool, displays image]
715
+
716
+ You: What apps are installed?
717
+ Claude: [Lists installed apps using app_list]
718
+
719
+ You: Open the YouTube app
720
+ Claude: [Uses app_start with package name]
721
+
722
+ You: Search for "cats"
723
+ Claude: [Uses click to tap search bar, then send_text to type "cats"]
724
+
725
+ You: Scroll down
726
+ Claude: [Uses swipe to scroll down]
727
+ ```
728
+
729
+ ## License
730
+
731
+ Apache-2.0
732
+
733
+ ------
734
+
735
+ [python]: https://www.python.org/ "Python is a programming language that lets you work quickly and integrate systems more effectively."
736
+ [pip]: https://pip.pypa.io/ "The most popular tool for installing Python packages, and the one included with modern versions of Python."
737
+ [pipx]: https://pipx.pypa.io/ "pipx is a tool to install and run Python command-line applications without causing dependency conflicts with other packages installed on the system."
738
+ [uv]: https://docs.astral.sh/uv/ "An extremely fast Python package and project manager"