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.
Files changed (333) hide show
  1. package/LICENSE +197 -0
  2. package/README.md +984 -0
  3. package/dist/api/agents.d.ts +5 -0
  4. package/dist/api/agents.d.ts.map +1 -0
  5. package/dist/api/agents.js +33 -0
  6. package/dist/api/agents.js.map +1 -0
  7. package/dist/api/applications.d.ts +35 -0
  8. package/dist/api/applications.d.ts.map +1 -0
  9. package/dist/api/applications.js +162 -0
  10. package/dist/api/applications.js.map +1 -0
  11. package/dist/api/backup.d.ts +4 -0
  12. package/dist/api/backup.d.ts.map +1 -0
  13. package/dist/api/backup.js +13 -0
  14. package/dist/api/backup.js.map +1 -0
  15. package/dist/api/browser-inspection.d.ts +33 -0
  16. package/dist/api/browser-inspection.d.ts.map +1 -0
  17. package/dist/api/browser-inspection.js +273 -0
  18. package/dist/api/browser-inspection.js.map +1 -0
  19. package/dist/api/browsers.d.ts +20 -0
  20. package/dist/api/browsers.d.ts.map +1 -0
  21. package/dist/api/browsers.js +31 -0
  22. package/dist/api/browsers.js.map +1 -0
  23. package/dist/api/client.d.ts +33 -0
  24. package/dist/api/client.d.ts.map +1 -0
  25. package/dist/api/client.js +200 -0
  26. package/dist/api/client.js.map +1 -0
  27. package/dist/api/device-groups.d.ts +15 -0
  28. package/dist/api/device-groups.d.ts.map +1 -0
  29. package/dist/api/device-groups.js +106 -0
  30. package/dist/api/device-groups.js.map +1 -0
  31. package/dist/api/devices.d.ts +32 -0
  32. package/dist/api/devices.d.ts.map +1 -0
  33. package/dist/api/devices.js +192 -0
  34. package/dist/api/devices.js.map +1 -0
  35. package/dist/api/license.d.ts +3 -0
  36. package/dist/api/license.d.ts.map +1 -0
  37. package/dist/api/license.js +11 -0
  38. package/dist/api/license.js.map +1 -0
  39. package/dist/api/nv-servers.d.ts +4 -0
  40. package/dist/api/nv-servers.d.ts.map +1 -0
  41. package/dist/api/nv-servers.js +20 -0
  42. package/dist/api/nv-servers.js.map +1 -0
  43. package/dist/api/projects.d.ts +36 -0
  44. package/dist/api/projects.d.ts.map +1 -0
  45. package/dist/api/projects.js +246 -0
  46. package/dist/api/projects.js.map +1 -0
  47. package/dist/api/provisioning-profiles.d.ts +7 -0
  48. package/dist/api/provisioning-profiles.d.ts.map +1 -0
  49. package/dist/api/provisioning-profiles.js +54 -0
  50. package/dist/api/provisioning-profiles.js.map +1 -0
  51. package/dist/api/regions.d.ts +4 -0
  52. package/dist/api/regions.d.ts.map +1 -0
  53. package/dist/api/regions.js +20 -0
  54. package/dist/api/regions.js.map +1 -0
  55. package/dist/api/reporter-projects.d.ts +3 -0
  56. package/dist/api/reporter-projects.d.ts.map +1 -0
  57. package/dist/api/reporter-projects.js +13 -0
  58. package/dist/api/reporter-projects.js.map +1 -0
  59. package/dist/api/reporting.d.ts +28 -0
  60. package/dist/api/reporting.d.ts.map +1 -0
  61. package/dist/api/reporting.js +340 -0
  62. package/dist/api/reporting.js.map +1 -0
  63. package/dist/api/repository.d.ts +17 -0
  64. package/dist/api/repository.d.ts.map +1 -0
  65. package/dist/api/repository.js +81 -0
  66. package/dist/api/repository.js.map +1 -0
  67. package/dist/api/reservations.d.ts +9 -0
  68. package/dist/api/reservations.d.ts.map +1 -0
  69. package/dist/api/reservations.js +72 -0
  70. package/dist/api/reservations.js.map +1 -0
  71. package/dist/api/sessions.d.ts +3 -0
  72. package/dist/api/sessions.d.ts.map +1 -0
  73. package/dist/api/sessions.js +12 -0
  74. package/dist/api/sessions.js.map +1 -0
  75. package/dist/api/test-views.d.ts +9 -0
  76. package/dist/api/test-views.d.ts.map +1 -0
  77. package/dist/api/test-views.js +77 -0
  78. package/dist/api/test-views.js.map +1 -0
  79. package/dist/api/transactions.d.ts +4 -0
  80. package/dist/api/transactions.d.ts.map +1 -0
  81. package/dist/api/transactions.js +28 -0
  82. package/dist/api/transactions.js.map +1 -0
  83. package/dist/api/usage-reports.d.ts +24 -0
  84. package/dist/api/usage-reports.d.ts.map +1 -0
  85. package/dist/api/usage-reports.js +47 -0
  86. package/dist/api/usage-reports.js.map +1 -0
  87. package/dist/api/users.d.ts +14 -0
  88. package/dist/api/users.d.ts.map +1 -0
  89. package/dist/api/users.js +77 -0
  90. package/dist/api/users.js.map +1 -0
  91. package/dist/api/webdriver.d.ts +97 -0
  92. package/dist/api/webdriver.d.ts.map +1 -0
  93. package/dist/api/webdriver.js +1183 -0
  94. package/dist/api/webdriver.js.map +1 -0
  95. package/dist/index.d.ts +3 -0
  96. package/dist/index.d.ts.map +1 -0
  97. package/dist/index.js +130 -0
  98. package/dist/index.js.map +1 -0
  99. package/dist/tools/agent-tools.d.ts +3 -0
  100. package/dist/tools/agent-tools.d.ts.map +1 -0
  101. package/dist/tools/agent-tools.js +74 -0
  102. package/dist/tools/agent-tools.js.map +1 -0
  103. package/dist/tools/application-tools.d.ts +3 -0
  104. package/dist/tools/application-tools.d.ts.map +1 -0
  105. package/dist/tools/application-tools.js +816 -0
  106. package/dist/tools/application-tools.js.map +1 -0
  107. package/dist/tools/backup-tools.d.ts +3 -0
  108. package/dist/tools/backup-tools.d.ts.map +1 -0
  109. package/dist/tools/backup-tools.js +33 -0
  110. package/dist/tools/backup-tools.js.map +1 -0
  111. package/dist/tools/boilerplate-tools.d.ts +9 -0
  112. package/dist/tools/boilerplate-tools.d.ts.map +1 -0
  113. package/dist/tools/boilerplate-tools.js +1365 -0
  114. package/dist/tools/boilerplate-tools.js.map +1 -0
  115. package/dist/tools/browser-tools.d.ts +3 -0
  116. package/dist/tools/browser-tools.d.ts.map +1 -0
  117. package/dist/tools/browser-tools.js +108 -0
  118. package/dist/tools/browser-tools.js.map +1 -0
  119. package/dist/tools/coverage-tools.d.ts +3 -0
  120. package/dist/tools/coverage-tools.d.ts.map +1 -0
  121. package/dist/tools/coverage-tools.js +148 -0
  122. package/dist/tools/coverage-tools.js.map +1 -0
  123. package/dist/tools/debug-tools.d.ts +3 -0
  124. package/dist/tools/debug-tools.d.ts.map +1 -0
  125. package/dist/tools/debug-tools.js +315 -0
  126. package/dist/tools/debug-tools.js.map +1 -0
  127. package/dist/tools/device-group-tools.d.ts +3 -0
  128. package/dist/tools/device-group-tools.d.ts.map +1 -0
  129. package/dist/tools/device-group-tools.js +284 -0
  130. package/dist/tools/device-group-tools.js.map +1 -0
  131. package/dist/tools/device-tools.d.ts +3 -0
  132. package/dist/tools/device-tools.d.ts.map +1 -0
  133. package/dist/tools/device-tools.js +757 -0
  134. package/dist/tools/device-tools.js.map +1 -0
  135. package/dist/tools/health-tools.d.ts +3 -0
  136. package/dist/tools/health-tools.d.ts.map +1 -0
  137. package/dist/tools/health-tools.js +368 -0
  138. package/dist/tools/health-tools.js.map +1 -0
  139. package/dist/tools/inspection-tools.d.ts +3 -0
  140. package/dist/tools/inspection-tools.d.ts.map +1 -0
  141. package/dist/tools/inspection-tools.js +1170 -0
  142. package/dist/tools/inspection-tools.js.map +1 -0
  143. package/dist/tools/meta-tools.d.ts +4 -0
  144. package/dist/tools/meta-tools.d.ts.map +1 -0
  145. package/dist/tools/meta-tools.js +412 -0
  146. package/dist/tools/meta-tools.js.map +1 -0
  147. package/dist/tools/nv-server-tools.d.ts +3 -0
  148. package/dist/tools/nv-server-tools.d.ts.map +1 -0
  149. package/dist/tools/nv-server-tools.js +67 -0
  150. package/dist/tools/nv-server-tools.js.map +1 -0
  151. package/dist/tools/performance-tools.d.ts +3 -0
  152. package/dist/tools/performance-tools.d.ts.map +1 -0
  153. package/dist/tools/performance-tools.js +295 -0
  154. package/dist/tools/performance-tools.js.map +1 -0
  155. package/dist/tools/project-tools.d.ts +3 -0
  156. package/dist/tools/project-tools.d.ts.map +1 -0
  157. package/dist/tools/project-tools.js +577 -0
  158. package/dist/tools/project-tools.js.map +1 -0
  159. package/dist/tools/prompt-tools.d.ts +3 -0
  160. package/dist/tools/prompt-tools.d.ts.map +1 -0
  161. package/dist/tools/prompt-tools.js +570 -0
  162. package/dist/tools/prompt-tools.js.map +1 -0
  163. package/dist/tools/provisioning-profile-tools.d.ts +3 -0
  164. package/dist/tools/provisioning-profile-tools.d.ts.map +1 -0
  165. package/dist/tools/provisioning-profile-tools.js +169 -0
  166. package/dist/tools/provisioning-profile-tools.js.map +1 -0
  167. package/dist/tools/region-tools.d.ts +3 -0
  168. package/dist/tools/region-tools.d.ts.map +1 -0
  169. package/dist/tools/region-tools.js +46 -0
  170. package/dist/tools/region-tools.js.map +1 -0
  171. package/dist/tools/reporting-tools.d.ts +3 -0
  172. package/dist/tools/reporting-tools.d.ts.map +1 -0
  173. package/dist/tools/reporting-tools.js +1105 -0
  174. package/dist/tools/reporting-tools.js.map +1 -0
  175. package/dist/tools/repository-tools.d.ts +3 -0
  176. package/dist/tools/repository-tools.d.ts.map +1 -0
  177. package/dist/tools/repository-tools.js +208 -0
  178. package/dist/tools/repository-tools.js.map +1 -0
  179. package/dist/tools/reservation-tools.d.ts +3 -0
  180. package/dist/tools/reservation-tools.d.ts.map +1 -0
  181. package/dist/tools/reservation-tools.js +199 -0
  182. package/dist/tools/reservation-tools.js.map +1 -0
  183. package/dist/tools/resources.d.ts +3 -0
  184. package/dist/tools/resources.d.ts.map +1 -0
  185. package/dist/tools/resources.js +91 -0
  186. package/dist/tools/resources.js.map +1 -0
  187. package/dist/tools/test-view-tools.d.ts +3 -0
  188. package/dist/tools/test-view-tools.d.ts.map +1 -0
  189. package/dist/tools/test-view-tools.js +242 -0
  190. package/dist/tools/test-view-tools.js.map +1 -0
  191. package/dist/tools/transaction-tools.d.ts +3 -0
  192. package/dist/tools/transaction-tools.d.ts.map +1 -0
  193. package/dist/tools/transaction-tools.js +391 -0
  194. package/dist/tools/transaction-tools.js.map +1 -0
  195. package/dist/tools/usage-report-tools.d.ts +3 -0
  196. package/dist/tools/usage-report-tools.d.ts.map +1 -0
  197. package/dist/tools/usage-report-tools.js +160 -0
  198. package/dist/tools/usage-report-tools.js.map +1 -0
  199. package/dist/tools/user-tools.d.ts +3 -0
  200. package/dist/tools/user-tools.d.ts.map +1 -0
  201. package/dist/tools/user-tools.js +279 -0
  202. package/dist/tools/user-tools.js.map +1 -0
  203. package/dist/tools/web-inspection-tools.d.ts +3 -0
  204. package/dist/tools/web-inspection-tools.d.ts.map +1 -0
  205. package/dist/tools/web-inspection-tools.js +416 -0
  206. package/dist/tools/web-inspection-tools.js.map +1 -0
  207. package/dist/tools/workflow-tools.d.ts +3 -0
  208. package/dist/tools/workflow-tools.d.ts.map +1 -0
  209. package/dist/tools/workflow-tools.js +1136 -0
  210. package/dist/tools/workflow-tools.js.map +1 -0
  211. package/dist/types/digital-ai.d.ts +691 -0
  212. package/dist/types/digital-ai.d.ts.map +1 -0
  213. package/dist/types/digital-ai.js +3 -0
  214. package/dist/types/digital-ai.js.map +1 -0
  215. package/dist/utils/csv.d.ts +6 -0
  216. package/dist/utils/csv.d.ts.map +1 -0
  217. package/dist/utils/csv.js +77 -0
  218. package/dist/utils/csv.js.map +1 -0
  219. package/dist/utils/destructive-guard.d.ts +2 -0
  220. package/dist/utils/destructive-guard.d.ts.map +1 -0
  221. package/dist/utils/destructive-guard.js +13 -0
  222. package/dist/utils/destructive-guard.js.map +1 -0
  223. package/dist/utils/device-resolver.d.ts +22 -0
  224. package/dist/utils/device-resolver.d.ts.map +1 -0
  225. package/dist/utils/device-resolver.js +69 -0
  226. package/dist/utils/device-resolver.js.map +1 -0
  227. package/dist/utils/download-command.d.ts +18 -0
  228. package/dist/utils/download-command.d.ts.map +1 -0
  229. package/dist/utils/download-command.js +54 -0
  230. package/dist/utils/download-command.js.map +1 -0
  231. package/dist/utils/locality.d.ts +9 -0
  232. package/dist/utils/locality.d.ts.map +1 -0
  233. package/dist/utils/locality.js +22 -0
  234. package/dist/utils/locality.js.map +1 -0
  235. package/dist/utils/output-format.d.ts +13 -0
  236. package/dist/utils/output-format.d.ts.map +1 -0
  237. package/dist/utils/output-format.js +13 -0
  238. package/dist/utils/output-format.js.map +1 -0
  239. package/dist/utils/pagination.d.ts +12 -0
  240. package/dist/utils/pagination.d.ts.map +1 -0
  241. package/dist/utils/pagination.js +24 -0
  242. package/dist/utils/pagination.js.map +1 -0
  243. package/dist/utils/path-guard.d.ts +17 -0
  244. package/dist/utils/path-guard.d.ts.map +1 -0
  245. package/dist/utils/path-guard.js +41 -0
  246. package/dist/utils/path-guard.js.map +1 -0
  247. package/dist/utils/performance-comparison.d.ts +53 -0
  248. package/dist/utils/performance-comparison.d.ts.map +1 -0
  249. package/dist/utils/performance-comparison.js +286 -0
  250. package/dist/utils/performance-comparison.js.map +1 -0
  251. package/dist/utils/performance-stats.d.ts +72 -0
  252. package/dist/utils/performance-stats.d.ts.map +1 -0
  253. package/dist/utils/performance-stats.js +124 -0
  254. package/dist/utils/performance-stats.js.map +1 -0
  255. package/dist/utils/profile-loader.d.ts +37 -0
  256. package/dist/utils/profile-loader.d.ts.map +1 -0
  257. package/dist/utils/profile-loader.js +80 -0
  258. package/dist/utils/profile-loader.js.map +1 -0
  259. package/dist/utils/response-formatter.d.ts +27 -0
  260. package/dist/utils/response-formatter.d.ts.map +1 -0
  261. package/dist/utils/response-formatter.js +493 -0
  262. package/dist/utils/response-formatter.js.map +1 -0
  263. package/dist/utils/timestamp.d.ts +12 -0
  264. package/dist/utils/timestamp.d.ts.map +1 -0
  265. package/dist/utils/timestamp.js +22 -0
  266. package/dist/utils/timestamp.js.map +1 -0
  267. package/dist/utils/tool-registry.d.ts +21 -0
  268. package/dist/utils/tool-registry.d.ts.map +1 -0
  269. package/dist/utils/tool-registry.js +137 -0
  270. package/dist/utils/tool-registry.js.map +1 -0
  271. package/dist/utils/upload-command.d.ts +20 -0
  272. package/dist/utils/upload-command.d.ts.map +1 -0
  273. package/dist/utils/upload-command.js +64 -0
  274. package/dist/utils/upload-command.js.map +1 -0
  275. package/dist/utils/usage-report-guard.d.ts +48 -0
  276. package/dist/utils/usage-report-guard.d.ts.map +1 -0
  277. package/dist/utils/usage-report-guard.js +88 -0
  278. package/dist/utils/usage-report-guard.js.map +1 -0
  279. package/dist/utils/usage-report-summary.d.ts +20 -0
  280. package/dist/utils/usage-report-summary.d.ts.map +1 -0
  281. package/dist/utils/usage-report-summary.js +48 -0
  282. package/dist/utils/usage-report-summary.js.map +1 -0
  283. package/dist/utils/version.d.ts +2 -0
  284. package/dist/utils/version.d.ts.map +1 -0
  285. package/dist/utils/version.js +24 -0
  286. package/dist/utils/version.js.map +1 -0
  287. package/package.json +73 -0
  288. package/resources/boilerplate/Android-Native/Java JUnit5/AndroidNative-oss.java +58 -0
  289. package/resources/boilerplate/Android-Native/Java JUnit5/AndroidNative.java +67 -0
  290. package/resources/boilerplate/Android-Native/Java JUnit5/gradle +10 -0
  291. package/resources/boilerplate/Android-Native/Java JUnit5/gradle-oss +10 -0
  292. package/resources/boilerplate/Android-Native/Java JUnit5/maven +42 -0
  293. package/resources/boilerplate/Android-Native/Java JUnit5/maven-oss +42 -0
  294. package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/AndroidNative.js +30 -0
  295. package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/Shell +19 -0
  296. package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/Shell-oss +19 -0
  297. package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/package-oss.json +12 -0
  298. package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/package.json +12 -0
  299. package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/wdio-oss.conf.js +40 -0
  300. package/resources/boilerplate/Android-Native/NodeJS (WebDriver)/wdio.conf.js +44 -0
  301. package/resources/boilerplate/Android-Native/Python/AndroidNative-oss.py +49 -0
  302. package/resources/boilerplate/Android-Native/Python/AndroidNative.py +69 -0
  303. package/resources/boilerplate/Android-Native/Python/pip +2 -0
  304. package/resources/boilerplate/Android-Native/Python/pip-oss +1 -0
  305. package/resources/boilerplate/Android-Native/java TestNG/AndroidNative-oss.java +58 -0
  306. package/resources/boilerplate/Android-Native/java TestNG/AndroidNative.java +67 -0
  307. package/resources/boilerplate/Android-Native/java TestNG/gradle +13 -0
  308. package/resources/boilerplate/Android-Native/java TestNG/gradle-oss +13 -0
  309. package/resources/boilerplate/Android-Native/java TestNG/maven +42 -0
  310. package/resources/boilerplate/Android-Native/java TestNG/maven-oss +42 -0
  311. package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/Shell-oss.txt +19 -0
  312. package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/Shell.txt +19 -0
  313. package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/iOSNative.js +30 -0
  314. package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/package-oss.json +12 -0
  315. package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/package.json +12 -0
  316. package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/wdio-oss.conf.js +35 -0
  317. package/resources/boilerplate/iOS-Native/NodeJS (WebDriver)/wdio.conf.js +39 -0
  318. package/resources/boilerplate/iOS-Native/Python/iOSNative-oss.py +44 -0
  319. package/resources/boilerplate/iOS-Native/Python/iOSNative.py +62 -0
  320. package/resources/boilerplate/iOS-Native/Python/pip-oss.txt +1 -0
  321. package/resources/boilerplate/iOS-Native/Python/pip.txt +2 -0
  322. package/resources/boilerplate/iOS-Native/java-JUnit5/gradle +10 -0
  323. package/resources/boilerplate/iOS-Native/java-JUnit5/gradle-oss +10 -0
  324. package/resources/boilerplate/iOS-Native/java-JUnit5/iOSNative-oss.java +52 -0
  325. package/resources/boilerplate/iOS-Native/java-JUnit5/iOSNative.java +59 -0
  326. package/resources/boilerplate/iOS-Native/java-JUnit5/maven +42 -0
  327. package/resources/boilerplate/iOS-Native/java-JUnit5/maven-oss +42 -0
  328. package/resources/boilerplate/iOS-Native/java-TestNG/gradle +13 -0
  329. package/resources/boilerplate/iOS-Native/java-TestNG/gradle-oss +13 -0
  330. package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative-oss.java +52 -0
  331. package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative.java +59 -0
  332. package/resources/boilerplate/iOS-Native/java-TestNG/maven +42 -0
  333. package/resources/boilerplate/iOS-Native/java-TestNG/maven-oss +42 -0
