@deriv-com/fe-mcp-servers 0.0.10 → 0.0.12

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,610 @@
1
+ # Maestro AI MCP Server
2
+
3
+ A Model Context Protocol (MCP) server that provides automated Maestro test generation for web applications with best practices, templates, and guidelines baked in.
4
+
5
+ ## 🚀 Installation & Setup
6
+
7
+ ### Step 1: Install the Package
8
+
9
+ ```bash
10
+ npm install -g @deriv-com/fe-mcp-servers
11
+ ```
12
+
13
+ ### Step 2: Get Configuration Path
14
+
15
+ Get the exact path for your MCP configuration:
16
+
17
+ ```bash
18
+ echo "$(npm root -g)/@deriv-com/fe-mcp-servers/dist/maestro-ai/mcp-server.js"
19
+ ```
20
+
21
+ **Important**: Use the **bundled executable path** (without `src/`) for MCP configuration.
22
+
23
+ ### Step 3: Configure MCP Client
24
+
25
+ Add to your MCP client configuration (e.g., in Cursor settings):
26
+
27
+ ```json
28
+ {
29
+ "mcpServers": {
30
+ "maestro-ai": {
31
+ "command": "node",
32
+ "args": [
33
+ "/Users/user/.nvm/versions/node/v20.17.0/lib/node_modules/@deriv-com/fe-mcp-servers/dist/maestro-ai/mcp-server.js"
34
+ ]
35
+ }
36
+ }
37
+ }
38
+ ```
39
+
40
+ ## 🛠️ Development Structure
41
+
42
+ ### Source Code (Development)
43
+
44
+ ```
45
+ maestro-ai/
46
+ ├── src/
47
+ │ ├── mcp-server.js # Main MCP server implementation
48
+ │ ├── mcp.js # Core Maestro test generation functionality
49
+ │ └── test-mcp.js # Test suite
50
+ └── README.md # This documentation
51
+ ```
52
+
53
+ ### Built Output (Distribution)
54
+
55
+ After building, the package creates:
56
+
57
+ ```
58
+ dist/
59
+ └── maestro-ai/
60
+ ├── mcp-server.js # Bundled executable (all dependencies included)
61
+ └── README.md # Documentation
62
+ ```
63
+
64
+ ## 🔧 Build Process
65
+
66
+ The build process uses esbuild to:
67
+
68
+ 1. Bundle all dependencies into a single file
69
+ 2. Create a standalone executable
70
+ 3. Include proper Node.js shebang for direct execution
71
+ 4. No external dependency resolution needed at runtime
72
+
73
+ ## ⚡ Available Tools
74
+
75
+ ### `maestro_generate_test` Tool
76
+
77
+ Generates comprehensive Maestro test YAML with templates, guidelines, and checklists.
78
+
79
+ **Parameters:**
80
+
81
+ - `feature` (string, required): The feature being tested (e.g., "User Settings")
82
+ - `action` (string, required): The action being tested (e.g., "Reset defaults")
83
+ - `flowType` (string, optional): Type of flow - `auth`, `sidebar`, `form`, `modal`, `navigation`, `extended`
84
+ - `changedElements` (array, optional): List of UI elements that were changed
85
+ - `existingTests` (array, optional): List of existing related test files
86
+
87
+ **Returns:**
88
+
89
+ - Generated YAML template with proper structure
90
+ - Change verification checklist
91
+ - Quality guidelines and suggested filename
92
+
93
+ ### `maestro_cheat_sheet` Tool
94
+
95
+ Returns Maestro commands quick reference including selector strategy, waiting strategy, and file naming conventions.
96
+
97
+ **Parameters:**
98
+
99
+ - None required
100
+
101
+ **Returns:**
102
+
103
+ - Complete command reference table
104
+ - Selector priority order (text → id → index → repeat)
105
+ - Environment variable setup examples
106
+
107
+ ### `maestro_flow_template` Tool
108
+
109
+ Returns a specific Maestro flow template by type.
110
+
111
+ **Parameters:**
112
+
113
+ - `flowType` (string, required): `auth`, `sidebar`, `form`, `modal`, `navigation`, `extended`
114
+ - `name` (string, optional): Custom flow name
115
+ - `baseUrl` (string, optional): Override default URL
116
+ - `waitForElement` (string, optional): Initial element to wait for
117
+ - `baseFlow` (string, optional): For extended type, base flow to extend
118
+
119
+ **Returns:**
120
+
121
+ - Ready-to-use YAML template for the specified flow type
122
+
123
+ ### `maestro_ui_inspection` Tool
124
+
125
+ Returns UI inspection guidelines and checklist for proper element discovery.
126
+
127
+ **Parameters:**
128
+
129
+ - None required
130
+
131
+ **Returns:**
132
+
133
+ - MCP tool usage instructions
134
+ - Source code grep patterns
135
+ - ID vs data-testid distinction guide
136
+
137
+ ### `maestro_pattern` Tool
138
+
139
+ Returns common Maestro patterns with "when to use" guidance.
140
+
141
+ **Parameters:**
142
+
143
+ - `patternType` (string, optional): `login`, `form`, `onboarding`, `slider`, `waitVisible`, `waitNotVisible`, `runFlow`
144
+
145
+ **Returns:**
146
+
147
+ - Pattern YAML code
148
+ - Usage guidance for each pattern
149
+
150
+ ### `maestro_ensure_installed` Tool
151
+
152
+ ⚠️ **PREREQUISITE**: Call this FIRST before using `maestro_write_test` or `maestro_run_all_tests`!
153
+
154
+ Checks if Maestro CLI is installed and automatically installs it if missing.
155
+
156
+ **When to Call:**
157
+
158
+ - ALWAYS before `maestro_write_test` (when execute=true)
159
+ - ALWAYS before `maestro_run_all_tests`
160
+ - When setting up a new development environment
161
+
162
+ **Parameters:**
163
+
164
+ - `autoInstall` (boolean, optional): Whether to automatically install if not found (default: true)
165
+ - `forceReinstall` (boolean, optional): Whether to force reinstall even if already installed (default: false)
166
+
167
+ **Returns:**
168
+
169
+ - `installed`: boolean - Whether Maestro is now installed
170
+ - `version`: string - Installed version (if available)
171
+ - `wasInstalled`: boolean - Whether this call performed the installation
172
+ - `message`: string - Status message
173
+ - `details`: object - Additional info (path, install method)
174
+
175
+ **Installation Method:**
176
+
177
+ ```bash
178
+ curl -fsSL "https://get.maestro.mobile.dev" | bash
179
+ ```
180
+
181
+ ### `maestro_analyze_changes` Tool
182
+
183
+ Automatically analyzes actual git changes in a repository and provides test recommendations.
184
+
185
+ **Parameters:**
186
+
187
+ - `repoPath` (string, required): Path to the git repository
188
+ - `changeType` (string, optional): `all`, `unstaged`, `staged`, `lastCommit`, `branch`
189
+ - `baseBranch` (string, optional): Base branch for comparison (default: "main")
190
+ - `fileFilter` (string, optional): Comma-separated patterns to filter files
191
+
192
+ **Returns:**
193
+
194
+ - List of changed files (unstaged, staged, UI files)
195
+ - Interactive elements detected (onClick, Button, Form, etc.)
196
+ - Suggested flow type and whether to create tests
197
+
198
+ ---
199
+
200
+ ## 🚀 Test Execution Tools
201
+
202
+ ### `maestro_write_test` Tool
203
+
204
+ Writes a Maestro test YAML file to disk.
205
+
206
+ **Parameters:**
207
+
208
+ - `yaml` (string, required): The YAML content to write
209
+ - `fileName` (string, required): Name of the file (e.g., "login_test.yaml")
210
+ - `directory` (string, optional): Target directory (default: "maestro")
211
+ - `basePath` (string, optional): Project base path (default: current directory)
212
+
213
+ **Returns:**
214
+
215
+ - `success`: boolean
216
+ - `filePath`: Path where file was written
217
+ - `message`: Status message
218
+
219
+ ### `maestro_execute_test` Tool
220
+
221
+ Executes a single Maestro test file using the Maestro CLI.
222
+
223
+ **Prerequisites:**
224
+
225
+ - Maestro CLI must be installed (`curl -fsSL https://get.maestro.dev | bash`)
226
+ - A device/simulator must be running
227
+
228
+ **Parameters:**
229
+
230
+ - `flowFile` (string, required): Path to the .yaml flow file
231
+ - `deviceId` (string, optional): Target device ID
232
+ - `env` (object, optional): Environment variables to pass
233
+ - `timeout` (number, optional): Execution timeout in ms (default: 120000)
234
+
235
+ **Returns:**
236
+
237
+ - `success`: boolean
238
+ - `output`: Test output/logs
239
+ - `exitCode`: Process exit code
240
+ - `duration`: Execution time in ms
241
+
242
+ ### `maestro_execute_tests_sequential` Tool
243
+
244
+ Executes multiple Maestro test files sequentially with aggregated results.
245
+
246
+ **Parameters:**
247
+
248
+ - `flowFiles` (array, required): Array of flow file paths to execute
249
+ - `deviceId` (string, optional): Target device ID
250
+ - `env` (object, optional): Environment variables to pass
251
+ - `stopOnFailure` (boolean, optional): Stop on first failure (default: false)
252
+
253
+ **Returns:**
254
+
255
+ - `success`: boolean (true if all tests passed)
256
+ - `results`: Array of individual test results
257
+ - `summary`: Aggregated statistics (passed, failed, skipped, duration)
258
+
259
+ ### `maestro_generate_and_run` Tool
260
+
261
+ All-in-one workflow: Generate, write, and execute a Maestro test.
262
+
263
+ **Parameters:**
264
+
265
+ - `feature` (string, required): Feature being tested
266
+ - `action` (string, required): Action being tested
267
+ - `flowType` (string, required): Flow type (auth, form, sidebar, modal, navigation, extended)
268
+ - `basePath` (string, optional): Project base path
269
+ - `deviceId` (string, optional): Target device ID
270
+ - `env` (object, optional): Environment variables
271
+ - `execute` (boolean, optional): Execute after writing (default: true)
272
+ - `changedElements` (array, optional): List of changed UI elements
273
+ - `existingTests` (array, optional): List of existing related test files
274
+
275
+ **Returns:**
276
+
277
+ - `generation`: Generated template and guidelines
278
+ - `write`: File write result
279
+ - `execution`: Test execution results (if execute=true)
280
+ - `summary`: Human-readable summary
281
+
282
+ ### `maestro_discover_tests` Tool
283
+
284
+ Discovers all Maestro test files in a directory.
285
+
286
+ **Parameters:**
287
+
288
+ - `directory` (string, optional): Directory to search (default: "maestro")
289
+ - `basePath` (string, optional): Project base path
290
+
291
+ **Returns:**
292
+
293
+ - `files`: Array of file paths
294
+ - `count`: Number of files found
295
+
296
+ ### `maestro_run_all_tests` Tool
297
+
298
+ Runs all Maestro tests in a directory sequentially.
299
+
300
+ **Parameters:**
301
+
302
+ - `directory` (string, optional): Directory containing tests (default: "maestro")
303
+ - `basePath` (string, optional): Project base path
304
+ - `deviceId` (string, optional): Target device ID
305
+ - `env` (object, optional): Environment variables
306
+ - `stopOnFailure` (boolean, optional): Stop on first failure (default: false)
307
+
308
+ **Returns:**
309
+
310
+ - `discovery`: List of discovered test files
311
+ - `execution`: Results with pass/fail status for each test
312
+ - `summary`: Aggregated statistics
313
+
314
+ ## 🎯 Usage Examples
315
+
316
+ Once configured in your MCP client, you can use the tools in your conversations:
317
+
318
+ ### Generate Test for New Feature
319
+
320
+ **Input:**
321
+
322
+ ```
323
+ Use maestro_generate_test to create a test for the new Reset button in User Settings
324
+ ```
325
+
326
+ **What happens:**
327
+ The AI will receive a complete YAML template with guidelines for testing the feature.
328
+
329
+ ### Analyze Git Changes Before Testing
330
+
331
+ **Input:**
332
+
333
+ ```
334
+ maestro_analyze_changes(repoPath: "/path/to/project", changeType: "all")
335
+ ```
336
+
337
+ **Expected Output:**
338
+
339
+ ```
340
+ ## 📁 Changed Files Summary
341
+ ### Unstaged Changes: 2 files
342
+ - src/components/Settings/ResetButton.tsx
343
+ - src/components/Settings/Settings.tsx
344
+
345
+ ## 🔍 Analysis
346
+ ### Should Create Test: ✅ Yes
347
+ ### Interactive Elements Found:
348
+ - onClick
349
+ - Button
350
+ ### Suggested Flow Type: form
351
+ ```
352
+
353
+ ### Get Flow Template
354
+
355
+ **Input:**
356
+
357
+ ```
358
+ maestro_flow_template(flowType: "auth", name: "Login - OAuth flow")
359
+ ```
360
+
361
+ **Expected Output:**
362
+
363
+ ```yaml
364
+ appId: web
365
+ name: "Login - OAuth flow"
366
+ url: ${BASE_URL}
367
+
368
+ env:
369
+ BASE_URL: ${MAESTRO_BASE_URL || "https://localhost:8443"}
370
+ USER_EMAIL: ${MAESTRO_USER_EMAIL || "user@example.com"}
371
+ ---
372
+ - launchApp
373
+ - extendedWaitUntil:
374
+ visible: "Log in"
375
+ timeout: 20000
376
+ - tapOn:
377
+ text: "Log in"
378
+ ```
379
+
380
+ ### Common Use Cases
381
+
382
+ 1. **New Feature Testing**: `maestro_generate_test(feature: "Checkout", action: "Submit order")`
383
+ 2. **Git Analysis**: `maestro_analyze_changes(repoPath: ".", changeType: "staged")`
384
+ 3. **Quick Reference**: `maestro_cheat_sheet()`
385
+ 4. **Pattern Lookup**: `maestro_pattern(patternType: "login")`
386
+ 5. **UI Discovery**: `maestro_ui_inspection()`
387
+ 6. **Pre-check Installation**: `maestro_ensure_installed()` - Verifies Maestro CLI is ready
388
+
389
+ ### Test Execution Use Cases
390
+
391
+ 6. **Generate & Run Test**:
392
+
393
+ ```
394
+ maestro_generate_and_run(
395
+ feature: "Login",
396
+ action: "OAuth flow",
397
+ flowType: "auth",
398
+ basePath: "/path/to/project"
399
+ )
400
+ ```
401
+
402
+ 7. **Run All Tests in Directory**:
403
+
404
+ ```
405
+ maestro_run_all_tests(
406
+ directory: "maestro",
407
+ basePath: "/path/to/project",
408
+ stopOnFailure: false
409
+ )
410
+ ```
411
+
412
+ 8. **Execute Specific Tests Sequentially**:
413
+
414
+ ```
415
+ maestro_execute_tests_sequential(
416
+ flowFiles: ["maestro/login.yaml", "maestro/checkout.yaml"],
417
+ env: { "BASE_URL": "https://staging.example.com" }
418
+ )
419
+ ```
420
+
421
+ 9. **Write Test File Only (No Execution)**:
422
+
423
+ ```
424
+ maestro_write_test(
425
+ yaml: "<generated yaml content>",
426
+ fileName: "user_settings_reset.yaml",
427
+ basePath: "/path/to/project"
428
+ )
429
+ ```
430
+
431
+ 10. **Discover Available Tests**:
432
+
433
+ ```
434
+ maestro_discover_tests(
435
+ directory: "maestro",
436
+ basePath: "/path/to/project"
437
+ )
438
+ ```
439
+
440
+ ## Flow Types
441
+
442
+ | Flow Type | Description | Includes Onboarding? |
443
+ | ------------ | ----------------------------- | -------------------- |
444
+ | `auth` | Login, signup, password reset | Yes |
445
+ | `sidebar` | Sidebar panel interactions | No |
446
+ | `form` | Form fill and submit | No |
447
+ | `modal` | Modal/dialog interactions | No |
448
+ | `navigation` | Page-to-page navigation | No |
449
+ | `extended` | Build on existing flow | No |
450
+
451
+ ## Git Change Types
452
+
453
+ | Type | Description | Git Command |
454
+ | ------------ | ------------------------------ | -------------------------------- |
455
+ | `all` | Unstaged + staged (default) | `git diff` + `git diff --staged` |
456
+ | `unstaged` | Only working directory changes | `git diff` |
457
+ | `staged` | Only staged changes | `git diff --staged` |
458
+ | `lastCommit` | Most recent commit | `git diff HEAD~1` |
459
+ | `branch` | Compare to base branch | `git diff {baseBranch}...HEAD` |
460
+
461
+ ## 🔄 Complete Workflow Example
462
+
463
+ ### ⚠️ IMPORTANT: Always Check Installation First!
464
+
465
+ When a user asks to "generate and run test cases" or use Maestro, follow this order:
466
+
467
+ ```bash
468
+ # Step 0: ALWAYS check Maestro installation first!
469
+ maestro_ensure_installed()
470
+
471
+ # If not installed, the tool will automatically install it via:
472
+ # curl -fsSL "https://get.maestro.mobile.dev" | bash
473
+ ```
474
+
475
+ ### End-to-End: Analyze Changes → Generate → Execute
476
+
477
+ ```bash
478
+ # Step 0: Ensure Maestro is installed (REQUIRED)
479
+ maestro_ensure_installed()
480
+
481
+ # Step 1: Analyze git changes to see what needs testing
482
+ maestro_analyze_changes(repoPath: "/path/to/project", changeType: "staged")
483
+
484
+ # Output shows: Settings.tsx changed with onClick handler
485
+ # Suggested flow type: form
486
+
487
+ # Step 2: Generate and run the test in one call
488
+ maestro_generate_and_run(
489
+ feature: "User Settings",
490
+ action: "Reset defaults",
491
+ flowType: "form",
492
+ basePath: "/path/to/project",
493
+ env: { "BASE_URL": "https://localhost:8443" }
494
+ )
495
+
496
+ # Output:
497
+ # - File written to: /path/to/project/maestro/user_settings_reset_defaults.yaml
498
+ # - Test executed: ✅ Passed (duration: 12.5s)
499
+ ```
500
+
501
+ ### Sequential Test Suite Execution
502
+
503
+ ```bash
504
+ # Step 0: Ensure Maestro is installed (REQUIRED)
505
+ maestro_ensure_installed()
506
+
507
+ # Discover all tests
508
+ maestro_discover_tests(basePath: "/path/to/project")
509
+ # Output: Found 5 test files
510
+
511
+ # Run all tests with stop-on-failure
512
+ maestro_run_all_tests(
513
+ basePath: "/path/to/project",
514
+ stopOnFailure: true,
515
+ env: { "BASE_URL": "https://staging.example.com" }
516
+ )
517
+
518
+ # Output:
519
+ # ✅ login_basic.yaml (8.2s)
520
+ # ✅ user_settings_open.yaml (5.1s)
521
+ # ❌ checkout_submit.yaml (12.3s) - FAILED
522
+ # ⏭️ payment_confirm.yaml - SKIPPED
523
+ # ⏭️ logout.yaml - SKIPPED
524
+ #
525
+ # Summary: 2 passed, 1 failed, 2 skipped
526
+ ```
527
+
528
+ ## 📊 Examples
529
+
530
+ ### Auth Flow Template
531
+
532
+ ```yaml
533
+ appId: web
534
+ name: "Login - Basic authentication"
535
+ url: ${BASE_URL}
536
+
537
+ env:
538
+ BASE_URL: ${MAESTRO_BASE_URL || "https://localhost:8443"}
539
+ USER_EMAIL: ${MAESTRO_USER_EMAIL || "user@example.com"}
540
+ USER_PASSWORD: ${MAESTRO_USER_PASSWORD || "password"}
541
+ ---
542
+ - launchApp
543
+ - extendedWaitUntil:
544
+ visible: "Log in"
545
+ timeout: 20000
546
+ - tapOn:
547
+ text: "Next"
548
+ repeat: 3
549
+ - tapOn:
550
+ text: "Got it"
551
+ repeat: 3
552
+ - tapOn:
553
+ text: "Log in"
554
+ - inputText: ${USER_EMAIL}
555
+ - tapOn:
556
+ text: "Log in"
557
+ - extendedWaitUntil:
558
+ visible: "Dashboard"
559
+ timeout: 30000
560
+ ```
561
+
562
+ ### Form Flow Template
563
+
564
+ ```yaml
565
+ appId: web
566
+ name: "User Settings - Reset defaults"
567
+ url: ${BASE_URL}
568
+
569
+ env:
570
+ BASE_URL: ${MAESTRO_BASE_URL || "https://localhost:8443"}
571
+ ---
572
+ - launchApp
573
+ - extendedWaitUntil:
574
+ visible: "Settings"
575
+ timeout: 20000
576
+ - tapOn:
577
+ text: "Reset to defaults"
578
+ - extendedWaitUntil:
579
+ visible: "Settings reset successfully"
580
+ timeout: 10000
581
+ ```
582
+
583
+ ### Sidebar Flow Template
584
+
585
+ ```yaml
586
+ appId: web
587
+ name: "Positions - Open panel"
588
+ url: ${BASE_URL}
589
+
590
+ env:
591
+ BASE_URL: ${MAESTRO_BASE_URL || "https://localhost:8443"}
592
+ ---
593
+ - launchApp
594
+ - extendedWaitUntil:
595
+ visible: "Portfolio"
596
+ timeout: 20000
597
+ - tapOn:
598
+ id: "dt_sidebar_positions"
599
+ - extendedWaitUntil:
600
+ visible: "Open Positions"
601
+ timeout: 10000
602
+ - assertVisible: "No open positions"
603
+ ```
604
+
605
+ ## 📚 Resources
606
+
607
+ - [Maestro Docs](https://docs.maestro.dev/)
608
+ - [Selectors Reference](https://docs.maestro.dev/api-reference/selectors)
609
+ - [Commands Reference](https://docs.maestro.dev/api-reference/)
610
+ - [Maestro MCP](https://docs.maestro.dev/getting-started/maestro-mcp)