digital-ai-testing-mcp 1.2.2
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 +197 -0
- package/README.md +984 -0
- package/dist/api/agents.d.ts +5 -0
- package/dist/api/agents.d.ts.map +1 -0
- package/dist/api/agents.js +33 -0
- package/dist/api/agents.js.map +1 -0
- package/dist/api/applications.d.ts +35 -0
- package/dist/api/applications.d.ts.map +1 -0
- package/dist/api/applications.js +162 -0
- package/dist/api/applications.js.map +1 -0
- package/dist/api/backup.d.ts +4 -0
- package/dist/api/backup.d.ts.map +1 -0
- package/dist/api/backup.js +13 -0
- package/dist/api/backup.js.map +1 -0
- package/dist/api/browser-inspection.d.ts +33 -0
- package/dist/api/browser-inspection.d.ts.map +1 -0
- package/dist/api/browser-inspection.js +273 -0
- package/dist/api/browser-inspection.js.map +1 -0
- package/dist/api/browsers.d.ts +20 -0
- package/dist/api/browsers.d.ts.map +1 -0
- package/dist/api/browsers.js +31 -0
- package/dist/api/browsers.js.map +1 -0
- package/dist/api/client.d.ts +33 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +200 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/device-groups.d.ts +15 -0
- package/dist/api/device-groups.d.ts.map +1 -0
- package/dist/api/device-groups.js +106 -0
- package/dist/api/device-groups.js.map +1 -0
- package/dist/api/devices.d.ts +32 -0
- package/dist/api/devices.d.ts.map +1 -0
- package/dist/api/devices.js +192 -0
- package/dist/api/devices.js.map +1 -0
- package/dist/api/license.d.ts +3 -0
- package/dist/api/license.d.ts.map +1 -0
- package/dist/api/license.js +11 -0
- package/dist/api/license.js.map +1 -0
- package/dist/api/nv-servers.d.ts +4 -0
- package/dist/api/nv-servers.d.ts.map +1 -0
- package/dist/api/nv-servers.js +20 -0
- package/dist/api/nv-servers.js.map +1 -0
- package/dist/api/projects.d.ts +36 -0
- package/dist/api/projects.d.ts.map +1 -0
- package/dist/api/projects.js +246 -0
- package/dist/api/projects.js.map +1 -0
- package/dist/api/provisioning-profiles.d.ts +7 -0
- package/dist/api/provisioning-profiles.d.ts.map +1 -0
- package/dist/api/provisioning-profiles.js +54 -0
- package/dist/api/provisioning-profiles.js.map +1 -0
- package/dist/api/regions.d.ts +4 -0
- package/dist/api/regions.d.ts.map +1 -0
- package/dist/api/regions.js +20 -0
- package/dist/api/regions.js.map +1 -0
- package/dist/api/reporter-projects.d.ts +3 -0
- package/dist/api/reporter-projects.d.ts.map +1 -0
- package/dist/api/reporter-projects.js +13 -0
- package/dist/api/reporter-projects.js.map +1 -0
- package/dist/api/reporting.d.ts +28 -0
- package/dist/api/reporting.d.ts.map +1 -0
- package/dist/api/reporting.js +340 -0
- package/dist/api/reporting.js.map +1 -0
- package/dist/api/repository.d.ts +17 -0
- package/dist/api/repository.d.ts.map +1 -0
- package/dist/api/repository.js +81 -0
- package/dist/api/repository.js.map +1 -0
- package/dist/api/reservations.d.ts +9 -0
- package/dist/api/reservations.d.ts.map +1 -0
- package/dist/api/reservations.js +72 -0
- package/dist/api/reservations.js.map +1 -0
- package/dist/api/sessions.d.ts +3 -0
- package/dist/api/sessions.d.ts.map +1 -0
- package/dist/api/sessions.js +12 -0
- package/dist/api/sessions.js.map +1 -0
- package/dist/api/test-views.d.ts +9 -0
- package/dist/api/test-views.d.ts.map +1 -0
- package/dist/api/test-views.js +77 -0
- package/dist/api/test-views.js.map +1 -0
- package/dist/api/transactions.d.ts +4 -0
- package/dist/api/transactions.d.ts.map +1 -0
- package/dist/api/transactions.js +28 -0
- package/dist/api/transactions.js.map +1 -0
- package/dist/api/usage-reports.d.ts +24 -0
- package/dist/api/usage-reports.d.ts.map +1 -0
- package/dist/api/usage-reports.js +47 -0
- package/dist/api/usage-reports.js.map +1 -0
- package/dist/api/users.d.ts +14 -0
- package/dist/api/users.d.ts.map +1 -0
- package/dist/api/users.js +77 -0
- package/dist/api/users.js.map +1 -0
- package/dist/api/webdriver.d.ts +97 -0
- package/dist/api/webdriver.d.ts.map +1 -0
- package/dist/api/webdriver.js +1183 -0
- package/dist/api/webdriver.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +130 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/agent-tools.d.ts +3 -0
- package/dist/tools/agent-tools.d.ts.map +1 -0
- package/dist/tools/agent-tools.js +74 -0
- package/dist/tools/agent-tools.js.map +1 -0
- package/dist/tools/application-tools.d.ts +3 -0
- package/dist/tools/application-tools.d.ts.map +1 -0
- package/dist/tools/application-tools.js +816 -0
- package/dist/tools/application-tools.js.map +1 -0
- package/dist/tools/backup-tools.d.ts +3 -0
- package/dist/tools/backup-tools.d.ts.map +1 -0
- package/dist/tools/backup-tools.js +33 -0
- package/dist/tools/backup-tools.js.map +1 -0
- package/dist/tools/boilerplate-tools.d.ts +9 -0
- package/dist/tools/boilerplate-tools.d.ts.map +1 -0
- package/dist/tools/boilerplate-tools.js +1365 -0
- package/dist/tools/boilerplate-tools.js.map +1 -0
- package/dist/tools/browser-tools.d.ts +3 -0
- package/dist/tools/browser-tools.d.ts.map +1 -0
- package/dist/tools/browser-tools.js +108 -0
- package/dist/tools/browser-tools.js.map +1 -0
- package/dist/tools/coverage-tools.d.ts +3 -0
- package/dist/tools/coverage-tools.d.ts.map +1 -0
- package/dist/tools/coverage-tools.js +148 -0
- package/dist/tools/coverage-tools.js.map +1 -0
- package/dist/tools/debug-tools.d.ts +3 -0
- package/dist/tools/debug-tools.d.ts.map +1 -0
- package/dist/tools/debug-tools.js +315 -0
- package/dist/tools/debug-tools.js.map +1 -0
- package/dist/tools/device-group-tools.d.ts +3 -0
- package/dist/tools/device-group-tools.d.ts.map +1 -0
- package/dist/tools/device-group-tools.js +284 -0
- package/dist/tools/device-group-tools.js.map +1 -0
- package/dist/tools/device-tools.d.ts +3 -0
- package/dist/tools/device-tools.d.ts.map +1 -0
- package/dist/tools/device-tools.js +757 -0
- package/dist/tools/device-tools.js.map +1 -0
- package/dist/tools/health-tools.d.ts +3 -0
- package/dist/tools/health-tools.d.ts.map +1 -0
- package/dist/tools/health-tools.js +368 -0
- package/dist/tools/health-tools.js.map +1 -0
- package/dist/tools/inspection-tools.d.ts +3 -0
- package/dist/tools/inspection-tools.d.ts.map +1 -0
- package/dist/tools/inspection-tools.js +1170 -0
- package/dist/tools/inspection-tools.js.map +1 -0
- package/dist/tools/meta-tools.d.ts +4 -0
- package/dist/tools/meta-tools.d.ts.map +1 -0
- package/dist/tools/meta-tools.js +412 -0
- package/dist/tools/meta-tools.js.map +1 -0
- package/dist/tools/nv-server-tools.d.ts +3 -0
- package/dist/tools/nv-server-tools.d.ts.map +1 -0
- package/dist/tools/nv-server-tools.js +67 -0
- package/dist/tools/nv-server-tools.js.map +1 -0
- package/dist/tools/performance-tools.d.ts +3 -0
- package/dist/tools/performance-tools.d.ts.map +1 -0
- package/dist/tools/performance-tools.js +295 -0
- package/dist/tools/performance-tools.js.map +1 -0
- package/dist/tools/project-tools.d.ts +3 -0
- package/dist/tools/project-tools.d.ts.map +1 -0
- package/dist/tools/project-tools.js +577 -0
- package/dist/tools/project-tools.js.map +1 -0
- package/dist/tools/prompt-tools.d.ts +3 -0
- package/dist/tools/prompt-tools.d.ts.map +1 -0
- package/dist/tools/prompt-tools.js +570 -0
- package/dist/tools/prompt-tools.js.map +1 -0
- package/dist/tools/provisioning-profile-tools.d.ts +3 -0
- package/dist/tools/provisioning-profile-tools.d.ts.map +1 -0
- package/dist/tools/provisioning-profile-tools.js +169 -0
- package/dist/tools/provisioning-profile-tools.js.map +1 -0
- package/dist/tools/region-tools.d.ts +3 -0
- package/dist/tools/region-tools.d.ts.map +1 -0
- package/dist/tools/region-tools.js +46 -0
- package/dist/tools/region-tools.js.map +1 -0
- package/dist/tools/reporting-tools.d.ts +3 -0
- package/dist/tools/reporting-tools.d.ts.map +1 -0
- package/dist/tools/reporting-tools.js +1105 -0
- package/dist/tools/reporting-tools.js.map +1 -0
- package/dist/tools/repository-tools.d.ts +3 -0
- package/dist/tools/repository-tools.d.ts.map +1 -0
- package/dist/tools/repository-tools.js +208 -0
- package/dist/tools/repository-tools.js.map +1 -0
- package/dist/tools/reservation-tools.d.ts +3 -0
- package/dist/tools/reservation-tools.d.ts.map +1 -0
- package/dist/tools/reservation-tools.js +199 -0
- package/dist/tools/reservation-tools.js.map +1 -0
- package/dist/tools/resources.d.ts +3 -0
- package/dist/tools/resources.d.ts.map +1 -0
- package/dist/tools/resources.js +91 -0
- package/dist/tools/resources.js.map +1 -0
- package/dist/tools/test-view-tools.d.ts +3 -0
- package/dist/tools/test-view-tools.d.ts.map +1 -0
- package/dist/tools/test-view-tools.js +242 -0
- package/dist/tools/test-view-tools.js.map +1 -0
- package/dist/tools/transaction-tools.d.ts +3 -0
- package/dist/tools/transaction-tools.d.ts.map +1 -0
- package/dist/tools/transaction-tools.js +391 -0
- package/dist/tools/transaction-tools.js.map +1 -0
- package/dist/tools/usage-report-tools.d.ts +3 -0
- package/dist/tools/usage-report-tools.d.ts.map +1 -0
- package/dist/tools/usage-report-tools.js +160 -0
- package/dist/tools/usage-report-tools.js.map +1 -0
- package/dist/tools/user-tools.d.ts +3 -0
- package/dist/tools/user-tools.d.ts.map +1 -0
- package/dist/tools/user-tools.js +279 -0
- package/dist/tools/user-tools.js.map +1 -0
- package/dist/tools/web-inspection-tools.d.ts +3 -0
- package/dist/tools/web-inspection-tools.d.ts.map +1 -0
- package/dist/tools/web-inspection-tools.js +416 -0
- package/dist/tools/web-inspection-tools.js.map +1 -0
- package/dist/tools/workflow-tools.d.ts +3 -0
- package/dist/tools/workflow-tools.d.ts.map +1 -0
- package/dist/tools/workflow-tools.js +1136 -0
- package/dist/tools/workflow-tools.js.map +1 -0
- package/dist/types/digital-ai.d.ts +691 -0
- package/dist/types/digital-ai.d.ts.map +1 -0
- package/dist/types/digital-ai.js +3 -0
- package/dist/types/digital-ai.js.map +1 -0
- package/dist/utils/csv.d.ts +6 -0
- package/dist/utils/csv.d.ts.map +1 -0
- package/dist/utils/csv.js +77 -0
- package/dist/utils/csv.js.map +1 -0
- package/dist/utils/destructive-guard.d.ts +2 -0
- package/dist/utils/destructive-guard.d.ts.map +1 -0
- package/dist/utils/destructive-guard.js +13 -0
- package/dist/utils/destructive-guard.js.map +1 -0
- package/dist/utils/device-resolver.d.ts +22 -0
- package/dist/utils/device-resolver.d.ts.map +1 -0
- package/dist/utils/device-resolver.js +69 -0
- package/dist/utils/device-resolver.js.map +1 -0
- package/dist/utils/download-command.d.ts +18 -0
- package/dist/utils/download-command.d.ts.map +1 -0
- package/dist/utils/download-command.js +54 -0
- package/dist/utils/download-command.js.map +1 -0
- package/dist/utils/locality.d.ts +9 -0
- package/dist/utils/locality.d.ts.map +1 -0
- package/dist/utils/locality.js +22 -0
- package/dist/utils/locality.js.map +1 -0
- package/dist/utils/output-format.d.ts +13 -0
- package/dist/utils/output-format.d.ts.map +1 -0
- package/dist/utils/output-format.js +13 -0
- package/dist/utils/output-format.js.map +1 -0
- package/dist/utils/pagination.d.ts +12 -0
- package/dist/utils/pagination.d.ts.map +1 -0
- package/dist/utils/pagination.js +24 -0
- package/dist/utils/pagination.js.map +1 -0
- package/dist/utils/path-guard.d.ts +17 -0
- package/dist/utils/path-guard.d.ts.map +1 -0
- package/dist/utils/path-guard.js +41 -0
- package/dist/utils/path-guard.js.map +1 -0
- package/dist/utils/performance-comparison.d.ts +53 -0
- package/dist/utils/performance-comparison.d.ts.map +1 -0
- package/dist/utils/performance-comparison.js +286 -0
- package/dist/utils/performance-comparison.js.map +1 -0
- package/dist/utils/performance-stats.d.ts +72 -0
- package/dist/utils/performance-stats.d.ts.map +1 -0
- package/dist/utils/performance-stats.js +124 -0
- package/dist/utils/performance-stats.js.map +1 -0
- package/dist/utils/profile-loader.d.ts +37 -0
- package/dist/utils/profile-loader.d.ts.map +1 -0
- package/dist/utils/profile-loader.js +80 -0
- package/dist/utils/profile-loader.js.map +1 -0
- package/dist/utils/response-formatter.d.ts +27 -0
- package/dist/utils/response-formatter.d.ts.map +1 -0
- package/dist/utils/response-formatter.js +493 -0
- package/dist/utils/response-formatter.js.map +1 -0
- package/dist/utils/timestamp.d.ts +12 -0
- package/dist/utils/timestamp.d.ts.map +1 -0
- package/dist/utils/timestamp.js +22 -0
- package/dist/utils/timestamp.js.map +1 -0
- package/dist/utils/tool-registry.d.ts +21 -0
- package/dist/utils/tool-registry.d.ts.map +1 -0
- package/dist/utils/tool-registry.js +137 -0
- package/dist/utils/tool-registry.js.map +1 -0
- package/dist/utils/upload-command.d.ts +20 -0
- package/dist/utils/upload-command.d.ts.map +1 -0
- package/dist/utils/upload-command.js +64 -0
- package/dist/utils/upload-command.js.map +1 -0
- package/dist/utils/usage-report-guard.d.ts +48 -0
- package/dist/utils/usage-report-guard.d.ts.map +1 -0
- package/dist/utils/usage-report-guard.js +88 -0
- package/dist/utils/usage-report-guard.js.map +1 -0
- package/dist/utils/usage-report-summary.d.ts +20 -0
- package/dist/utils/usage-report-summary.d.ts.map +1 -0
- package/dist/utils/usage-report-summary.js +48 -0
- package/dist/utils/usage-report-summary.js.map +1 -0
- package/dist/utils/version.d.ts +2 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +24 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +73 -0
- package/resources/boilerplate/Android-Native/Java JUnit5/AndroidNative-oss.java +58 -0
- package/resources/boilerplate/Android-Native/Java JUnit5/AndroidNative.java +67 -0
- package/resources/boilerplate/Android-Native/Java JUnit5/gradle +10 -0
- package/resources/boilerplate/Android-Native/Java JUnit5/gradle-oss +10 -0
- package/resources/boilerplate/Android-Native/Java JUnit5/maven +42 -0
- package/resources/boilerplate/Android-Native/Java JUnit5/maven-oss +42 -0
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/AndroidNative.js +30 -0
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/Shell +19 -0
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/Shell-oss +19 -0
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/package-oss.json +12 -0
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/package.json +12 -0
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/wdio-oss.conf.js +40 -0
- package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/wdio.conf.js +44 -0
- package/resources/boilerplate/Android-Native/Python/AndroidNative-oss.py +49 -0
- package/resources/boilerplate/Android-Native/Python/AndroidNative.py +69 -0
- package/resources/boilerplate/Android-Native/Python/pip +2 -0
- package/resources/boilerplate/Android-Native/Python/pip-oss +1 -0
- package/resources/boilerplate/Android-Native/java TestNG/AndroidNative-oss.java +58 -0
- package/resources/boilerplate/Android-Native/java TestNG/AndroidNative.java +67 -0
- package/resources/boilerplate/Android-Native/java TestNG/gradle +13 -0
- package/resources/boilerplate/Android-Native/java TestNG/gradle-oss +13 -0
- package/resources/boilerplate/Android-Native/java TestNG/maven +42 -0
- package/resources/boilerplate/Android-Native/java TestNG/maven-oss +42 -0
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/Shell-oss.txt +19 -0
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/Shell.txt +19 -0
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/iOSNative.js +30 -0
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/package-oss.json +12 -0
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/package.json +12 -0
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/wdio-oss.conf.js +35 -0
- package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/wdio.conf.js +39 -0
- package/resources/boilerplate/iOS-Native/Python/iOSNative-oss.py +44 -0
- package/resources/boilerplate/iOS-Native/Python/iOSNative.py +62 -0
- package/resources/boilerplate/iOS-Native/Python/pip-oss.txt +1 -0
- package/resources/boilerplate/iOS-Native/Python/pip.txt +2 -0
- package/resources/boilerplate/iOS-Native/java-JUnit5/gradle +10 -0
- package/resources/boilerplate/iOS-Native/java-JUnit5/gradle-oss +10 -0
- package/resources/boilerplate/iOS-Native/java-JUnit5/iOSNative-oss.java +52 -0
- package/resources/boilerplate/iOS-Native/java-JUnit5/iOSNative.java +59 -0
- package/resources/boilerplate/iOS-Native/java-JUnit5/maven +42 -0
- package/resources/boilerplate/iOS-Native/java-JUnit5/maven-oss +42 -0
- package/resources/boilerplate/iOS-Native/java-TestNG/gradle +13 -0
- package/resources/boilerplate/iOS-Native/java-TestNG/gradle-oss +13 -0
- package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative-oss.java +52 -0
- package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative.java +59 -0
- package/resources/boilerplate/iOS-Native/java-TestNG/maven +42 -0
- package/resources/boilerplate/iOS-Native/java-TestNG/maven-oss +42 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getDevicesByQuery, getDevice } from '../api/devices.js';
|
|
3
|
+
import { getActiveAccessKey, getActiveUrl } from '../api/client.js';
|
|
4
|
+
import { outputFormatParam, respond } from '../utils/output-format.js';
|
|
5
|
+
function resolveSerial(d) {
|
|
6
|
+
return d.deviceOs === 'iOS' ? (d.iosUdid || d.udid) : d.udid;
|
|
7
|
+
}
|
|
8
|
+
function deviceLabel(d) {
|
|
9
|
+
return `${d.deviceName} (${d.deviceOs} ${d.osVersion})`;
|
|
10
|
+
}
|
|
11
|
+
export function registerDebugTools(server) {
|
|
12
|
+
server.tool('get_remote_debug_command', 'Use this when you want to interact with a cloud device as if it were physically connected to your machine — ' +
|
|
13
|
+
'for manual exploration, UI inspection, locator discovery, or step-through debugging against a published app. ' +
|
|
14
|
+
'Common entry points: "I want to manually test on a real device", "build a test script on a live device", ' +
|
|
15
|
+
'"find the XPath or element ID for a control in my app", "inspect a running app", ' +
|
|
16
|
+
'"test against a published app without a test script yet", "debug without owning hardware".\n\n' +
|
|
17
|
+
'rdb creates a gRPC/TLS tunnel that proxies ADB (Android) or usbmuxd (iOS) to localhost. ' +
|
|
18
|
+
'Once running, the cloud device appears as a locally connected device — Android Studio, Xcode, ' +
|
|
19
|
+
'Appium MCP, and command-line ADB all see it without reconfiguration. ' +
|
|
20
|
+
'The MCP server constructs a ready-to-run script file; the user runs it locally.\n\n' +
|
|
21
|
+
'IMPORTANT — sequence before connecting rdb:\n' +
|
|
22
|
+
' 0. list_applications + version check — call list_applications to find the app; show the user the version found (buildVersion / releaseVersion) and ask "Is this the build you want to test, or do you have a newer one?" WAIT for the answer. If not found or a newer build is wanted: ask for local file path and OS, call get_application_upload_command, share the command, and WAIT for upload confirmation before re-checking list_applications. Do not advance until the user has confirmed the version.\n' +
|
|
23
|
+
' 1. install_application — install the app while the device is still available.\n' +
|
|
24
|
+
' install_application FAILS while a device is reserved via rdb.\n' +
|
|
25
|
+
' 2. get_remote_debug_command — connect rdb (device is now reserved)\n' +
|
|
26
|
+
' 3. adb shell am start -n <package>/<activity> — launch the app\n' +
|
|
27
|
+
' 4. Inspect UI elements (see below)\n' +
|
|
28
|
+
' 5. get_test_boilerplate — generate test script with discovered element IDs\n\n' +
|
|
29
|
+
'UI element ID extraction — two paths:\n' +
|
|
30
|
+
' Primary (UIAutomator dump):\n' +
|
|
31
|
+
' adb shell uiautomator dump /data/local/tmp/ui.xml\n' +
|
|
32
|
+
' adb pull /data/local/tmp/ui.xml\n' +
|
|
33
|
+
' Parse the XML for resource-id attributes.\n' +
|
|
34
|
+
' Fallback (if dump exits silently with no output — known issue on Android 15+ Samsung devices; also observed on Samsung Galaxy S20 Ultra, Android 13):\n' +
|
|
35
|
+
' adb shell pm path <package> # get APK path on device\n' +
|
|
36
|
+
' adb pull <apk-path> app.apk # pull APK locally\n' +
|
|
37
|
+
' aapt dump xmltree app.apk res/layout/activity_login.xml # find element hex IDs\n' +
|
|
38
|
+
' aapt dump resources app.apk | grep ":id/" # resolve hex IDs to names\n' +
|
|
39
|
+
' (aapt is in %LOCALAPPDATA%/Android/Sdk/build-tools/<version>/ on Windows,\n' +
|
|
40
|
+
' ~/Library/Android/sdk/build-tools/<version>/ on Mac)\n' +
|
|
41
|
+
' Android Studio Layout Inspector: use Tools → Layout Inspector directly\n' +
|
|
42
|
+
' (does not require an Android app module in the project).\n' +
|
|
43
|
+
' If the device is not detected after rdb connects, restart ADB:\n' +
|
|
44
|
+
' adb kill-server && adb start-server\n\n' +
|
|
45
|
+
'Device diagnostics — rdb is not just for UI inspection. Once connected, ADB can verify device health before committing to a test run:\n' +
|
|
46
|
+
' adb shell ping -c 3 8.8.8.8 # check internet connectivity\n' +
|
|
47
|
+
' adb shell nslookup google.com # check DNS resolution\n' +
|
|
48
|
+
' adb shell dumpsys activity activities | grep topResumedActivity # confirm foreground activity\n' +
|
|
49
|
+
' adb shell am broadcast -a android.intent.action.CLOSE_SYSTEM_DIALOGS # dismiss blocking overlays\n' +
|
|
50
|
+
' Network checks are especially important before running NV-dependent tests (startPerformanceTransaction):\n' +
|
|
51
|
+
' a device with broken DNS will crash immediately when NV throttling activates.\n\n' +
|
|
52
|
+
'AUTH NOTE: rdb serial number resolution requires Cloud Admin credentials. If the active profile is a\n' +
|
|
53
|
+
' project-level key (Project Admin or User, aut_1_...), device serial lookup may fall back to the internal numeric device ID,\n' +
|
|
54
|
+
' which rdb rejects ("validation error / Failed to reserve device"). If this happens, switch to your\n' +
|
|
55
|
+
' Cloud Admin profile first: switch_environment("default") → get_remote_debug_command → switch back.\n\n' +
|
|
56
|
+
'Discovery → codification workflow:\n' +
|
|
57
|
+
' Use rdb to connect and discover element selectors, then call get_test_boilerplate\n' +
|
|
58
|
+
' with those identifiers to generate a reusable script. The rdb connection can stay\n' +
|
|
59
|
+
' open while you iterate — validating each selector — then close it and trigger the\n' +
|
|
60
|
+
' final script via RemoteWebDriver without any debug session.\n\n' +
|
|
61
|
+
'For returning users who already have rdb installed, pass rdb_path to skip the download/extract guide.', {
|
|
62
|
+
serialNumber: z.string().optional().describe('Device serial number (ADB serial for Android, UDID for iOS) or internal device ID from find_available_device. ' +
|
|
63
|
+
'If omitted, an available device is selected automatically using devicePlatform/osVersion filters.'),
|
|
64
|
+
localPlatform: z.enum(['windows', 'macos']).describe('Platform of the machine where the user will run the rdb script. ' +
|
|
65
|
+
'Required — cannot be inferred because the MCP server runs in Docker. ' +
|
|
66
|
+
'Determines the download URL, script format (.ps1 vs .sh), and binary name.'),
|
|
67
|
+
devicePlatform: z.enum(['android', 'ios']).optional().describe('OS filter used when auto-selecting a device (serialNumber not provided). Ignored if serialNumber is given.'),
|
|
68
|
+
osVersion: z.string().optional().describe('Minimum OS version filter when auto-selecting, e.g. "14.0". Ignored if serialNumber is given.'),
|
|
69
|
+
rdbPath: z.string().optional().describe('Absolute path to the directory containing the rdb binary — the folder rdb extracts to ' +
|
|
70
|
+
'(e.g. C:/tools/rdb/SeeTestRemoteDebugging on Windows, ~/tools/rdb/SeeTestRemoteDebugging on macOS). ' +
|
|
71
|
+
'If provided, the download/extract guide is skipped. Use this for returning users who already have rdb installed.'),
|
|
72
|
+
outputFormat: outputFormatParam,
|
|
73
|
+
}, async ({ serialNumber, localPlatform, devicePlatform, osVersion, rdbPath, outputFormat }) => {
|
|
74
|
+
try {
|
|
75
|
+
// Active-profile accessors (not process.env) — the generated rdb script
|
|
76
|
+
// must embed the credential for whatever profile is currently active.
|
|
77
|
+
const accessKey = getActiveAccessKey();
|
|
78
|
+
const baseUrl = getActiveUrl();
|
|
79
|
+
// ── Resolve device ──────────────────────────────────────────────────
|
|
80
|
+
let serial;
|
|
81
|
+
let label;
|
|
82
|
+
if (serialNumber) {
|
|
83
|
+
// Look up device details for the confirmation header. Best-effort — if lookup
|
|
84
|
+
// fails we still produce the script with just the serial as the label.
|
|
85
|
+
let resolved = null;
|
|
86
|
+
try {
|
|
87
|
+
const bySerial = await getDevicesByQuery(`@serialNumber='${serialNumber}'`);
|
|
88
|
+
if (bySerial.length > 0) {
|
|
89
|
+
resolved = bySerial[0];
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
// Caller may have passed the internal device ID from find_available_device
|
|
93
|
+
resolved = await getDevice(serialNumber);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// Device lookup is best-effort; proceed with serial-only label
|
|
98
|
+
}
|
|
99
|
+
if (resolved) {
|
|
100
|
+
const actualSerial = resolveSerial(resolved);
|
|
101
|
+
serial = actualSerial || serialNumber;
|
|
102
|
+
label = deviceLabel(resolved);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
serial = serialNumber;
|
|
106
|
+
label = `Serial: ${serialNumber}`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
// Auto-select an available device matching the requested criteria
|
|
111
|
+
const clauses = [];
|
|
112
|
+
if (devicePlatform === 'android')
|
|
113
|
+
clauses.push(`@os='android'`);
|
|
114
|
+
else if (devicePlatform === 'ios')
|
|
115
|
+
clauses.push(`@os='iOS'`);
|
|
116
|
+
clauses.push(`@category='PHONE'`);
|
|
117
|
+
const devices = await getDevicesByQuery(clauses.join(' and '));
|
|
118
|
+
const candidates = devices.filter((d) => {
|
|
119
|
+
if (d.displayStatus !== 'Available')
|
|
120
|
+
return false;
|
|
121
|
+
if (osVersion && parseFloat(d.osVersion) < parseFloat(osVersion))
|
|
122
|
+
return false;
|
|
123
|
+
return true;
|
|
124
|
+
});
|
|
125
|
+
if (candidates.length === 0) {
|
|
126
|
+
const osLabel = devicePlatform ? ` ${devicePlatform}` : '';
|
|
127
|
+
const versionLabel = osVersion ? ` ${osVersion}+` : '';
|
|
128
|
+
return {
|
|
129
|
+
content: [{
|
|
130
|
+
type: 'text',
|
|
131
|
+
text: `No available${osLabel}${versionLabel} devices found. Run list_devices to see current availability.`,
|
|
132
|
+
}],
|
|
133
|
+
isError: true,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const d = candidates[0];
|
|
137
|
+
serial = resolveSerial(d);
|
|
138
|
+
label = deviceLabel(d);
|
|
139
|
+
}
|
|
140
|
+
// ── Build script ────────────────────────────────────────────────────
|
|
141
|
+
const isWindows = localPlatform === 'windows';
|
|
142
|
+
const scriptFilename = isWindows ? 'start-rdb.ps1' : 'start-rdb.sh';
|
|
143
|
+
const downloadUrl = `${baseUrl}/download-rdb/?exist=&os=${isWindows ? 'win' : 'mac'}`;
|
|
144
|
+
// Path to the rdb binary inside the script (uses shell variable expansion, not %VAR%)
|
|
145
|
+
const scriptBinaryPath = rdbPath
|
|
146
|
+
? (isWindows ? `${rdbPath}\\rdb.exe` : `${rdbPath}/rdb`)
|
|
147
|
+
: (isWindows
|
|
148
|
+
? '$env:USERPROFILE\\tools\\rdb\\SeeTestRemoteDebugging\\rdb.exe'
|
|
149
|
+
: '$HOME/tools/rdb/SeeTestRemoteDebugging/rdb');
|
|
150
|
+
let scriptContent;
|
|
151
|
+
if (isWindows) {
|
|
152
|
+
scriptContent = [
|
|
153
|
+
'# start-rdb.ps1 — Digital.ai Remote Debug Bridge',
|
|
154
|
+
'# Generated by digital-ai-testing MCP',
|
|
155
|
+
'# WARNING: This file contains your access key. Delete it when your session is complete.',
|
|
156
|
+
`$key = "${accessKey}"`,
|
|
157
|
+
'$envFile = Join-Path $PSScriptRoot ".env"',
|
|
158
|
+
'if (Test-Path $envFile) {',
|
|
159
|
+
' $line = Get-Content $envFile | Where-Object { $_ -match "^DIGITAL_AI_ACCESS_KEY=" } | Select-Object -First 1',
|
|
160
|
+
' if ($line) { $key = ($line -split "=", 2)[1].Trim() }',
|
|
161
|
+
'}',
|
|
162
|
+
`& "${scriptBinaryPath}" start-remote-debug \``,
|
|
163
|
+
` --url ${baseUrl} \``,
|
|
164
|
+
' --access-key $key `',
|
|
165
|
+
` --serial-number ${serial}`,
|
|
166
|
+
].join('\n');
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
scriptContent = [
|
|
170
|
+
'#!/bin/bash',
|
|
171
|
+
'# start-rdb.sh — Digital.ai Remote Debug Bridge',
|
|
172
|
+
'# Generated by digital-ai-testing MCP',
|
|
173
|
+
'# WARNING: This file contains your access key. Delete it when your session is complete.',
|
|
174
|
+
`KEY="${accessKey}"`,
|
|
175
|
+
'if [ -f ".env" ]; then',
|
|
176
|
+
' _key=$(grep "^DIGITAL_AI_ACCESS_KEY=" .env | cut -d\'=\' -f2-)',
|
|
177
|
+
' [ -n "$_key" ] && KEY="$_key"',
|
|
178
|
+
'fi',
|
|
179
|
+
`"${scriptBinaryPath}" start-remote-debug \\`,
|
|
180
|
+
` --url ${baseUrl} \\`,
|
|
181
|
+
' --access-key "$KEY" \\',
|
|
182
|
+
` --serial-number ${serial}`,
|
|
183
|
+
].join('\n');
|
|
184
|
+
}
|
|
185
|
+
// ── Build human output ──────────────────────────────────────────────
|
|
186
|
+
const isProjectApiKey = !accessKey.startsWith('eyJ');
|
|
187
|
+
const serialLooksLikeInternalId = /^\d+$/.test(serial);
|
|
188
|
+
const lines = [];
|
|
189
|
+
lines.push(`Remote debug session ready for: ${label}`);
|
|
190
|
+
lines.push(`Serial: ${serial}`);
|
|
191
|
+
lines.push('');
|
|
192
|
+
if (isProjectApiKey || serialLooksLikeInternalId) {
|
|
193
|
+
lines.push('⚠️ AUTH WARNING: rdb serial resolution requires Cloud Admin credentials.');
|
|
194
|
+
if (isProjectApiKey) {
|
|
195
|
+
lines.push(' The active profile is a project-level key (Project Admin or User) — device serial lookup may be incomplete.');
|
|
196
|
+
}
|
|
197
|
+
if (serialLooksLikeInternalId) {
|
|
198
|
+
lines.push(` "${serial}" is an internal device ID, not an ADB serial. rdb will likely reject it.`);
|
|
199
|
+
}
|
|
200
|
+
lines.push(' Fix: switch_environment("default") → re-run get_remote_debug_command → switch back.');
|
|
201
|
+
lines.push('');
|
|
202
|
+
}
|
|
203
|
+
if (rdbPath) {
|
|
204
|
+
// Compact output — returning user already has rdb
|
|
205
|
+
lines.push(`Script: ${scriptFilename}`);
|
|
206
|
+
lines.push('');
|
|
207
|
+
lines.push('```');
|
|
208
|
+
lines.push(scriptContent);
|
|
209
|
+
lines.push('```');
|
|
210
|
+
lines.push('');
|
|
211
|
+
lines.push(`Write the above to ${scriptFilename} in your project root, then run:`);
|
|
212
|
+
lines.push(isWindows ? ` .\\${scriptFilename}` : ` chmod +x ${scriptFilename} && ./${scriptFilename}`);
|
|
213
|
+
lines.push('');
|
|
214
|
+
lines.push('Keep the terminal open for the duration of your session.');
|
|
215
|
+
lines.push('Press Ctrl+C to terminate the session and release the device.');
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
// Full first-time setup guide
|
|
219
|
+
lines.push(`─── Pre-flight: Is rdb already installed? ${'─'.repeat(23)}`);
|
|
220
|
+
lines.push('');
|
|
221
|
+
lines.push('If you have local shell access, run this check now:');
|
|
222
|
+
lines.push('');
|
|
223
|
+
if (isWindows) {
|
|
224
|
+
lines.push(' # 1. Check PATH first (fastest — works regardless of install location)');
|
|
225
|
+
lines.push(' Get-Command rdb -ErrorAction SilentlyContinue | Select-Object Source');
|
|
226
|
+
lines.push('');
|
|
227
|
+
lines.push(' # 2. Check the recommended install location (no recursion)');
|
|
228
|
+
lines.push(' Test-Path "$env:USERPROFILE\\tools\\rdb\\SeeTestRemoteDebugging\\rdb.exe"');
|
|
229
|
+
lines.push('');
|
|
230
|
+
lines.push(' # 3. Check the project root (for teams that vendor the binary)');
|
|
231
|
+
lines.push(' Test-Path ".\\rdb.exe"');
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
lines.push(' which rdb 2>/dev/null || find ~/tools /usr/local/bin -name "rdb" 2>/dev/null | head -3');
|
|
235
|
+
}
|
|
236
|
+
lines.push('');
|
|
237
|
+
lines.push('If you do not have local shell access, ask the user:');
|
|
238
|
+
lines.push(' "Do you already have rdb installed? If yes, what\'s the full path to the folder');
|
|
239
|
+
lines.push(' containing the rdb binary (e.g. the folder that contains rdb.exe or ./rdb)?"');
|
|
240
|
+
lines.push('');
|
|
241
|
+
lines.push('→ If rdb is found: call get_remote_debug_command again with rdb_path=<result>.');
|
|
242
|
+
lines.push(' The full setup guide will be skipped — output will be the script only.');
|
|
243
|
+
lines.push('→ If all checks return nothing: proceed immediately to the download instructions below.');
|
|
244
|
+
lines.push(' Do not search further — if rdb is not in PATH, the recommended location, or the project root,');
|
|
245
|
+
lines.push(' it is not installed.');
|
|
246
|
+
lines.push('');
|
|
247
|
+
lines.push(`─── Step 1: Download rdb ${'─'.repeat(38)}`);
|
|
248
|
+
lines.push(downloadUrl);
|
|
249
|
+
lines.push('');
|
|
250
|
+
lines.push(`─── Step 2: Extract ${'─'.repeat(43)}`);
|
|
251
|
+
if (isWindows) {
|
|
252
|
+
lines.push('Suggested location: C:\\Users\\<your-username>\\tools\\rdb\\');
|
|
253
|
+
lines.push('After extracting, you should have: C:\\Users\\<your-username>\\tools\\rdb\\SeeTestRemoteDebugging\\');
|
|
254
|
+
lines.push(' (SeeTestRemoteDebugging is the Digital.ai Remote Debug Bridge folder — the name is set by the installer)');
|
|
255
|
+
lines.push('');
|
|
256
|
+
lines.push('Or create the directory with PowerShell:');
|
|
257
|
+
lines.push(' New-Item -ItemType Directory -Force "$env:USERPROFILE\\tools\\rdb"');
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
lines.push('Suggested location: ~/tools/rdb/');
|
|
261
|
+
lines.push('After extracting, you should have: ~/tools/rdb/SeeTestRemoteDebugging/');
|
|
262
|
+
lines.push(' (SeeTestRemoteDebugging is the Digital.ai Remote Debug Bridge folder — the name is set by the installer)');
|
|
263
|
+
}
|
|
264
|
+
lines.push('');
|
|
265
|
+
lines.push(`─── Step 3: Run the remote debug session ${'─'.repeat(22)}`);
|
|
266
|
+
lines.push(`A ready-to-run script has been prepared: ${scriptFilename}`);
|
|
267
|
+
lines.push('');
|
|
268
|
+
lines.push('```');
|
|
269
|
+
lines.push(scriptContent);
|
|
270
|
+
lines.push('```');
|
|
271
|
+
lines.push('');
|
|
272
|
+
lines.push(`Write the above to ${scriptFilename} in your project root, then open a terminal there and run:`);
|
|
273
|
+
lines.push(isWindows ? ` .\\${scriptFilename}` : ` chmod +x ${scriptFilename} && ./${scriptFilename}`);
|
|
274
|
+
lines.push('');
|
|
275
|
+
lines.push('Keep the terminal open for the duration of your session.');
|
|
276
|
+
lines.push('Press Ctrl+C to terminate the session and release the device.');
|
|
277
|
+
lines.push('');
|
|
278
|
+
lines.push(`─── Optional: Add rdb to PATH (run once) ${'─'.repeat(22)}`);
|
|
279
|
+
if (isWindows) {
|
|
280
|
+
lines.push('[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$env:USERPROFILE\\tools\\rdb\\SeeTestRemoteDebugging", "User")');
|
|
281
|
+
lines.push('# Restart your terminal for PATH to take effect.');
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
lines.push(`echo 'export PATH="$HOME/tools/rdb/SeeTestRemoteDebugging:$PATH"' >> ~/.zshrc && source ~/.zshrc`);
|
|
285
|
+
lines.push('# After this, you can run rdb from anywhere.');
|
|
286
|
+
}
|
|
287
|
+
lines.push('');
|
|
288
|
+
lines.push(`─── Once running ${'─'.repeat(46)}`);
|
|
289
|
+
lines.push('The device will appear as a locally connected ADB device.');
|
|
290
|
+
lines.push('Android Studio, Xcode, and Appium MCP will detect it automatically.');
|
|
291
|
+
lines.push('If Android Studio does not detect the device, run: adb kill-server && adb start-server');
|
|
292
|
+
}
|
|
293
|
+
const authWarning = (isProjectApiKey || serialLooksLikeInternalId)
|
|
294
|
+
? 'Project API key active — serial resolution may be incomplete. Switch to Cloud Admin profile before running.'
|
|
295
|
+
: null;
|
|
296
|
+
return respond(outputFormat, {
|
|
297
|
+
device: { label, serial },
|
|
298
|
+
localPlatform,
|
|
299
|
+
downloadUrl: rdbPath ? null : downloadUrl,
|
|
300
|
+
scriptFilename,
|
|
301
|
+
scriptContent,
|
|
302
|
+
setupRequired: !rdbPath,
|
|
303
|
+
authWarning,
|
|
304
|
+
}, lines.join('\n'));
|
|
305
|
+
}
|
|
306
|
+
catch (e) {
|
|
307
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
308
|
+
return {
|
|
309
|
+
content: [{ type: 'text', text: `Failed to build remote debug command: ${msg}` }],
|
|
310
|
+
isError: true,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
//# sourceMappingURL=debug-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug-tools.js","sourceRoot":"","sources":["../../src/tools/debug-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAGvE,SAAS,aAAa,CAAC,CAAS;IAC9B,OAAO,CAAC,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/D,CAAC;AAED,SAAS,WAAW,CAAC,CAAS;IAC5B,OAAO,GAAG,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,SAAS,GAAG,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAAiB;IAClD,MAAM,CAAC,IAAI,CACT,0BAA0B,EAC1B,8GAA8G;QAC9G,+GAA+G;QAC/G,2GAA2G;QAC3G,mFAAmF;QACnF,gGAAgG;QAChG,0FAA0F;QAC1F,gGAAgG;QAChG,uEAAuE;QACvE,qFAAqF;QACrF,+CAA+C;QAC/C,ofAAof;QACpf,mFAAmF;QACnF,sEAAsE;QACtE,wEAAwE;QACxE,oEAAoE;QACpE,wCAAwC;QACxC,kFAAkF;QAClF,yCAAyC;QACzC,iCAAiC;Q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CAAC,IAAI,CAAC,wFAAwF,CAAC,CAAC;YACvG,CAAC;YAED,MAAM,WAAW,GAAG,CAAC,eAAe,IAAI,yBAAyB,CAAC;gBAChE,CAAC,CAAC,6GAA6G;gBAC/G,CAAC,CAAC,IAAI,CAAC;YAET,OAAO,OAAO,CAAC,YAAY,EAAE;gBAC3B,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;gBACzB,aAAa;gBACb,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW;gBACzC,cAAc;gBACd,aAAa;gBACb,aAAa,EAAE,CAAC,OAAO;gBACvB,WAAW;aACZ,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAEvB,CAAC;QAAC,OAAO,CAAU,EAAE,CAAC;YACpB,MAAM,GAAG,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACvD,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,yCAAyC,GAAG,EAAE,EAAE,CAAC;gBAC1F,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-group-tools.d.ts","sourceRoot":"","sources":["../../src/tools/device-group-tools.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAkBzE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAkVhE"}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getDeviceGroups, getDeviceGroupsV2, getDevicesInDeviceGroup, getProjectsInDeviceGroup, createDeviceGroup, editDeviceGroup, deleteDeviceGroup, addDevicesToDeviceGroup, removeDevicesFromDeviceGroup, assignDeviceGroupToProject, } from '../api/device-groups.js';
|
|
3
|
+
import { checkDestructiveGuard } from '../utils/destructive-guard.js';
|
|
4
|
+
import { applyMaxResults, appendTruncationNotice } from '../utils/pagination.js';
|
|
5
|
+
import { formatDeviceList, formatProjectList, formatDeviceGroupV2List } from '../utils/response-formatter.js';
|
|
6
|
+
import { outputFormatParam, respond } from '../utils/output-format.js';
|
|
7
|
+
export function registerDeviceGroupTools(server) {
|
|
8
|
+
server.tool('list_device_groups', 'Lists all device groups in the system. ' +
|
|
9
|
+
'Use this to find a group\'s numeric ID — required by get_devices_in_group, add_devices_to_group, remove_devices_from_group, assign_group_to_project, and the create_poc / close_poc / delete_poc workflows. ' +
|
|
10
|
+
'Returns the Default device group ID (the source pool for POC device selection) and any named groups (e.g. "Acme Corp POC"). ' +
|
|
11
|
+
'Device groups organize devices and control which projects can access which devices. ' +
|
|
12
|
+
'Cloud Admin returns full group data (numberOfDevices, type, acceptNewDevices). Project-level keys (Project Admin and Project User) receive a simplified response via the v1 fallback (id and name only).', {
|
|
13
|
+
maxResults: z
|
|
14
|
+
.number()
|
|
15
|
+
.optional()
|
|
16
|
+
.default(50)
|
|
17
|
+
.describe('Maximum number of results to return (default: 50, max: 500).'),
|
|
18
|
+
outputFormat: outputFormatParam,
|
|
19
|
+
}, async ({ maxResults, outputFormat }) => {
|
|
20
|
+
try {
|
|
21
|
+
// Try v2 first (Cloud Admin) — returns richer data (numberOfDevices, type, acceptNewDevices).
|
|
22
|
+
// Falls back to v1 (project-level keys) which returns a flat {id→name} dict.
|
|
23
|
+
let v2Groups = null;
|
|
24
|
+
try {
|
|
25
|
+
v2Groups = await getDeviceGroupsV2();
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// v2 unavailable (project-level key or older server) — fall through to v1
|
|
29
|
+
}
|
|
30
|
+
if (v2Groups && v2Groups.length > 0) {
|
|
31
|
+
const paged = applyMaxResults(v2Groups, maxResults);
|
|
32
|
+
const structured = {
|
|
33
|
+
deviceGroups: paged.items.map(g => ({ id: String(g.id), name: g.name, numberOfDevices: g.numberOfDevices, type: g.type, acceptNewDevices: g.acceptNewDevices })),
|
|
34
|
+
};
|
|
35
|
+
const humanText = appendTruncationNotice(`Device Groups (${paged.total} total):\n` + formatDeviceGroupV2List(paged.items), paged);
|
|
36
|
+
return respond(outputFormat, structured, humanText);
|
|
37
|
+
}
|
|
38
|
+
// v1 fallback
|
|
39
|
+
const groups = await getDeviceGroups();
|
|
40
|
+
const entries = Object.entries(groups);
|
|
41
|
+
const paged = applyMaxResults(entries, maxResults);
|
|
42
|
+
const structured = {
|
|
43
|
+
deviceGroups: paged.items.map(([id, name]) => ({ id, name })),
|
|
44
|
+
};
|
|
45
|
+
const lines = paged.items.map(([id, name]) => ` • ${name} (ID: ${id})`).join('\n');
|
|
46
|
+
const humanText = appendTruncationNotice(`Device Groups (${paged.total} total):\n${lines || ' (none)'}`, paged);
|
|
47
|
+
return respond(outputFormat, structured, humanText);
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
server.tool('get_devices_in_group', 'Lists all devices that belong to a specific device group. ' +
|
|
54
|
+
'Optional client-side filters: osType (ios/android), status (Available/Offline/In Use/etc.), ' +
|
|
55
|
+
'category (PHONE/TABLET/WATCH), excludeTags (exclude devices with any listed tag), ' +
|
|
56
|
+
'requireTags (include only devices with all listed tags). ' +
|
|
57
|
+
'Used in create_poc Step 3 to select eligible devices from the Default group. Cloud Admin only.', {
|
|
58
|
+
groupId: z.string().describe('The numeric device group ID. Use list_device_groups to find it.'),
|
|
59
|
+
osType: z
|
|
60
|
+
.enum(['ios', 'android'])
|
|
61
|
+
.optional()
|
|
62
|
+
.describe("Filter by OS: 'ios' or 'android'. Case-insensitive match against the device OS field."),
|
|
63
|
+
status: z
|
|
64
|
+
.string()
|
|
65
|
+
.optional()
|
|
66
|
+
.describe("Filter by displayStatus (e.g. 'Available', 'Offline', 'In Use'). Exact case-insensitive match."),
|
|
67
|
+
category: z
|
|
68
|
+
.string()
|
|
69
|
+
.optional()
|
|
70
|
+
.describe("Filter by deviceCategory: 'PHONE', 'TABLET', 'WATCH', or 'UNKNOWN'. Exact case-insensitive match."),
|
|
71
|
+
excludeTags: z
|
|
72
|
+
.array(z.string())
|
|
73
|
+
.optional()
|
|
74
|
+
.describe('Exclude devices that have any of these tags (exact case-insensitive match per tag). Example: ["DoNotTake", "DONTTAKE", "DONOTUSE"].'),
|
|
75
|
+
requireTags: z
|
|
76
|
+
.array(z.string())
|
|
77
|
+
.optional()
|
|
78
|
+
.describe('Include only devices that have ALL of these tags (exact case-insensitive match per tag).'),
|
|
79
|
+
maxResults: z
|
|
80
|
+
.number()
|
|
81
|
+
.optional()
|
|
82
|
+
.default(50)
|
|
83
|
+
.describe('Maximum number of results to return after filtering (default: 50, max: 500).'),
|
|
84
|
+
outputFormat: outputFormatParam,
|
|
85
|
+
}, async ({ groupId, osType, status, category, excludeTags, requireTags, maxResults, outputFormat }) => {
|
|
86
|
+
try {
|
|
87
|
+
let devices = await getDevicesInDeviceGroup(groupId);
|
|
88
|
+
if (osType) {
|
|
89
|
+
const q = osType.toLowerCase();
|
|
90
|
+
devices = devices.filter(d => (d.deviceOs ?? '').toLowerCase() === q);
|
|
91
|
+
}
|
|
92
|
+
if (status) {
|
|
93
|
+
const q = status.toLowerCase();
|
|
94
|
+
devices = devices.filter(d => (d.displayStatus ?? '').toLowerCase() === q);
|
|
95
|
+
}
|
|
96
|
+
if (category) {
|
|
97
|
+
const q = category.toLowerCase();
|
|
98
|
+
devices = devices.filter(d => (d.deviceCategory ?? '').toLowerCase() === q);
|
|
99
|
+
}
|
|
100
|
+
if (excludeTags && excludeTags.length > 0) {
|
|
101
|
+
const excl = excludeTags.map(t => t.toLowerCase());
|
|
102
|
+
devices = devices.filter(d => !(d.tags ?? []).some(t => excl.includes(t.toLowerCase())));
|
|
103
|
+
}
|
|
104
|
+
if (requireTags && requireTags.length > 0) {
|
|
105
|
+
const req = requireTags.map(t => t.toLowerCase());
|
|
106
|
+
devices = devices.filter(d => {
|
|
107
|
+
const dtags = (d.tags ?? []).map(t => t.toLowerCase());
|
|
108
|
+
return req.every(r => dtags.includes(r));
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
const paged = applyMaxResults(devices, maxResults);
|
|
112
|
+
const structured = {
|
|
113
|
+
devices: paged.items.map(d => ({
|
|
114
|
+
id: d.id,
|
|
115
|
+
name: d.deviceName,
|
|
116
|
+
osType: d.deviceOs,
|
|
117
|
+
osVersion: d.osVersion,
|
|
118
|
+
deviceCategory: d.deviceCategory,
|
|
119
|
+
displayStatus: d.displayStatus,
|
|
120
|
+
region: d.region || d.agentLocation || '',
|
|
121
|
+
tags: d.tags,
|
|
122
|
+
})),
|
|
123
|
+
};
|
|
124
|
+
const humanText = appendTruncationNotice(`Devices in group ${groupId} (${paged.total} total):\n\n${formatDeviceList(paged.items)}`, paged);
|
|
125
|
+
return respond(outputFormat, structured, humanText);
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
const msg = e.message;
|
|
129
|
+
if (msg.includes('[400]') && msg.toLowerCase().includes('not found')) {
|
|
130
|
+
return { content: [{ type: 'text', text: `Device group ${groupId} not found or has already been deleted.` }], isError: true };
|
|
131
|
+
}
|
|
132
|
+
return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
server.tool('get_projects_in_group', 'Lists all projects that have access to a specific device group. Cloud Admin only.', {
|
|
136
|
+
groupId: z.string().describe('The numeric device group ID.'),
|
|
137
|
+
maxResults: z
|
|
138
|
+
.number()
|
|
139
|
+
.optional()
|
|
140
|
+
.default(50)
|
|
141
|
+
.describe('Maximum number of results to return (default: 50, max: 500).'),
|
|
142
|
+
outputFormat: outputFormatParam,
|
|
143
|
+
}, async ({ groupId, maxResults, outputFormat }) => {
|
|
144
|
+
try {
|
|
145
|
+
const projects = await getProjectsInDeviceGroup(groupId);
|
|
146
|
+
const paged = applyMaxResults(projects, maxResults);
|
|
147
|
+
const structured = {
|
|
148
|
+
projects: paged.items.map(p => ({ id: p.id, name: p.name })),
|
|
149
|
+
};
|
|
150
|
+
const humanText = appendTruncationNotice(`Projects with access to group ${groupId} (${paged.total} total):\n${formatProjectList(paged.items)}`, paged);
|
|
151
|
+
return respond(outputFormat, structured, humanText);
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
server.tool('create_device_group', 'Creates a new device group. Device groups let you organize devices and control project access. Cloud Admin only.', {
|
|
158
|
+
name: z.string().describe('Name for the new device group.'),
|
|
159
|
+
acceptNewDevices: z
|
|
160
|
+
.boolean()
|
|
161
|
+
.optional()
|
|
162
|
+
.describe('Whether new devices should be automatically added to this group.'),
|
|
163
|
+
}, async ({ name, acceptNewDevices }) => {
|
|
164
|
+
try {
|
|
165
|
+
const result = await createDeviceGroup({ name, acceptNewDevices });
|
|
166
|
+
return {
|
|
167
|
+
content: [
|
|
168
|
+
{
|
|
169
|
+
type: 'text',
|
|
170
|
+
text: `✅ Device group "${name}" created with ID: ${result.id}`,
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
catch (e) {
|
|
176
|
+
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
server.tool('edit_device_group', 'Renames a device group or changes whether it automatically accepts new devices. Cloud Admin only.', {
|
|
180
|
+
groupId: z.string().describe('The numeric device group ID.'),
|
|
181
|
+
name: z.string().optional().describe('New name for the group.'),
|
|
182
|
+
acceptNewDevices: z
|
|
183
|
+
.boolean()
|
|
184
|
+
.optional()
|
|
185
|
+
.describe('Whether new devices should be automatically added to this group.'),
|
|
186
|
+
}, async ({ groupId, name, acceptNewDevices }) => {
|
|
187
|
+
try {
|
|
188
|
+
await editDeviceGroup(groupId, { name, acceptNewDevices });
|
|
189
|
+
return {
|
|
190
|
+
content: [{ type: 'text', text: `✅ Device group ${groupId} updated.` }],
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
catch (e) {
|
|
194
|
+
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
server.tool('delete_device_group', 'Permanently deletes a device group. Note: the Default and Cleanup groups cannot be deleted. Devices in the group are not deleted — they remain in the system. Cloud Admin only. Requires confirmDeletion: true. ⚠️ POC teardown: use delete_poc instead — it handles the full sequence (device cleanup, user access revocation, then deletion).', {
|
|
198
|
+
groupId: z.string().describe('The numeric device group ID.'),
|
|
199
|
+
confirmDeletion: z
|
|
200
|
+
.boolean()
|
|
201
|
+
.describe('Must be true to confirm this destructive, irreversible operation. No changes are made without this.'),
|
|
202
|
+
}, async ({ groupId, confirmDeletion }) => {
|
|
203
|
+
const guard = checkDestructiveGuard(confirmDeletion, `Delete device group ${groupId}`);
|
|
204
|
+
if (guard)
|
|
205
|
+
return { content: [{ type: 'text', text: guard }] };
|
|
206
|
+
try {
|
|
207
|
+
await deleteDeviceGroup(groupId);
|
|
208
|
+
return {
|
|
209
|
+
content: [{ type: 'text', text: `✅ Device group ${groupId} deleted.` }],
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
catch (e) {
|
|
213
|
+
const msg = e.message;
|
|
214
|
+
if (msg.includes('[400]') && msg.toLowerCase().includes('not found')) {
|
|
215
|
+
return { content: [{ type: 'text', text: `Device group ${groupId} not found or has already been deleted.` }], isError: true };
|
|
216
|
+
}
|
|
217
|
+
return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
server.tool('add_devices_to_group', 'Adds one or more devices to a device group. Cloud Admin only.', {
|
|
221
|
+
groupId: z.string().describe('The numeric device group ID.'),
|
|
222
|
+
deviceIds: z.array(z.string()).describe('List of device IDs to add to the group.'),
|
|
223
|
+
}, async ({ groupId, deviceIds }) => {
|
|
224
|
+
try {
|
|
225
|
+
await addDevicesToDeviceGroup(groupId, deviceIds);
|
|
226
|
+
return {
|
|
227
|
+
content: [
|
|
228
|
+
{
|
|
229
|
+
type: 'text',
|
|
230
|
+
text: `✅ Added ${deviceIds.length} device(s) to group ${groupId}: ${deviceIds.join(', ')}`,
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
catch (e) {
|
|
236
|
+
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
server.tool('remove_devices_from_group', 'Removes one or more devices from a device group. The devices remain in the system. Cloud Admin only. Requires confirmDeletion: true.', {
|
|
240
|
+
groupId: z.string().describe('The numeric device group ID.'),
|
|
241
|
+
deviceIds: z.array(z.string()).describe('List of device IDs to remove from the group.'),
|
|
242
|
+
confirmDeletion: z
|
|
243
|
+
.boolean()
|
|
244
|
+
.describe('Must be true to confirm this destructive, irreversible operation. No changes are made without this.'),
|
|
245
|
+
}, async ({ groupId, deviceIds, confirmDeletion }) => {
|
|
246
|
+
const guard = checkDestructiveGuard(confirmDeletion, `Remove ${deviceIds.length} device(s) from group ${groupId}`);
|
|
247
|
+
if (guard)
|
|
248
|
+
return { content: [{ type: 'text', text: guard }] };
|
|
249
|
+
try {
|
|
250
|
+
await removeDevicesFromDeviceGroup(groupId, deviceIds);
|
|
251
|
+
return {
|
|
252
|
+
content: [
|
|
253
|
+
{
|
|
254
|
+
type: 'text',
|
|
255
|
+
text: `✅ Removed ${deviceIds.length} device(s) from group ${groupId}.`,
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
catch (e) {
|
|
261
|
+
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
server.tool('assign_group_to_project', 'Grants a project access to a device group, allowing its users to see and use those devices. Cloud Admin only.', {
|
|
265
|
+
projectId: z.string().describe('The numeric project ID.'),
|
|
266
|
+
deviceGroupId: z.string().describe('The numeric device group ID.'),
|
|
267
|
+
}, async ({ projectId, deviceGroupId }) => {
|
|
268
|
+
try {
|
|
269
|
+
await assignDeviceGroupToProject(projectId, deviceGroupId);
|
|
270
|
+
return {
|
|
271
|
+
content: [
|
|
272
|
+
{
|
|
273
|
+
type: 'text',
|
|
274
|
+
text: `✅ Device group ${deviceGroupId} assigned to project ${projectId}.`,
|
|
275
|
+
},
|
|
276
|
+
],
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
catch (e) {
|
|
280
|
+
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=device-group-tools.js.map
|