@@ -0,0 +1,816 @@
1
+ import { z } from 'zod';
2
+ import { getApplications, getApplicationInfo, uploadApplication, uploadApplicationFromUrl, deleteApplication, updateApplicationPlugins, installApplication, uninstallApplication, uninstallApplicationByPackage, uninstallApplicationByPackageFromDevices, extractLanguageFiles, } from '../api/applications.js';
3
+ import { getDevicesInDeviceGroup } from '../api/device-groups.js';
4
+ import { getMyAccountInfo } from '../api/users.js';
5
+ import { listActiveSessions } from '../api/webdriver.js';
6
+ import { resolveDevice } from '../utils/device-resolver.js';
7
+ import { checkDestructiveGuard } from '../utils/destructive-guard.js';
8
+ import { validateOutputPath, validateInputPath } from '../utils/path-guard.js';
9
+ import { SERVER_FS_DOWNLOAD_NOTICE, SERVER_FS_OUTPUT_PARAM } from '../utils/locality.js';
10
+ import { buildDownloadCommand } from '../utils/download-command.js';
11
+ import { applyMaxResults, appendTruncationNotice } from '../utils/pagination.js';
12
+ import { formatApplicationList } from '../utils/response-formatter.js';
13
+ import { outputFormatParam, respond } from '../utils/output-format.js';
14
+ import { getActiveAccessKey, getActiveUrl, getActiveKeyType } from '../api/client.js';
15
+ // v43 Fix C — structured (not prose) test-creation guidance, attached to the entry-point
16
+ // tools an agent calls first when building a test. The doc's argument: agents treat a
17
+ // structured response field as fact to act on, but treat description prose as background
18
+ // context. `liveInspectionSession` is the one selector source the MCP can actually verify.
19
+ function testCreationGuidance() {
20
+ return {
21
+ decideModeFirst: 'If you are creating a test: INTERACTIVE (start_inspection_session) when intent is vague, you lack the app source, ' +
22
+ 'or you have no captured element IDs; AUTONOMOUS (get_test_boilerplate) only with specific intent AND a real selector source.',
23
+ liveInspectionSession: listActiveSessions().length > 0,
24
+ prohibited: 'Authoring a test from guessed/placeholder element IDs or fabricated credentials and presenting it as finished — ' +
25
+ 'including by writing the file yourself instead of using get_test_boilerplate.',
26
+ beforeDelivering: 'Run validate_test_script on any test you produce; do not present a script it flags.',
27
+ };
28
+ }
29
+ export function registerApplicationTools(server) {
30
+ server.tool('list_applications', 'Lists and searches the app repository. Use nameContains to find apps by name (e.g. "ExperiBank", "demo") without needing a bundle ID or package name. ' +
31
+ 'Returns app IDs needed by install_application, assign_app_to_project, and get_application_info. ' +
32
+ 'TEST-CREATION NOTE: if this lookup is the first step of creating a test, decide the MODE before going further — ' +
33
+ 'autonomous (get_test_boilerplate: specific intent + selectors from source or a session) vs interactive ' +
34
+ '(start_inspection_session: vague intent, "let\'s decide as we go", no source access). If unsure, ask the user which they want. ' +
35
+ 'Each result lists its project assignments — when several uploads share a name, PREFER the one assigned to your active project ' +
36
+ '(install and inspection sessions run in the active project context and fail for apps assigned only elsewhere). ' +
37
+ 'Also filterable by platform (ios/android), package name, bundle identifier, file type (apk/ipa/aab), and simulator flag. ' +
38
+ 'Covers the full app catalog — browse uploaded applications, find a specific version, or search for a demo app.', {
39
+ nameContains: z
40
+ .string()
41
+ .optional()
42
+ .describe('Filter by app name — partial, case-insensitive match on applicationName. ' +
43
+ 'E.g. "ExperiBank" returns all apps with "ExperiBank" in their name, without needing the bundle ID or package name. ' +
44
+ 'Combine with osType to narrow to a specific platform.'),
45
+ osType: z.enum(['ios', 'android']).optional().describe("Filter by platform: 'ios' or 'android'."),
46
+ packageName: z.string().optional().describe('Filter by Android package name (exact server-side filter).'),
47
+ bundleIdentifier: z.string().optional().describe('Filter by iOS bundle identifier (exact server-side filter).'),
48
+ uniqueName: z.string().optional().describe('Filter by unique name alias.'),
49
+ fileType: z
50
+ .enum(['apk', 'ipa', 'aab', 'zip'])
51
+ .optional()
52
+ .describe("Filter by file type: 'apk', 'ipa', 'aab', or 'zip'."),
53
+ isForSimulator: z.boolean().optional().describe('Filter simulator/emulator builds only.'),
54
+ sortBy: z
55
+ .enum(['applicationName', 'releaseVersion', 'buildVersion', 'createdAt', 'osType', 'fileType'])
56
+ .optional()
57
+ .describe('Sort results by this field (client-side). Default: newest first.'),
58
+ sortOrder: z
59
+ .enum(['asc', 'desc'])
60
+ .optional()
61
+ .default('desc')
62
+ .describe("Sort direction: 'asc' or 'desc'. Default: 'desc' (newest first)."),
63
+ maxResults: z
64
+ .number()
65
+ .optional()
66
+ .default(50)
67
+ .describe('Maximum number of results to return (default: 50, max: 500).'),
68
+ outputFormat: outputFormatParam,
69
+ }, async ({ nameContains, osType, packageName, bundleIdentifier, uniqueName, fileType, isForSimulator, sortBy, sortOrder, maxResults, outputFormat }) => {
70
+ try {
71
+ let apps = await getApplications({
72
+ osType,
73
+ packageName,
74
+ bundleIdentifier,
75
+ uniqueName,
76
+ fileType,
77
+ isForSimulator,
78
+ });
79
+ if (nameContains) {
80
+ const q = nameContains.toLowerCase();
81
+ apps = apps.filter(a => a.applicationName.toLowerCase().includes(q));
82
+ }
83
+ if (sortBy) {
84
+ apps = [...apps].sort((a, b) => {
85
+ if (sortBy === 'createdAt') {
86
+ const av = a.createdAt ?? 0;
87
+ const bv = b.createdAt ?? 0;
88
+ return sortOrder === 'desc' ? bv - av : av - bv;
89
+ }
90
+ const av = String(a[sortBy] ?? '').toLowerCase();
91
+ const bv = String(b[sortBy] ?? '').toLowerCase();
92
+ return sortOrder === 'desc' ? bv.localeCompare(av) : av.localeCompare(bv);
93
+ });
94
+ }
95
+ else {
96
+ apps = [...apps].sort((a, b) => (b.createdAt ?? 0) - (a.createdAt ?? 0));
97
+ }
98
+ const paged = applyMaxResults(apps, maxResults);
99
+ const structured = {
100
+ applications: paged.items.map(a => ({
101
+ id: a.id,
102
+ name: a.applicationName,
103
+ osType: a.osType,
104
+ version: a.releaseVersion,
105
+ uploadedAt: a.createdAtFormatted || new Date(a.createdAt).toISOString().slice(0, 10),
106
+ // Install/inspection run in the ACTIVE project context — pick a copy
107
+ // assigned to it when several uploads share a name (v36).
108
+ projects: (a.projectsInfo ?? []).map(p => p.name),
109
+ })),
110
+ _testCreationGuidance: testCreationGuidance(),
111
+ };
112
+ if (paged.total === 0) {
113
+ structured._storeInstallGuidance = {
114
+ appNotInRepository: true,
115
+ suggestion: 'Ask the user if this is a public store app they want to test. If yes, install it directly onto a farm device without needing a repository upload.',
116
+ androidFlow: 'start_inspection_session(no appId) → app_control(action:"deep_link", url:"market://details?id=<packageName>") — returns 500 but succeeds on-device (confirmed live), ignore the error → take_inspection_screenshot to verify Play Store opened → find_elements(xpath,"//*[@content-desc=\'Install\']") + tap_element',
117
+ iosFlow: 'start_inspection_session(no appId) → launch_app(packageName:"com.apple.AppStore") — itms-apps:// deep links return 500 on Grid iOS (confirmed), use launch_app instead → take_inspection_screenshot — if consent/onboarding screen with disabled buttons appears, stop session and use open_mobile_studio for manual interaction → user taps GET (Face ID/Touch ID cannot be automated). iOS numeric App Store ID is in the apps.apple.com URL after /id.',
118
+ iosAuthNote: 'iOS install requires human confirmation (Face ID, Touch ID, or Apple ID password) — cannot be automated. Use open_mobile_studio to hand control to the user for the GET tap.',
119
+ repositoryNote: 'Installing from the store adds the app to that device only. It will not appear in list_applications and cannot be pushed to other devices via install_application.',
120
+ };
121
+ }
122
+ const humanText = appendTruncationNotice(`Found ${paged.total} application(s):\n\n${formatApplicationList(paged.items)}`, paged);
123
+ return respond(outputFormat, structured, humanText);
124
+ }
125
+ catch (e) {
126
+ return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
127
+ }
128
+ });
129
+ server.tool('get_application_info', 'Gets full details for a specific app by its numeric ID, including signing configuration, plugins, project assignments, ' +
130
+ 'and the launch activity (mainActivity, Android) needed for start_inspection_session and launch_app.', {
131
+ applicationId: z.number().describe('The numeric application ID. Use list_applications to find it.'),
132
+ outputFormat: outputFormatParam,
133
+ }, async ({ applicationId, outputFormat }) => {
134
+ try {
135
+ const app = await getApplicationInfo(applicationId);
136
+ const humanText = [
137
+ `šŸ“¦ ${app.applicationName} (ID: ${app.id})`,
138
+ `Platform: ${app.osType}`,
139
+ `Version: ${app.releaseVersion} (build ${app.buildVersion})`,
140
+ `File Type: ${app.fileType.toUpperCase()}`,
141
+ `Package: ${app.packageName ?? app.bundleIdentifier ?? 'N/A'}`,
142
+ app.mainActivity ? `Main Activity: ${app.mainActivity}` : '',
143
+ `Unique Name: ${app.uniqueName ?? 'none'}`,
144
+ `Camera Support: ${app.cameraSupport}`,
145
+ `Network Capture: ${app.networkCaptureSupport}`,
146
+ `For Simulator: ${app.isForSimulator}`,
147
+ `Can Delete: ${app.canDelete}`,
148
+ `Uploaded: ${app.createdAtFormatted}`,
149
+ app.plugins && app.plugins.length > 0
150
+ ? `Plugins: ${app.plugins.map((p) => `${p.name} (${p.uuid})`).join(', ')}`
151
+ : '',
152
+ app.projectsInfo && app.projectsInfo.length > 0
153
+ ? `Projects: ${app.projectsInfo.map((p) => `${p.name} (${p.id})`).join(', ')}`
154
+ : '',
155
+ ]
156
+ .filter(Boolean)
157
+ .join('\n');
158
+ return respond(outputFormat, { ...app, _testCreationGuidance: testCreationGuidance() }, humanText);
159
+ }
160
+ catch (e) {
161
+ return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
162
+ }
163
+ });
164
+ server.tool('upload_application_file', 'Uploads an app binary (APK, IPA, AAB) from a local file path visible to the MCP server process. IMPORTANT: the MCP server runs in Docker — host machine paths (e.g. C:\\AppSec\\app.apk) are NOT accessible unless the directory is volume-mounted into the container. Mount the directory when starting the container (e.g. -v /host/apk-dir:/uploads) and pass the in-container path (e.g. /uploads/app.apk). If mounting is not possible, use upload_application_from_url instead with a direct artifact URL.', {
165
+ filePath: z.string().describe('Absolute path inside the MCP container (not the host path). Volume-mount the directory first. Example: /uploads/MyApp.apk'),
166
+ uniqueName: z.string().optional().describe('A short unique alias for this app (optional).'),
167
+ camera: z.boolean().optional().describe('Enable camera support instrumentation.'),
168
+ touchId: z.boolean().optional().describe('Enable Touch ID support (iOS).'),
169
+ project: z.string().optional().describe('Project name to assign the app to. Cloud Admin only — project keys upload to their assigned project; this param is ignored.'),
170
+ uuid: z.string().optional().describe('iOS provisioning profile UUID for signing.'),
171
+ fixKeychainAccess: z.boolean().optional().describe('Fix keychain access for iOS.'),
172
+ allowResign: z.boolean().optional().describe('Allow app re-signing for iOS.'),
173
+ signPlugins: z.boolean().optional().describe('Sign app plugins/extensions for iOS.'),
174
+ installMDM: z.boolean().optional().describe('Install via MDM for iOS.'),
175
+ installAttributesMDM: z
176
+ .string()
177
+ .optional()
178
+ .describe('MDM installation attributes as JSON string.'),
179
+ autoTrustEnterpriseDeveloper: z
180
+ .boolean()
181
+ .optional()
182
+ .describe('Auto-trust enterprise developer for iOS.'),
183
+ keystorePassword: z.string().optional().describe('Keystore password for Android custom signing.'),
184
+ keyAlias: z.string().optional().describe('Key alias for Android custom signing.'),
185
+ keyPassword: z.string().optional().describe('Key password for Android custom signing.'),
186
+ networkCaptureSupport: z.boolean().optional().describe('Enable network capture for Android.'),
187
+ }, async (params) => {
188
+ const { filePath, installAttributesMDM, ...rest } = params;
189
+ // Detect host-machine paths that are unreachable inside the Docker container.
190
+ const isWindowsHostPath = /^[A-Za-z]:[\\\/]/.test(filePath);
191
+ const isHostHomePath = /^\/(Users|home|root)\//.test(filePath);
192
+ if (isWindowsHostPath || isHostHomePath) {
193
+ return {
194
+ content: [{ type: 'text', text: JSON.stringify({
195
+ error: 'HOST_PATH_UNREACHABLE',
196
+ message: `The path '${filePath}' looks like a host machine path. The MCP server runs inside Docker and cannot access host filesystem paths unless the directory is volume-mounted into the container. ` +
197
+ `Options: (1) Use upload_application_from_url with a publicly reachable artifact URL. ` +
198
+ `(2) Mount the directory when starting the container: -v /host/apk-dir:/uploads, then pass /uploads/app.apk as the path.`,
199
+ }) }],
200
+ isError: true,
201
+ };
202
+ }
203
+ const inputErr = validateInputPath(filePath);
204
+ if (inputErr)
205
+ return { content: [{ type: 'text', text: `Error: ${inputErr}` }], isError: true };
206
+ try {
207
+ const uploadParams = {
208
+ ...rest,
209
+ installAttributesMDM: installAttributesMDM
210
+ ? JSON.parse(installAttributesMDM)
211
+ : undefined,
212
+ };
213
+ const result = await uploadApplication(filePath, uploadParams);
214
+ const text = [
215
+ result.created ? 'āœ… Application uploaded successfully.' : 'āœ… Application updated (existing version replaced).',
216
+ `App ID: ${result.id}`,
217
+ result.name ? `Name: ${result.name}` : '',
218
+ result.buildVersion ? `Build Version: ${result.buildVersion}` : '',
219
+ result.releaseVersion ? `Release Version: ${result.releaseVersion}` : '',
220
+ ]
221
+ .filter(Boolean)
222
+ .join('\n');
223
+ return { content: [{ type: 'text', text }] };
224
+ }
225
+ catch (e) {
226
+ return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
227
+ }
228
+ });
229
+ server.tool('upload_application_from_url', 'Uploads an app by having the Digital.ai platform fetch it from a URL. Ideal for CI/CD artifact servers. IMPORTANT: the URL must be a direct, stable, publicly reachable artifact URL — the platform fetches it server-side. Redirecting URLs (e.g. APKPure links, GitHub "latest" release assets, short URLs) and URLs that require authentication or cookies are likely to fail with a 400 validation error. Use a permanent direct download link from your artifact storage (Nexus, Artifactory, S3, Azure Blobs, etc.). Same signing options as upload_application_file.', {
230
+ url: z.string().describe('Direct, stable artifact URL reachable by the Digital.ai platform server. Must not redirect or require authentication.'),
231
+ uniqueName: z.string().optional().describe('A short unique alias for this app.'),
232
+ camera: z.boolean().optional().describe('Enable camera support.'),
233
+ touchId: z.boolean().optional().describe('Enable Touch ID support (iOS).'),
234
+ project: z.string().optional().describe('Project name to assign the app to. Cloud Admin only — project keys upload to their assigned project; this param is ignored.'),
235
+ uuid: z.string().optional().describe('iOS provisioning profile UUID.'),
236
+ fixKeychainAccess: z.boolean().optional().describe('Fix keychain access (iOS).'),
237
+ allowResign: z.boolean().optional().describe('Allow re-signing (iOS).'),
238
+ signPlugins: z.boolean().optional().describe('Sign plugins (iOS).'),
239
+ installMDM: z.boolean().optional().describe('Install via MDM (iOS).'),
240
+ autoTrustEnterpriseDeveloper: z.boolean().optional().describe('Auto-trust enterprise developer (iOS).'),
241
+ networkCaptureSupport: z.boolean().optional().describe('Network capture support (Android).'),
242
+ }, async ({ url, ...rest }) => {
243
+ try {
244
+ const result = await uploadApplicationFromUrl(url, rest);
245
+ const text = [
246
+ result.created ? 'āœ… Application fetched and uploaded.' : 'āœ… Application updated from URL.',
247
+ `App ID: ${result.id}`,
248
+ result.name ? `Name: ${result.name}` : '',
249
+ result.buildVersion ? `Build: ${result.buildVersion}` : '',
250
+ ]
251
+ .filter(Boolean)
252
+ .join('\n');
253
+ return { content: [{ type: 'text', text }] };
254
+ }
255
+ catch (e) {
256
+ const msg = e.message;
257
+ if (msg.includes('[400]')) {
258
+ return {
259
+ content: [{
260
+ type: 'text',
261
+ text: `Error: URL upload rejected by platform (400 validation error).\n\n` +
262
+ `Common causes:\n` +
263
+ ` • Redirecting URL — the platform fetches server-side and does not follow redirects. Use a permanent direct download link.\n` +
264
+ ` • Authentication required — URLs that need cookies, tokens, or login cannot be fetched by the platform.\n` +
265
+ ` • Unsupported file type — only APK, IPA, AAB, and ZIP are accepted.\n` +
266
+ ` • URL not reachable from the platform server — verify the artifact URL is publicly accessible.\n\n` +
267
+ `Tested URL: ${url}\n\n` +
268
+ `If you cannot provide a direct artifact URL, use upload_application_file with a volume-mounted local path instead.`,
269
+ }],
270
+ isError: true,
271
+ };
272
+ }
273
+ return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
274
+ }
275
+ });
276
+ server.tool('get_application_upload_command', 'Generates a ready-to-run curl or PowerShell command for uploading an app binary directly from the user\'s local machine to the Digital.ai platform. ' +
277
+ 'The MCP server itself does not handle the binary — the user runs the generated command locally so the file never passes through the Docker container. ' +
278
+ 'Use this instead of upload_application_file when the binary is on a local machine and volume-mounting is not practical.\n\n' +
279
+ 'WARNING: The generated command embeds the active access key in plaintext. ' +
280
+ 'Instruct the user to run it immediately and not save or share the output.', {
281
+ localFilePath: z.string().describe('Full path to the binary on the user\'s local machine, used verbatim in the generated command. ' +
282
+ 'Examples: "C:\\\\Downloads\\\\MyApp.apk" (Windows), "/Users/joe/Downloads/MyApp.ipa" (macOS).'),
283
+ localPlatform: z.enum(['windows', 'macos', 'linux']).describe('Platform of the machine where the command will be run. ' +
284
+ '"windows" produces both a Git Bash curl command and a PowerShell alternative. ' +
285
+ '"macos"/"linux" produce a bash curl command. Cannot be inferred — the MCP runs in Docker.'),
286
+ uniqueName: z.string().optional().describe('Short unique alias to assign to the uploaded app.'),
287
+ project: z.string().optional().describe('Project name to assign the app to. Cloud Admin only — project keys upload to their assigned project; this param is ignored.'),
288
+ camera: z.boolean().optional().describe('Enable camera support instrumentation.'),
289
+ touchId: z.boolean().optional().describe('Enable Touch ID support (iOS).'),
290
+ uuid: z.string().optional().describe('iOS provisioning profile UUID for signing.'),
291
+ fixKeychainAccess: z.boolean().optional().describe('Fix keychain access for iOS.'),
292
+ allowResign: z.boolean().optional().describe('Allow app re-signing for iOS.'),
293
+ signPlugins: z.boolean().optional().describe('Sign app plugins/extensions for iOS.'),
294
+ installMDM: z.boolean().optional().describe('Install via MDM (iOS).'),
295
+ autoTrustEnterpriseDeveloper: z.boolean().optional().describe('Auto-trust enterprise developer (iOS).'),
296
+ keystorePassword: z.string().optional().describe('Keystore password for Android custom signing. Will appear in plaintext in the generated command.'),
297
+ keyAlias: z.string().optional().describe('Key alias for Android custom signing.'),
298
+ keyPassword: z.string().optional().describe('Key password for Android custom signing. Will appear in plaintext in the generated command.'),
299
+ networkCaptureSupport: z.boolean().optional().describe('Enable network capture for Android.'),
300
+ outputFormat: outputFormatParam,
301
+ }, async ({ localFilePath, localPlatform, uniqueName, project, camera, touchId, uuid, fixKeychainAccess, allowResign, signPlugins, installMDM, autoTrustEnterpriseDeveloper, keystorePassword, keyAlias, keyPassword, networkCaptureSupport, outputFormat, }) => {
302
+ const accessKey = getActiveAccessKey();
303
+ const baseUrl = getActiveUrl();
304
+ const isJwt = getActiveKeyType() === 'jwt';
305
+ const isWindows = localPlatform === 'windows';
306
+ const endpoint = `${baseUrl}/api/v1/applications/new`;
307
+ // Collect optional form fields in declaration order (mirrors upload_application_file)
308
+ const fields = [];
309
+ if (uniqueName)
310
+ fields.push(['uniqueName', uniqueName]);
311
+ if (camera !== undefined)
312
+ fields.push(['camera', String(camera)]);
313
+ if (touchId !== undefined)
314
+ fields.push(['touchId', String(touchId)]);
315
+ if (project)
316
+ fields.push(['project', project]);
317
+ if (uuid)
318
+ fields.push(['uuid', uuid]);
319
+ if (fixKeychainAccess !== undefined)
320
+ fields.push(['fixKeychainAccess', String(fixKeychainAccess)]);
321
+ if (allowResign !== undefined)
322
+ fields.push(['allowResign', String(allowResign)]);
323
+ if (signPlugins !== undefined)
324
+ fields.push(['signPlugins', String(signPlugins)]);
325
+ if (installMDM !== undefined)
326
+ fields.push(['installMDM', String(installMDM)]);
327
+ if (autoTrustEnterpriseDeveloper !== undefined)
328
+ fields.push(['autoTrustEnterpriseDeveloper', String(autoTrustEnterpriseDeveloper)]);
329
+ if (keystorePassword)
330
+ fields.push(['keystorePassword', keystorePassword]);
331
+ if (keyAlias)
332
+ fields.push(['keyAlias', keyAlias]);
333
+ if (keyPassword)
334
+ fields.push(['keyPassword', keyPassword]);
335
+ if (networkCaptureSupport !== undefined)
336
+ fields.push(['networkCaptureSupport', String(networkCaptureSupport)]);
337
+ // curl — works on macOS, Linux, Git Bash, and WSL
338
+ const curlFilePath = localFilePath.replace(/\\/g, '/');
339
+ const curlLines = ['curl -X POST \\'];
340
+ if (isJwt) {
341
+ curlLines.push(` -H "Authorization: Bearer ${accessKey}" \\`);
342
+ }
343
+ else {
344
+ curlLines.push(` -H "X-API-KEY: ${accessKey}" \\`);
345
+ curlLines.push(` -H "Authorization: Bearer ${accessKey}" \\`);
346
+ }
347
+ curlLines.push(` -F "file=@${curlFilePath}" \\`);
348
+ for (const [k, v] of fields)
349
+ curlLines.push(` -F "${k}=${v}" \\`);
350
+ curlLines.push(` "${endpoint}"`);
351
+ const curlCommand = curlLines.join('\n');
352
+ // PowerShell (Invoke-RestMethod) — Windows native
353
+ const psLines = [];
354
+ psLines.push('$headers = @{');
355
+ if (isJwt) {
356
+ psLines.push(` "Authorization" = "Bearer ${accessKey}"`);
357
+ }
358
+ else {
359
+ psLines.push(` "X-API-KEY" = "${accessKey}"`);
360
+ psLines.push(` "Authorization" = "Bearer ${accessKey}"`);
361
+ }
362
+ psLines.push('}');
363
+ psLines.push('$form = @{');
364
+ psLines.push(` "file" = Get-Item "${localFilePath}"`);
365
+ for (const [k, v] of fields)
366
+ psLines.push(` "${k}" = "${v}"`);
367
+ psLines.push('}');
368
+ psLines.push(`Invoke-RestMethod -Uri "${endpoint}" \``);
369
+ psLines.push(' -Method POST `');
370
+ psLines.push(' -Headers $headers `');
371
+ psLines.push(' -Form $form');
372
+ const psCommand = psLines.join('\n');
373
+ // Build human-readable output
374
+ const lines = [];
375
+ lines.push('āš ļø WARNING: The commands below embed your access key in plaintext.');
376
+ lines.push(' Run immediately — do not save, share, or commit this output.');
377
+ lines.push('');
378
+ if (!isJwt && project) {
379
+ lines.push('āš ļø NOTE: The "project" field requires Cloud Admin access. The active key is a project-level key —');
380
+ lines.push(' the platform will ignore "project" and upload to your default project.');
381
+ lines.push(' To target a specific project: switch_environment("<admin-profile>") → re-run → switch back.');
382
+ lines.push('');
383
+ }
384
+ if (isWindows) {
385
+ lines.push('─── Git Bash / WSL / macOS curl ─────────────────────────────────');
386
+ lines.push('');
387
+ lines.push('```bash');
388
+ lines.push(curlCommand);
389
+ lines.push('```');
390
+ lines.push('');
391
+ lines.push('─── PowerShell (Invoke-RestMethod) ──────────────────────────────');
392
+ lines.push('');
393
+ lines.push('```powershell');
394
+ lines.push(psCommand);
395
+ lines.push('```');
396
+ }
397
+ else {
398
+ lines.push('```bash');
399
+ lines.push(curlCommand);
400
+ lines.push('```');
401
+ }
402
+ return respond(outputFormat, { endpoint, curlCommand, psCommand: isWindows ? psCommand : null }, lines.join('\n'));
403
+ });
404
+ server.tool('delete_application', 'Permanently removes an app from the repository. Any test scripts using this app may break. Requires confirmDeletion: true.', {
405
+ applicationId: z.number().describe('The numeric application ID to delete.'),
406
+ confirmDeletion: z
407
+ .boolean()
408
+ .describe('Must be true to confirm this destructive, irreversible operation. No changes are made without this.'),
409
+ }, async ({ applicationId, confirmDeletion }) => {
410
+ const guard = checkDestructiveGuard(confirmDeletion, `Delete application ${applicationId}`);
411
+ if (guard)
412
+ return { content: [{ type: 'text', text: guard }] };
413
+ try {
414
+ await deleteApplication(applicationId);
415
+ return {
416
+ content: [
417
+ { type: 'text', text: `āœ… Application ${applicationId} permanently deleted.` },
418
+ ],
419
+ };
420
+ }
421
+ catch (e) {
422
+ return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
423
+ }
424
+ });
425
+ server.tool('update_application_plugins', "Updates the signing profiles (provisioning profiles) assigned to iOS app extensions/plugins. Use 'Auto' as the UUID to use the default profile. iOS only.", {
426
+ applicationId: z.number().describe('The numeric iOS application ID.'),
427
+ plugins: z
428
+ .array(z.object({
429
+ name: z.string().describe('Name of the plugin/extension.'),
430
+ uuid: z.string().describe("Provisioning profile UUID, or 'Auto' for default."),
431
+ }))
432
+ .describe("List of plugins with their signing profile UUIDs. Use 'Auto' for the default profile."),
433
+ }, async ({ applicationId, plugins }) => {
434
+ try {
435
+ const result = await updateApplicationPlugins(applicationId, plugins);
436
+ const lines = result.map((p) => ` • ${p.name}: ${p.uuid}`);
437
+ return {
438
+ content: [
439
+ {
440
+ type: 'text',
441
+ text: `āœ… App ${applicationId} plugins updated:\n${lines.join('\n')}`,
442
+ },
443
+ ],
444
+ };
445
+ }
446
+ catch (e) {
447
+ return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
448
+ }
449
+ });
450
+ server.tool('install_application', 'Installs an app on one or more devices. The device(s) must be available and not reserved. ' +
451
+ 'IMPORTANT: If you plan to use get_remote_debug_command, install the app FIRST — installation fails ' +
452
+ 'while a device is reserved via an rdb tunnel. ' +
453
+ 'PREREQUISITE: The app must be assigned to a project that contains the target device. ' +
454
+ 'If you get a 400 error, call assign_app_to_project(projectId, applicationId) first, then retry. ' +
455
+ 'For Android, use keepData: true to upgrade the app without losing existing app data.', {
456
+ applicationId: z.number().describe('The numeric application ID.'),
457
+ deviceId: z.string().optional().describe('Single device to install on — numeric platform ID, serial number/UDID, or unambiguous device name. Serials are resolved to the numeric ID automatically.'),
458
+ devicesList: z
459
+ .string()
460
+ .optional()
461
+ .describe('Comma-separated list of numeric device IDs (e.g. "8,235,54").'),
462
+ allDevices: z
463
+ .boolean()
464
+ .optional()
465
+ .describe('Install on all available matching devices.'),
466
+ instrument: z.boolean().optional().default(false).describe('Instrument the app during install.'),
467
+ keepData: z
468
+ .boolean()
469
+ .optional()
470
+ .default(false)
471
+ .describe('Keep existing app data during install (Android only).'),
472
+ }, async ({ applicationId, deviceId, devicesList, allDevices, instrument, keepData }) => {
473
+ try {
474
+ if (!deviceId && !devicesList && !allDevices) {
475
+ return {
476
+ content: [
477
+ {
478
+ type: 'text',
479
+ text: 'Error: You must specify at least one of: deviceId, devicesList, or allDevices: true.',
480
+ },
481
+ ],
482
+ isError: true,
483
+ };
484
+ }
485
+ // The install endpoint requires the numeric platform ID — resolve serials/UDIDs/names.
486
+ let resolvedDeviceId = deviceId;
487
+ if (deviceId && !/^\d+$/.test(deviceId.trim())) {
488
+ const resolved = await resolveDevice(deviceId);
489
+ resolvedDeviceId = resolved.id;
490
+ }
491
+ const result = await installApplication(applicationId, {
492
+ deviceId: resolvedDeviceId,
493
+ devicesList,
494
+ allDevices,
495
+ instrument,
496
+ keepData,
497
+ });
498
+ const lines = Object.entries(result).map(([device, status]) => ` • Device ${device}: ${status}`);
499
+ return {
500
+ content: [
501
+ {
502
+ type: 'text',
503
+ text: `āœ… Install results for app ${applicationId}:\n${lines.join('\n')}`,
504
+ },
505
+ ],
506
+ };
507
+ }
508
+ catch (e) {
509
+ const msg = e.message ?? String(e);
510
+ let hint = '';
511
+ if (msg.includes("long parameter 'deviceId' is invalid")) {
512
+ hint = ' — deviceId must be the numeric platform ID (e.g. 16751287), not the device serial number. ' +
513
+ 'Pass the serial as deviceId and this tool will resolve it, or use list_devices(@serialNumber=\'...\') to look up the ID.';
514
+ }
515
+ else if (msg.includes('400')) {
516
+ hint = ' — 400 errors on install usually mean the app is not assigned to the target device\'s project ' +
517
+ '(call assign_app_to_project(projectId, applicationId) and retry), or the device is currently reserved ' +
518
+ '(e.g. by an rdb tunnel or an inspection session — release it first).';
519
+ }
520
+ return { content: [{ type: 'text', text: `Error: ${msg}${hint}` }], isError: true };
521
+ }
522
+ });
523
+ server.tool('uninstall_application', 'Uninstalls an app from one or more devices. App data on the device is lost. Requires confirmDeletion: true.', {
524
+ applicationId: z.number().describe('The numeric application ID.'),
525
+ deviceId: z.string().optional().describe('Single device ID.'),
526
+ devicesList: z.string().optional().describe('Comma-separated device IDs.'),
527
+ allDevices: z.boolean().optional().describe('Uninstall from all devices.'),
528
+ confirmDeletion: z
529
+ .boolean()
530
+ .optional()
531
+ .describe('Must be true to confirm this destructive operation. No changes are made without this.'),
532
+ }, async ({ applicationId, deviceId, devicesList, allDevices, confirmDeletion }) => {
533
+ try {
534
+ if (!deviceId && !devicesList && !allDevices) {
535
+ return {
536
+ content: [
537
+ {
538
+ type: 'text',
539
+ text: 'Error: You must specify at least one of: deviceId, devicesList, or allDevices: true.',
540
+ },
541
+ ],
542
+ isError: true,
543
+ };
544
+ }
545
+ const target = allDevices ? 'ALL devices' : devicesList ? `devices ${devicesList}` : `device ${deviceId}`;
546
+ const guard = checkDestructiveGuard(confirmDeletion, `Uninstall application ${applicationId} from ${target}`);
547
+ if (guard)
548
+ return { content: [{ type: 'text', text: guard }] };
549
+ const result = await uninstallApplication(applicationId, {
550
+ deviceId,
551
+ devicesList,
552
+ allDevices,
553
+ });
554
+ const lines = Object.entries(result).map(([device, status]) => ` • Device ${device}: ${status}`);
555
+ return {
556
+ content: [
557
+ {
558
+ type: 'text',
559
+ text: `āœ… Uninstall results for app ${applicationId}:\n${lines.join('\n')}`,
560
+ },
561
+ ],
562
+ };
563
+ }
564
+ catch (e) {
565
+ return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
566
+ }
567
+ });
568
+ server.tool('uninstall_application_by_package', 'Uninstalls an app from a single device using the package name (Android) or bundle ID (iOS), without needing the app\'s numeric ID. App data on the device is lost. Requires confirmDeletion: true.', {
569
+ deviceId: z.string().describe('The numeric device ID.'),
570
+ packageName: z
571
+ .string()
572
+ .describe('Android package name (e.g. com.mycompany.app) or iOS bundle identifier.'),
573
+ confirmDeletion: z
574
+ .boolean()
575
+ .optional()
576
+ .describe('Must be true to confirm this destructive operation. No changes are made without this.'),
577
+ }, async ({ deviceId, packageName, confirmDeletion }) => {
578
+ try {
579
+ const guard = checkDestructiveGuard(confirmDeletion, `Uninstall "${packageName}" from device ${deviceId}`);
580
+ if (guard)
581
+ return { content: [{ type: 'text', text: guard }] };
582
+ await uninstallApplicationByPackage(deviceId, packageName);
583
+ return {
584
+ content: [
585
+ {
586
+ type: 'text',
587
+ text: `āœ… App "${packageName}" uninstalled from device ${deviceId}.`,
588
+ },
589
+ ],
590
+ };
591
+ }
592
+ catch (e) {
593
+ return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
594
+ }
595
+ });
596
+ server.tool('uninstall_application_by_package_from_devices', 'Uninstalls an app from multiple devices at once using the package name or bundle ID. App data on the devices is lost. Requires confirmDeletion: true.', {
597
+ devicesList: z
598
+ .string()
599
+ .describe('Comma-separated device IDs, e.g. "8,235,54".'),
600
+ packageName: z
601
+ .string()
602
+ .describe('Android package name or iOS bundle identifier.'),
603
+ confirmDeletion: z
604
+ .boolean()
605
+ .optional()
606
+ .describe('Must be true to confirm this destructive operation. No changes are made without this.'),
607
+ }, async ({ devicesList, packageName, confirmDeletion }) => {
608
+ try {
609
+ const guard = checkDestructiveGuard(confirmDeletion, `Uninstall "${packageName}" from devices ${devicesList}`);
610
+ if (guard)
611
+ return { content: [{ type: 'text', text: guard }] };
612
+ await uninstallApplicationByPackageFromDevices(devicesList, packageName);
613
+ return {
614
+ content: [
615
+ {
616
+ type: 'text',
617
+ text: `āœ… App "${packageName}" uninstall command sent to devices: ${devicesList}`,
618
+ },
619
+ ],
620
+ };
621
+ }
622
+ catch (e) {
623
+ return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
624
+ }
625
+ });
626
+ server.tool('find_latest_application', 'Finds the most recently uploaded version of an app. ' +
627
+ 'Search by appName (partial, case-insensitive — e.g. "ExperiBank") without needing the bundle ID or package name. ' +
628
+ 'Or search by bundleIdentifier (iOS) or packageName (Android) for exact matching. ' +
629
+ 'osType is optional when searching by appName; omit it to search across all platforms. ' +
630
+ 'PROJECT-AWARE: when several uploads match, the newest one assigned to your ACTIVE project is preferred ' +
631
+ '(install/session run in the active project context — an app assigned only to another project will fail there). ' +
632
+ 'The response lists each app\'s project assignments; heed the projectWarning if present. ' +
633
+ 'Returns the app ID needed by assign_app_to_project. ' +
634
+ 'Used in create_poc Step 10 to locate a demo app before assigning it to the POC project.', {
635
+ appName: z
636
+ .string()
637
+ .optional()
638
+ .describe('Find by app name — partial, case-insensitive match. E.g. "ExperiBank" finds the latest upload whose name contains "ExperiBank". ' +
639
+ 'Use this when you do not know the bundle identifier or package name.'),
640
+ osType: z.enum(['ios', 'android']).optional().describe("Platform: 'ios' or 'android'. Optional when searching by appName alone."),
641
+ packageName: z
642
+ .string()
643
+ .optional()
644
+ .describe('Android package name (e.g. com.mycompany.app). Exact server-side filter.'),
645
+ bundleIdentifier: z
646
+ .string()
647
+ .optional()
648
+ .describe('iOS bundle identifier (e.g. com.mycompany.app). Exact server-side filter.'),
649
+ outputFormat: outputFormatParam,
650
+ }, async ({ appName, osType, packageName, bundleIdentifier, outputFormat }) => {
651
+ try {
652
+ // Guard against mis-named parameters (e.g. name= / os=): with no criteria
653
+ // this tool would otherwise "find" the newest app in the entire catalog.
654
+ if (!appName && !packageName && !bundleIdentifier) {
655
+ return {
656
+ content: [{
657
+ type: 'text',
658
+ text: 'Error: provide at least one search criterion — appName (partial match), packageName (Android), or bundleIdentifier (iOS). ' +
659
+ 'Parameter names matter: use appName (not "name") and osType (not "os").',
660
+ }],
661
+ isError: true,
662
+ };
663
+ }
664
+ let apps = await getApplications({ osType, packageName, bundleIdentifier });
665
+ if (appName) {
666
+ const q = appName.toLowerCase();
667
+ apps = apps.filter(a => a.applicationName.toLowerCase().includes(q));
668
+ }
669
+ if (apps.length === 0) {
670
+ return respond(outputFormat, { found: false }, 'No applications found matching your criteria.');
671
+ }
672
+ const sorted = apps.sort((a, b) => b.createdAt - a.createdAt);
673
+ // Prefer the newest upload assigned to the ACTIVE project — install and
674
+ // inspection sessions run in the active project context, so a copy that
675
+ // only lives in another project will fail there (v36).
676
+ let activeProject;
677
+ try {
678
+ const me = await getMyAccountInfo();
679
+ activeProject = { id: me.project.id, name: me.project.name };
680
+ }
681
+ catch {
682
+ // Non-fatal — fall back to global newest
683
+ }
684
+ const inActiveProject = activeProject
685
+ ? sorted.filter(a => (a.projectsInfo ?? []).some(p => p.id === activeProject.id))
686
+ : [];
687
+ const latest = inActiveProject[0] ?? sorted[0];
688
+ const preferredOverNewer = inActiveProject[0] != null && inActiveProject[0].id !== sorted[0].id;
689
+ const projectWarning = activeProject && !(latest.projectsInfo ?? []).some(p => p.id === activeProject.id)
690
+ ? `App ${latest.id} is NOT assigned to your active project "${activeProject.name}" — install and inspection sessions will fail there. ` +
691
+ `Assign it first (assign_app_to_project) or switch to a project that has it: ${(latest.projectsInfo ?? []).map(p => p.name).join(', ') || '(none)'}.`
692
+ : undefined;
693
+ // Build the ready-to-use `app` capability string for Appium
694
+ let appCapabilityString;
695
+ if (latest.uniqueName) {
696
+ appCapabilityString = `cloud:${latest.uniqueName}`;
697
+ }
698
+ else if (latest.packageName) {
699
+ appCapabilityString = `cloud:${latest.packageName}`;
700
+ }
701
+ else if (latest.bundleIdentifier) {
702
+ appCapabilityString = `cloud:${latest.bundleIdentifier}`;
703
+ }
704
+ const structured = {
705
+ ...latest,
706
+ appCapabilityString,
707
+ activeProject,
708
+ ...(projectWarning && { projectWarning }),
709
+ };
710
+ const humanText = [
711
+ `šŸ“¦ Latest: ${latest.applicationName}`,
712
+ `ID: ${latest.id}`,
713
+ `Version: ${latest.releaseVersion} (build ${latest.buildVersion})`,
714
+ `File Type: ${latest.fileType.toUpperCase()}`,
715
+ `Package: ${latest.packageName ?? latest.bundleIdentifier ?? 'N/A'}`,
716
+ `Uploaded: ${latest.createdAtFormatted}`,
717
+ `Unique Name: ${latest.uniqueName ?? 'none'}`,
718
+ `Projects: ${(latest.projectsInfo ?? []).map(p => p.name).join(', ') || '(none)'}`,
719
+ appCapabilityString ? `App Capability: ${appCapabilityString}` : '',
720
+ preferredOverNewer
721
+ ? `\nNote: a newer upload exists (ID ${sorted[0].id}, ${sorted[0].createdAtFormatted}) but is not assigned to your active project "${activeProject?.name}" — returned the newest copy that is.`
722
+ : '',
723
+ projectWarning ? `\nāš ļø ${projectWarning}` : '',
724
+ apps.length > 1
725
+ ? `\nNote: ${apps.length - 1} other matching upload(s) in the repository.`
726
+ : '',
727
+ ]
728
+ .filter(Boolean)
729
+ .join('\n');
730
+ return respond(outputFormat, structured, humanText);
731
+ }
732
+ catch (e) {
733
+ return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
734
+ }
735
+ });
736
+ server.tool('extract_app_language_files', 'Downloads the localization/language files from an app as a ZIP archive. Useful for reviewing or auditing app translations. APK and IPA only.' + SERVER_FS_DOWNLOAD_NOTICE, {
737
+ applicationId: z.number().describe('The numeric application ID (APK or IPA only).'),
738
+ localPath: z.string().describe(SERVER_FS_OUTPUT_PARAM),
739
+ }, async ({ applicationId, localPath }) => {
740
+ const pathErr = validateOutputPath(localPath);
741
+ if (pathErr)
742
+ return { content: [{ type: 'text', text: `Error: ${pathErr}` }], isError: true };
743
+ try {
744
+ await extractLanguageFiles(applicationId, localPath);
745
+ return {
746
+ content: [
747
+ {
748
+ type: 'text',
749
+ text: `āœ… Language files for app ${applicationId} extracted to: ${localPath}`,
750
+ },
751
+ ],
752
+ };
753
+ }
754
+ catch (e) {
755
+ return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
756
+ }
757
+ });
758
+ server.tool('get_app_language_files_download_command', 'Generates a ready-to-run curl or PowerShell command for downloading an app\'s localization/language-file ZIP directly to the user\'s local machine. ' +
759
+ 'Use this instead of extract_app_language_files when the MCP server runs in Docker/remote and the written file would be inaccessible to the user. APK and IPA only.\n\n' +
760
+ 'WARNING: The generated command embeds the active access key in plaintext. Instruct the user to run it immediately and not save or share the output.', {
761
+ applicationId: z.number().describe('The numeric application ID (APK or IPA only).'),
762
+ localPath: z.string().optional().default('language-files.zip').describe('Path on the user\'s local machine to save the ZIP. Default: "language-files.zip".'),
763
+ localPlatform: z.enum(['windows', 'macos', 'linux']).describe('Platform of the machine that will run the command. "windows" emits both Git Bash curl and PowerShell. Cannot be inferred — the MCP runs in Docker.'),
764
+ outputFormat: outputFormatParam,
765
+ }, async ({ applicationId, localPath, localPlatform, outputFormat }) => {
766
+ const result = buildDownloadCommand({ path: `/api/v1/applications/${applicationId}/language-file`, localPath: localPath ?? 'language-files.zip', localPlatform });
767
+ return respond(outputFormat, { endpoint: result.endpoint, curlCommand: result.curlCommand, psCommand: result.psCommand }, result.humanText);
768
+ });
769
+ // ─── bulk_install_to_group ────────────────────────────────────────────────
770
+ server.tool('bulk_install_to_group', 'Install an app on every device in a device group in a single call. Replaces the tedious one-device-at-a-time workflow when setting up a test run. Reports per-device success/failure so you can see which devices had problems.', {
771
+ applicationId: z
772
+ .number()
773
+ .int()
774
+ .describe('Numeric application ID to install. Use list_applications to find it.'),
775
+ deviceGroupId: z
776
+ .string()
777
+ .describe('Device group ID whose devices will receive the app. Use list_device_groups to find it.'),
778
+ instrument: z
779
+ .boolean()
780
+ .optional()
781
+ .describe('If true, the app is instrumented for test automation. Default: false.'),
782
+ keepData: z
783
+ .boolean()
784
+ .optional()
785
+ .describe('If true, existing app data is preserved on reinstall. Default: false.'),
786
+ }, async ({ applicationId, deviceGroupId, instrument, keepData }) => {
787
+ try {
788
+ const devices = await getDevicesInDeviceGroup(deviceGroupId);
789
+ if (devices.length === 0) {
790
+ return { content: [{ type: 'text', text: `Device group ${deviceGroupId} has no devices.` }] };
791
+ }
792
+ const results = [`Installing app ${applicationId} on ${devices.length} device(s) in group ${deviceGroupId}:\n`];
793
+ for (const device of devices) {
794
+ try {
795
+ await installApplication(applicationId, {
796
+ deviceId: device.id,
797
+ instrument: instrument ?? false,
798
+ keepData: keepData ?? false,
799
+ });
800
+ results.push(` āœ… ${device.deviceName} (ID: ${device.id})`);
801
+ }
802
+ catch (err) {
803
+ results.push(` āŒ ${device.deviceName} (ID: ${device.id}) — ${err.message}`);
804
+ }
805
+ }
806
+ const succeeded = results.filter((l) => l.includes('āœ…')).length;
807
+ const failed = results.filter((l) => l.includes('āŒ')).length;
808
+ results.push(`\nDone: ${succeeded} succeeded, ${failed} failed.`);
809
+ return { content: [{ type: 'text', text: results.join('\n') }] };
810
+ }
811
+ catch (e) {
812
+ return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
813
+ }
814
+ });
815
+ }
816
+ //# sourceMappingURL=application-tools.js.map