mcp-maestro-mobile-ai 1.1.0 → 1.3.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/CHANGELOG.md +29 -0
- package/docs/MCP_SETUP.md +246 -41
- package/package.json +4 -1
- package/scripts/check-prerequisites.js +277 -0
- package/src/mcp-server/index.js +202 -11
- package/src/mcp-server/tools/contextTools.js +123 -0
- package/src/mcp-server/tools/runTools.js +227 -4
- package/src/mcp-server/utils/prerequisites.js +390 -0
- package/src/mcp-server/utils/reportGenerator.js +455 -0
- package/src/mcp-server/utils/yamlTemplate.js +559 -0
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
+
## [1.2.0] - 2025-01-06
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- **YAML Generation Instructions System**: Ensures consistent YAML generation across different environments
|
|
22
|
+
- `get_yaml_instructions` - AI MUST call this before generating YAML (provides exact rules)
|
|
23
|
+
- `validate_yaml_structure` - Validates YAML for common issues (like missing tapOn before inputText)
|
|
24
|
+
- `get_test_pattern` - Get standard patterns for login, search, navigation, form tests
|
|
25
|
+
- **Critical Fix**: Input text pattern now enforced - prevents password going to username field issue
|
|
26
|
+
- Standard test patterns for common scenarios (login, search, navigation, form)
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
- YAML generation inconsistency between different environments
|
|
30
|
+
- Text input going to wrong fields due to missing tapOn commands
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## [1.1.1] - 2025-01-06
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
- Version bump for npm publish
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
18
41
|
## [1.1.0] - 2025-01-06
|
|
19
42
|
|
|
20
43
|
### Changed
|
|
@@ -23,6 +46,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
23
46
|
- Test results and screenshots now stored in `~/.maestro-mcp/output/`
|
|
24
47
|
|
|
25
48
|
### Added
|
|
49
|
+
- **Automatic Prerequisites Check**:
|
|
50
|
+
- Runs automatically after `npm install`
|
|
51
|
+
- Checks for Node.js 18+, Java 17+, Maestro CLI, Android SDK
|
|
52
|
+
- Shows clear error messages with installation hints
|
|
53
|
+
- Manual check available via `npm run check`
|
|
54
|
+
- **Runtime Validation**: Server validates prerequisites on startup and exits gracefully if critical deps missing
|
|
26
55
|
- **App Context Training System**: New tools to teach the AI about your app's UI
|
|
27
56
|
- `register_elements` - Register testIDs, accessibilityLabels for app elements
|
|
28
57
|
- `register_screen` - Define screen structures and available actions
|
package/docs/MCP_SETUP.md
CHANGED
|
@@ -1,18 +1,113 @@
|
|
|
1
1
|
# MCP Server Setup Guide
|
|
2
2
|
|
|
3
|
-
## Setting up Maestro
|
|
3
|
+
## Setting up MCP Maestro Mobile AI with AI Clients
|
|
4
4
|
|
|
5
|
-
This guide explains how to configure the Maestro
|
|
5
|
+
This guide explains how to configure the MCP Maestro Mobile AI server with different AI clients.
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## Prerequisites
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
### Required Dependencies
|
|
12
|
+
|
|
13
|
+
| Prerequisite | Version | Installation |
|
|
14
|
+
| --------------- | ------- | ------------------------------------- |
|
|
15
|
+
| **Node.js** | 18+ | [nodejs.org](https://nodejs.org/) |
|
|
16
|
+
| **Java** | 17+ | [adoptium.net](https://adoptium.net/) |
|
|
17
|
+
| **Maestro CLI** | Latest | See below |
|
|
18
|
+
| **Android SDK** | Any | Android Studio or standalone |
|
|
19
|
+
|
|
20
|
+
### Install Maestro CLI
|
|
21
|
+
|
|
22
|
+
**macOS / Linux:**
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
curl -Ls https://get.maestro.mobile.dev | bash
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Windows (PowerShell):**
|
|
29
|
+
|
|
30
|
+
```powershell
|
|
31
|
+
iwr https://get.maestro.mobile.dev | iex
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Automatic Prerequisites Check ✨
|
|
35
|
+
|
|
36
|
+
When you install the package, it **automatically checks** all prerequisites:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
npm install -g mcp-maestro-mobile-ai
|
|
40
|
+
|
|
41
|
+
╔════════════════════════════════════════════════════════╗
|
|
42
|
+
║ MCP Maestro Mobile AI - Prerequisites ║
|
|
43
|
+
╚════════════════════════════════════════════════════════╝
|
|
44
|
+
|
|
45
|
+
✅ Node.js v20.x
|
|
46
|
+
✅ Java 17
|
|
47
|
+
✅ Maestro 2.0.10
|
|
48
|
+
✅ Android SDK configured
|
|
49
|
+
|
|
50
|
+
✅ All prerequisites satisfied!
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
If any prerequisite is missing, you'll see:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
❌ Java not found
|
|
57
|
+
❌ Maestro CLI not found
|
|
58
|
+
|
|
59
|
+
⚠️ Some required prerequisites are missing.
|
|
60
|
+
|
|
61
|
+
💡 Installation hints:
|
|
62
|
+
→ Install Java 17+ from https://adoptium.net/
|
|
63
|
+
→ Install Maestro: curl -Ls https://get.maestro.mobile.dev | bash
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Manual Check
|
|
67
|
+
|
|
68
|
+
You can manually check prerequisites anytime:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# If installed globally
|
|
72
|
+
npm run check
|
|
73
|
+
|
|
74
|
+
# Or run directly
|
|
75
|
+
npx mcp-maestro-mobile-ai check
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Runtime Validation
|
|
79
|
+
|
|
80
|
+
The server also validates prerequisites **when it starts**. If Java or Maestro is missing, the server will:
|
|
81
|
+
|
|
82
|
+
1. Show clear error messages
|
|
83
|
+
2. Provide installation hints
|
|
84
|
+
3. Exit with code 2 (infrastructure error)
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Installation Options
|
|
89
|
+
|
|
90
|
+
### Option 1: NPX (Recommended - No Install)
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
npx mcp-maestro-mobile-ai
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Option 2: Global Install
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
npm install -g mcp-maestro-mobile-ai
|
|
100
|
+
maestro-mcp
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Option 3: Clone from GitHub
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
git clone https://github.com/krunal-mahera/mcp-maestro-mobile-ai.git
|
|
107
|
+
cd mcp-maestro-mobile-ai
|
|
108
|
+
npm install
|
|
109
|
+
npm start
|
|
110
|
+
```
|
|
16
111
|
|
|
17
112
|
---
|
|
18
113
|
|
|
@@ -21,29 +116,62 @@ This guide explains how to configure the Maestro MCP Server with different AI cl
|
|
|
21
116
|
### Step 1: Find your Cursor MCP config file
|
|
22
117
|
|
|
23
118
|
The config file is located at:
|
|
119
|
+
|
|
24
120
|
- **Windows**: `%USERPROFILE%\.cursor\mcp.json`
|
|
25
121
|
- **macOS**: `~/.cursor/mcp.json`
|
|
26
122
|
- **Linux**: `~/.cursor/mcp.json`
|
|
27
123
|
|
|
28
124
|
### Step 2: Add the Maestro server
|
|
29
125
|
|
|
30
|
-
|
|
126
|
+
**If installed via NPM (global):**
|
|
31
127
|
|
|
32
128
|
```json
|
|
33
129
|
{
|
|
34
130
|
"mcpServers": {
|
|
35
131
|
"maestro": {
|
|
36
|
-
"command": "
|
|
37
|
-
"
|
|
132
|
+
"command": "maestro-mcp",
|
|
133
|
+
"env": {
|
|
134
|
+
"APP_ID": "com.your.app.package",
|
|
135
|
+
"ANDROID_HOME": "C:/Users/YourName/AppData/Local/Android/Sdk"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**If using NPX:**
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"mcpServers": {
|
|
147
|
+
"maestro": {
|
|
148
|
+
"command": "npx",
|
|
149
|
+
"args": ["mcp-maestro-mobile-ai"],
|
|
38
150
|
"env": {
|
|
39
|
-
"APP_ID": "com.
|
|
151
|
+
"APP_ID": "com.your.app.package",
|
|
152
|
+
"ANDROID_HOME": "C:/Users/YourName/AppData/Local/Android/Sdk"
|
|
40
153
|
}
|
|
41
154
|
}
|
|
42
155
|
}
|
|
43
156
|
}
|
|
44
157
|
```
|
|
45
158
|
|
|
46
|
-
**
|
|
159
|
+
**If cloned from GitHub:**
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"mcpServers": {
|
|
164
|
+
"maestro": {
|
|
165
|
+
"command": "node",
|
|
166
|
+
"args": ["C:/path/to/mcp-maestro-mobile-ai/src/mcp-server/index.js"],
|
|
167
|
+
"env": {
|
|
168
|
+
"APP_ID": "com.your.app.package",
|
|
169
|
+
"ANDROID_HOME": "C:/Users/YourName/AppData/Local/Android/Sdk"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
```
|
|
47
175
|
|
|
48
176
|
### Step 3: Restart Cursor
|
|
49
177
|
|
|
@@ -52,6 +180,7 @@ Close and reopen Cursor for the changes to take effect.
|
|
|
52
180
|
### Step 4: Verify
|
|
53
181
|
|
|
54
182
|
In Cursor's AI chat, type:
|
|
183
|
+
|
|
55
184
|
```
|
|
56
185
|
List the available MCP tools
|
|
57
186
|
```
|
|
@@ -69,8 +198,9 @@ If there's an MCP extension for VS Code Copilot, configure it similarly to Curso
|
|
|
69
198
|
### Option 2: Run Server Manually
|
|
70
199
|
|
|
71
200
|
1. Start the MCP server:
|
|
201
|
+
|
|
72
202
|
```bash
|
|
73
|
-
cd
|
|
203
|
+
cd path/to/mcp-maestro-mobile-ai
|
|
74
204
|
npm start
|
|
75
205
|
```
|
|
76
206
|
|
|
@@ -78,103 +208,178 @@ If there's an MCP extension for VS Code Copilot, configure it similarly to Curso
|
|
|
78
208
|
|
|
79
209
|
---
|
|
80
210
|
|
|
211
|
+
## Claude Desktop Setup
|
|
212
|
+
|
|
213
|
+
Edit `~/.claude/claude_desktop_config.json` (macOS/Linux) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
|
|
214
|
+
|
|
215
|
+
```json
|
|
216
|
+
{
|
|
217
|
+
"mcpServers": {
|
|
218
|
+
"maestro": {
|
|
219
|
+
"command": "npx",
|
|
220
|
+
"args": ["mcp-maestro-mobile-ai"],
|
|
221
|
+
"env": {
|
|
222
|
+
"APP_ID": "com.your.app.package"
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
81
231
|
## Testing the Setup
|
|
82
232
|
|
|
83
|
-
### 1. Check
|
|
233
|
+
### 1. Check Prerequisites
|
|
234
|
+
|
|
235
|
+
Ask the AI:
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
Check if maestro device is connected
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### 2. Check Configuration
|
|
84
242
|
|
|
85
243
|
Ask the AI:
|
|
244
|
+
|
|
86
245
|
```
|
|
87
246
|
Get the app configuration
|
|
88
247
|
```
|
|
89
248
|
|
|
90
249
|
Expected response:
|
|
250
|
+
|
|
91
251
|
```json
|
|
92
252
|
{
|
|
93
253
|
"success": true,
|
|
94
254
|
"config": {
|
|
95
|
-
"appId": "com.
|
|
255
|
+
"appId": "com.your.app.package",
|
|
96
256
|
"platform": "android"
|
|
97
257
|
}
|
|
98
258
|
}
|
|
99
259
|
```
|
|
100
260
|
|
|
101
|
-
###
|
|
261
|
+
### 3. List Prompt Files
|
|
102
262
|
|
|
103
263
|
Ask the AI:
|
|
264
|
+
|
|
104
265
|
```
|
|
105
266
|
List available prompt files
|
|
106
267
|
```
|
|
107
268
|
|
|
108
|
-
###
|
|
269
|
+
### 4. Run a Test
|
|
109
270
|
|
|
110
271
|
Ask the AI:
|
|
272
|
+
|
|
111
273
|
```
|
|
112
|
-
Run a test:
|
|
274
|
+
Run a test: Open the app and verify the login screen is visible
|
|
113
275
|
```
|
|
114
276
|
|
|
115
277
|
---
|
|
116
278
|
|
|
117
279
|
## Environment Variables
|
|
118
280
|
|
|
119
|
-
|
|
281
|
+
| Variable | Required | Description |
|
|
282
|
+
| ---------------------- | ----------- | ----------------------------------------- |
|
|
283
|
+
| `APP_ID` | Yes | Target app package ID |
|
|
284
|
+
| `ANDROID_HOME` | Recommended | Android SDK path |
|
|
285
|
+
| `DEFAULT_WAIT_TIMEOUT` | No | Element wait timeout (ms, default: 10000) |
|
|
286
|
+
| `DEFAULT_RETRIES` | No | Auto-retry count (default: 1) |
|
|
287
|
+
| `MAX_RESULTS` | No | Max result files to keep (default: 50) |
|
|
288
|
+
|
|
289
|
+
Example config with all options:
|
|
120
290
|
|
|
121
291
|
```json
|
|
122
292
|
{
|
|
123
293
|
"mcpServers": {
|
|
124
294
|
"maestro": {
|
|
125
|
-
"command": "
|
|
126
|
-
"args": ["path/to/src/mcp-server/index.js"],
|
|
295
|
+
"command": "maestro-mcp",
|
|
127
296
|
"env": {
|
|
128
297
|
"APP_ID": "com.mycompany.myapp",
|
|
129
298
|
"ANDROID_HOME": "C:/Users/Me/Android/Sdk",
|
|
130
|
-
"
|
|
299
|
+
"DEFAULT_WAIT_TIMEOUT": "15000",
|
|
300
|
+
"DEFAULT_RETRIES": "2",
|
|
301
|
+
"MAX_RESULTS": "100"
|
|
131
302
|
}
|
|
132
303
|
}
|
|
133
304
|
}
|
|
134
305
|
}
|
|
135
306
|
```
|
|
136
307
|
|
|
137
|
-
Or create a `.env` file in the project root.
|
|
138
|
-
|
|
139
308
|
---
|
|
140
309
|
|
|
141
310
|
## Troubleshooting
|
|
142
311
|
|
|
312
|
+
### Prerequisites Check Failed
|
|
313
|
+
|
|
314
|
+
Run the manual check to see what's missing:
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
npm run check
|
|
318
|
+
```
|
|
319
|
+
|
|
143
320
|
### Server doesn't start
|
|
144
321
|
|
|
145
|
-
1. Check
|
|
146
|
-
2. Check
|
|
147
|
-
3. Check
|
|
322
|
+
1. Check prerequisites: `npm run check`
|
|
323
|
+
2. Check Node.js version: `node --version` (must be 18+)
|
|
324
|
+
3. Check Java version: `java --version` (must be 17+)
|
|
325
|
+
4. Check Maestro: `maestro --version`
|
|
148
326
|
|
|
149
|
-
### Tools not appearing
|
|
327
|
+
### Tools not appearing in AI chat
|
|
150
328
|
|
|
151
|
-
1. Restart your editor
|
|
329
|
+
1. Restart your editor completely
|
|
152
330
|
2. Check the MCP config path is correct
|
|
153
|
-
3. Verify the
|
|
331
|
+
3. Verify the command/args in the config
|
|
332
|
+
4. Check for JSON syntax errors in config
|
|
154
333
|
|
|
155
334
|
### Tests fail with "No emulator"
|
|
156
335
|
|
|
157
336
|
1. Start an Android emulator
|
|
158
337
|
2. Verify with `adb devices`
|
|
338
|
+
3. Make sure device shows as "device" not "offline"
|
|
159
339
|
|
|
160
340
|
### "APP_ID not configured"
|
|
161
341
|
|
|
162
342
|
Set the `APP_ID` in either:
|
|
343
|
+
|
|
163
344
|
- The MCP config's `env` section
|
|
164
345
|
- A `.env` file in the project root
|
|
165
346
|
|
|
347
|
+
### "ADB not found"
|
|
348
|
+
|
|
349
|
+
Set `ANDROID_HOME` in your MCP config:
|
|
350
|
+
|
|
351
|
+
```json
|
|
352
|
+
"env": {
|
|
353
|
+
"ANDROID_HOME": "C:/Users/YourName/AppData/Local/Android/Sdk"
|
|
354
|
+
}
|
|
355
|
+
```
|
|
356
|
+
|
|
166
357
|
---
|
|
167
358
|
|
|
168
359
|
## Available Tools
|
|
169
360
|
|
|
170
|
-
| Tool
|
|
171
|
-
|
|
172
|
-
| `read_prompt_file`
|
|
173
|
-
| `list_prompt_files`
|
|
174
|
-
| `
|
|
175
|
-
| `
|
|
176
|
-
| `
|
|
177
|
-
| `
|
|
178
|
-
| `
|
|
179
|
-
| `
|
|
180
|
-
|
|
361
|
+
| Tool | Description |
|
|
362
|
+
| ----------------------- | ---------------------------------- |
|
|
363
|
+
| `read_prompt_file` | Read test prompts from a file |
|
|
364
|
+
| `list_prompt_files` | List available prompt files |
|
|
365
|
+
| `list_devices` | List connected Android devices |
|
|
366
|
+
| `select_device` | Select a specific device |
|
|
367
|
+
| `clear_device` | Clear device selection |
|
|
368
|
+
| `check_device` | Check device connection |
|
|
369
|
+
| `check_app` | Check if app is installed |
|
|
370
|
+
| `get_app_config` | Get app configuration |
|
|
371
|
+
| `validate_maestro_yaml` | Validate Maestro YAML |
|
|
372
|
+
| `run_test` | Run a single test |
|
|
373
|
+
| `run_test_suite` | Run multiple tests |
|
|
374
|
+
| `get_test_results` | Get test results |
|
|
375
|
+
| `take_screenshot` | Take a screenshot |
|
|
376
|
+
| `cleanup_results` | Clean up old results |
|
|
377
|
+
| `register_elements` | Register UI elements for better AI |
|
|
378
|
+
| `register_screen` | Register screen structure |
|
|
379
|
+
| `save_successful_flow` | Save working flow pattern |
|
|
380
|
+
| `get_saved_flows` | Get saved patterns |
|
|
381
|
+
| `delete_flow` | Delete a saved pattern |
|
|
382
|
+
| `get_ai_context` | Get context for AI generation |
|
|
383
|
+
| `get_full_context` | Get complete context data |
|
|
384
|
+
| `clear_app_context` | Clear app context |
|
|
385
|
+
| `list_app_contexts` | List apps with context |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-maestro-mobile-ai",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "MCP Server for AI-Assisted Mobile Automation using Maestro - Run mobile tests with natural language prompts",
|
|
6
6
|
"main": "src/mcp-server/index.js",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"src/",
|
|
13
|
+
"scripts/",
|
|
13
14
|
"prompts/",
|
|
14
15
|
"templates/",
|
|
15
16
|
"docs/",
|
|
@@ -32,6 +33,8 @@
|
|
|
32
33
|
"dev": "node --watch src/mcp-server/index.js",
|
|
33
34
|
"test:flow": "maestro test",
|
|
34
35
|
"lint": "eslint src/",
|
|
36
|
+
"postinstall": "node scripts/check-prerequisites.js",
|
|
37
|
+
"check": "node scripts/check-prerequisites.js",
|
|
35
38
|
"prepublishOnly": "npm run lint"
|
|
36
39
|
},
|
|
37
40
|
"keywords": [
|