digital-ai-testing-mcp 1.2.8 โ 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +147 -46
- package/dist/api/browser-inspection.d.ts.map +1 -1
- package/dist/api/browser-inspection.js +14 -15
- package/dist/api/browser-inspection.js.map +1 -1
- package/dist/api/client.d.ts +7 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +9 -0
- package/dist/api/client.js.map +1 -1
- package/dist/api/projects.d.ts +16 -3
- package/dist/api/projects.d.ts.map +1 -1
- package/dist/api/projects.js +60 -18
- package/dist/api/projects.js.map +1 -1
- package/dist/api/reporting.d.ts +91 -0
- package/dist/api/reporting.d.ts.map +1 -1
- package/dist/api/reporting.js +178 -6
- package/dist/api/reporting.js.map +1 -1
- package/dist/api/test-orchestrator.d.ts +59 -0
- package/dist/api/test-orchestrator.d.ts.map +1 -0
- package/dist/api/test-orchestrator.js +126 -0
- package/dist/api/test-orchestrator.js.map +1 -0
- package/dist/api/test-runs.d.ts +80 -0
- package/dist/api/test-runs.d.ts.map +1 -0
- package/dist/api/test-runs.js +209 -0
- package/dist/api/test-runs.js.map +1 -0
- package/dist/api/test-views.d.ts.map +1 -1
- package/dist/api/test-views.js +5 -1
- package/dist/api/test-views.js.map +1 -1
- package/dist/api/transactions.d.ts +6 -0
- package/dist/api/transactions.d.ts.map +1 -1
- package/dist/api/transactions.js +19 -3
- package/dist/api/transactions.js.map +1 -1
- package/dist/api/usage-reports.d.ts.map +1 -1
- package/dist/api/usage-reports.js +3 -3
- package/dist/api/usage-reports.js.map +1 -1
- package/dist/api/webdriver.d.ts +39 -1
- package/dist/api/webdriver.d.ts.map +1 -1
- package/dist/api/webdriver.js +169 -65
- package/dist/api/webdriver.js.map +1 -1
- package/dist/index.js +79 -32
- package/dist/index.js.map +1 -1
- package/dist/tools/agent-tools.js +2 -2
- package/dist/tools/agent-tools.js.map +1 -1
- package/dist/tools/application-tools.d.ts.map +1 -1
- package/dist/tools/application-tools.js +5 -4
- package/dist/tools/application-tools.js.map +1 -1
- package/dist/tools/boilerplate-tools.d.ts +3 -0
- package/dist/tools/boilerplate-tools.d.ts.map +1 -1
- package/dist/tools/boilerplate-tools.js +301 -20
- package/dist/tools/boilerplate-tools.js.map +1 -1
- package/dist/tools/browser-tools.d.ts.map +1 -1
- package/dist/tools/browser-tools.js +8 -5
- package/dist/tools/browser-tools.js.map +1 -1
- package/dist/tools/device-group-tools.js +5 -5
- package/dist/tools/device-group-tools.js.map +1 -1
- package/dist/tools/device-tools.d.ts.map +1 -1
- package/dist/tools/device-tools.js +5 -4
- package/dist/tools/device-tools.js.map +1 -1
- package/dist/tools/health-tools.d.ts.map +1 -1
- package/dist/tools/health-tools.js +5 -4
- package/dist/tools/health-tools.js.map +1 -1
- package/dist/tools/inspection-tools.d.ts.map +1 -1
- package/dist/tools/inspection-tools.js +110 -10
- package/dist/tools/inspection-tools.js.map +1 -1
- package/dist/tools/meta-tools.d.ts +4 -1
- package/dist/tools/meta-tools.d.ts.map +1 -1
- package/dist/tools/meta-tools.js +59 -36
- package/dist/tools/meta-tools.js.map +1 -1
- package/dist/tools/performance-tools.d.ts.map +1 -1
- package/dist/tools/performance-tools.js +1 -7
- package/dist/tools/performance-tools.js.map +1 -1
- package/dist/tools/project-tools.d.ts.map +1 -1
- package/dist/tools/project-tools.js +38 -19
- package/dist/tools/project-tools.js.map +1 -1
- package/dist/tools/provisioning-profile-tools.d.ts.map +1 -1
- package/dist/tools/provisioning-profile-tools.js +5 -4
- package/dist/tools/provisioning-profile-tools.js.map +1 -1
- package/dist/tools/remediation-tools.d.ts +7 -0
- package/dist/tools/remediation-tools.d.ts.map +1 -0
- package/dist/tools/remediation-tools.js +50 -0
- package/dist/tools/remediation-tools.js.map +1 -0
- package/dist/tools/reporting-tools.d.ts.map +1 -1
- package/dist/tools/reporting-tools.js +334 -134
- package/dist/tools/reporting-tools.js.map +1 -1
- package/dist/tools/repository-tools.d.ts.map +1 -1
- package/dist/tools/repository-tools.js +5 -4
- package/dist/tools/repository-tools.js.map +1 -1
- package/dist/tools/reservation-tools.js +2 -2
- package/dist/tools/reservation-tools.js.map +1 -1
- package/dist/tools/test-run-tools.d.ts +3 -0
- package/dist/tools/test-run-tools.d.ts.map +1 -0
- package/dist/tools/test-run-tools.js +284 -0
- package/dist/tools/test-run-tools.js.map +1 -0
- package/dist/tools/test-view-tools.d.ts.map +1 -1
- package/dist/tools/test-view-tools.js +11 -11
- package/dist/tools/test-view-tools.js.map +1 -1
- package/dist/tools/toolset-tools.d.ts +8 -0
- package/dist/tools/toolset-tools.d.ts.map +1 -0
- package/dist/tools/toolset-tools.js +40 -0
- package/dist/tools/toolset-tools.js.map +1 -0
- package/dist/tools/transaction-tools.d.ts.map +1 -1
- package/dist/tools/transaction-tools.js +17 -7
- package/dist/tools/transaction-tools.js.map +1 -1
- package/dist/tools/usage-report-tools.d.ts.map +1 -1
- package/dist/tools/usage-report-tools.js +43 -15
- package/dist/tools/usage-report-tools.js.map +1 -1
- package/dist/tools/user-tools.js +2 -2
- package/dist/tools/user-tools.js.map +1 -1
- package/dist/tools/web-inspection-tools.d.ts.map +1 -1
- package/dist/tools/web-inspection-tools.js +39 -26
- package/dist/tools/web-inspection-tools.js.map +1 -1
- package/dist/tools/workflow-tools.js +1 -1
- package/dist/types/digital-ai.d.ts +14 -1
- package/dist/types/digital-ai.d.ts.map +1 -1
- package/dist/utils/browser-name.d.ts +2 -0
- package/dist/utils/browser-name.d.ts.map +1 -0
- package/dist/utils/browser-name.js +19 -0
- package/dist/utils/browser-name.js.map +1 -0
- package/dist/utils/command-payload.d.ts +19 -0
- package/dist/utils/command-payload.d.ts.map +1 -0
- package/dist/utils/command-payload.js +13 -0
- package/dist/utils/command-payload.js.map +1 -0
- package/dist/utils/csv.d.ts +6 -0
- package/dist/utils/csv.d.ts.map +1 -1
- package/dist/utils/csv.js +28 -2
- package/dist/utils/csv.js.map +1 -1
- package/dist/utils/locality.d.ts +7 -0
- package/dist/utils/locality.d.ts.map +1 -1
- package/dist/utils/locality.js +19 -0
- package/dist/utils/locality.js.map +1 -1
- package/dist/utils/maestro-flow.d.ts +38 -0
- package/dist/utils/maestro-flow.d.ts.map +1 -0
- package/dist/utils/maestro-flow.js +114 -0
- package/dist/utils/maestro-flow.js.map +1 -0
- package/dist/utils/metric-semantics.d.ts +22 -0
- package/dist/utils/metric-semantics.d.ts.map +1 -0
- package/dist/utils/metric-semantics.js +24 -0
- package/dist/utils/metric-semantics.js.map +1 -0
- package/dist/utils/pagination.d.ts +11 -0
- package/dist/utils/pagination.d.ts.map +1 -1
- package/dist/utils/pagination.js +16 -0
- package/dist/utils/pagination.js.map +1 -1
- package/dist/utils/remediation.d.ts +113 -0
- package/dist/utils/remediation.d.ts.map +1 -0
- package/dist/utils/remediation.js +392 -0
- package/dist/utils/remediation.js.map +1 -0
- package/dist/utils/report-ref.d.ts +23 -0
- package/dist/utils/report-ref.d.ts.map +1 -0
- package/dist/utils/report-ref.js +31 -0
- package/dist/utils/report-ref.js.map +1 -0
- package/dist/utils/response-formatter.d.ts +2 -1
- package/dist/utils/response-formatter.d.ts.map +1 -1
- package/dist/utils/response-formatter.js +32 -21
- package/dist/utils/response-formatter.js.map +1 -1
- package/dist/utils/test-orchestrator.d.ts +102 -0
- package/dist/utils/test-orchestrator.d.ts.map +1 -0
- package/dist/utils/test-orchestrator.js +236 -0
- package/dist/utils/test-orchestrator.js.map +1 -0
- package/dist/utils/test-status.d.ts +48 -0
- package/dist/utils/test-status.d.ts.map +1 -0
- package/dist/utils/test-status.js +92 -0
- package/dist/utils/test-status.js.map +1 -0
- package/dist/utils/tool-catalog.d.ts +6 -0
- package/dist/utils/tool-catalog.d.ts.map +1 -0
- package/dist/utils/tool-catalog.js +15 -0
- package/dist/utils/tool-catalog.js.map +1 -0
- package/dist/utils/toolsets.d.ts +79 -0
- package/dist/utils/toolsets.d.ts.map +1 -0
- package/dist/utils/toolsets.js +156 -0
- package/dist/utils/toolsets.js.map +1 -0
- package/dist/utils/usage-report-guard.d.ts +7 -0
- package/dist/utils/usage-report-guard.d.ts.map +1 -1
- package/dist/utils/usage-report-guard.js +18 -1
- package/dist/utils/usage-report-guard.js.map +1 -1
- package/dist/utils/usage-report-summary.d.ts +12 -0
- package/dist/utils/usage-report-summary.d.ts.map +1 -1
- package/dist/utils/usage-report-summary.js +25 -6
- package/dist/utils/usage-report-summary.js.map +1 -1
- package/package.json +40 -4
- package/resources/boilerplate/Android-Native/Java JUnit5/gradle +6 -1
- package/resources/boilerplate/Android-Native/Java JUnit5/gradle-oss +6 -1
- package/resources/boilerplate/Android-Native/java TestNG/AndroidNative-oss.java +2 -2
- package/resources/boilerplate/Android-Native/java TestNG/AndroidNative.java +2 -2
- package/resources/boilerplate/Android-Native/java TestNG/gradle +1 -1
- package/resources/boilerplate/Android-Native/java TestNG/gradle-oss +1 -1
- package/resources/boilerplate/iOS-Native/java-JUnit5/gradle +6 -1
- package/resources/boilerplate/iOS-Native/java-JUnit5/gradle-oss +6 -1
- package/resources/boilerplate/iOS-Native/java-TestNG/gradle +1 -1
- package/resources/boilerplate/iOS-Native/java-TestNG/gradle-oss +1 -1
- package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative-oss.java +2 -2
- package/resources/boilerplate/iOS-Native/java-TestNG/iOSNative.java +2 -2
- package/resources/test-orchestrator/agent.json +19 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { getTestById, getTestByReportApiId, listTests, listTestsSortedDesc, getGroupedTests, getDistinctKeyValues, deleteTests, downloadTestAttachments, extractAttachmentLog, summarizeTestFailures, } from '../api/reporting.js';
|
|
2
|
+
import { getTestById, getTestByUuid, shareTestReport, getRootCauseAnalysis, RCA_MAX_ATTEMPTS, getTestByReportApiId, listTests, listTestsSortedDesc, getGroupedTests, getDistinctKeyValues, deleteTests, downloadTestAttachments, downloadTestVideo, getTestVideoInfo, extractAttachmentLog, summarizeTestFailures, } from '../api/reporting.js';
|
|
3
3
|
import { serverFsDownloadNotice, serverFsOutputParam, commandGeneratorNotice, localPlatformParamNotice } from '../utils/locality.js';
|
|
4
4
|
import { checkDeleteAllowed, serverSortAvailable } from '../api/access-level.js';
|
|
5
5
|
import { checkDestructiveGuard } from '../utils/destructive-guard.js';
|
|
@@ -7,53 +7,154 @@ import { validateOutputPath } from '../utils/path-guard.js';
|
|
|
7
7
|
import { buildDownloadCommand } from '../utils/download-command.js';
|
|
8
8
|
import { formatTestReport, formatTestReportList, formatFailureSummary, formatTestAttachments, formatGroupedTestReports, formatProjectTestSummary, } from '../utils/response-formatter.js';
|
|
9
9
|
import { outputFormatParam, respond } from '../utils/output-format.js';
|
|
10
|
+
import { commandPayload } from '../utils/command-payload.js';
|
|
11
|
+
import { parseReportRef } from '../utils/report-ref.js';
|
|
12
|
+
import { countsFromPivotRow, tallyStatuses, passRate, statusOutcome, unknownStatusCount, PASS_RATE_BASIS } from '../utils/test-status.js';
|
|
10
13
|
export function registerReportingTools(server) {
|
|
11
14
|
// โโโ get_test_report โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
12
|
-
server.tool('get_test_report', 'Retrieve a full test execution report by
|
|
13
|
-
'Provide
|
|
14
|
-
'
|
|
15
|
-
'NOTE: Step-level detail is not available
|
|
15
|
+
server.tool('get_test_report', 'Retrieve a full test execution report by UUID, numeric test ID, or the report URL printed in tearDown (digitalai:reportUrl โ e.g. .../reporter/video-report/<uuid>). ' +
|
|
16
|
+
'Provide ONE of uuid, testId or reportUrl. PREFER uuid (or the report URL): UUIDs are global, while numeric test IDs are only unique per project and can resolve to a different test in another project. ' +
|
|
17
|
+
'uuid and test_id are both returned by list_test_reports and find_latest_test_for_name. ' +
|
|
18
|
+
'NOTE: Step-level detail is not available on this endpoint โ the backend API does not support it here. ' +
|
|
16
19
|
'To get steps, use get_test_by_report_id with the report_api_id from a live session. ' +
|
|
17
20
|
'For failure diagnosis use the cause/errorCategory/errorDetail fields in this response, or get_test_log for the full Appium log.', {
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
uuid: z.string().optional().describe('The test execution UUID (uuid field from list results). Preferred โ globally unique.'),
|
|
22
|
+
testId: z.number().int().optional().describe('The numeric test ID (test_id field from list results, e.g. 377918). Unique only within a project โ prefer uuid.'),
|
|
23
|
+
reportUrl: z.string().optional().describe('The report URL printed by tearDown (digitalai:reportUrl), e.g. .../reporter/video-report/<uuid> or an older ...?test_id=<n> link. The identifier is extracted automatically.'),
|
|
20
24
|
outputFormat: outputFormatParam,
|
|
21
|
-
}, async ({ testId, reportUrl, outputFormat }) => {
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
}, async ({ uuid, testId, reportUrl, outputFormat }) => {
|
|
26
|
+
const given = [uuid, testId, reportUrl].filter((v) => v != null && v !== '').length;
|
|
27
|
+
if (given === 0) {
|
|
28
|
+
return { content: [{ type: 'text', text: 'Provide one of uuid, testId or reportUrl.' }], isError: true };
|
|
29
|
+
}
|
|
30
|
+
if (given > 1) {
|
|
31
|
+
return { content: [{ type: 'text', text: 'Provide only ONE of uuid, testId or reportUrl โ they could point at different reports.' }], isError: true };
|
|
32
|
+
}
|
|
33
|
+
const ref = parseReportRef(uuid ?? reportUrl ?? testId);
|
|
34
|
+
if (!ref) {
|
|
35
|
+
return {
|
|
36
|
+
content: [{ type: 'text', text: `Could not find a report UUID or numeric test ID in: ${uuid ?? reportUrl}. Use list_test_reports or find_latest_test_for_name to look the test up.` }],
|
|
37
|
+
isError: true,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const report = ref.kind === 'uuid' ? await getTestByUuid(ref.uuid) : await getTestById(ref.testId);
|
|
42
|
+
return respond(outputFormat, report, formatTestReport(report));
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
// โโโ share_test_report โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
49
|
+
server.tool('share_test_report', 'Create a PUBLIC link to a test report that anyone can open WITHOUT logging in โ the report page, its data (including ' +
|
|
50
|
+
'key-value pairs/capabilities) and its video. Links expire 14 days after first creation; sharing the same report again ' +
|
|
51
|
+
'returns the same link and does NOT extend it. There is no revoke: the only way to disable a link early is to delete the ' +
|
|
52
|
+
'report (delete_test_reports). Requires confirmPublicShare: true โ without it, this returns a preview of what would be ' +
|
|
53
|
+
'exposed and shares nothing. Only share when the user explicitly asked for a public/shareable link. ' +
|
|
54
|
+
'Fails if public sharing is disabled for the report\'s project.', {
|
|
55
|
+
uuid: z.string().optional().describe('Test execution UUID (uuid field from list_test_reports / get_test_report).'),
|
|
56
|
+
reportUrl: z.string().optional().describe('The report URL (e.g. .../reporter/video-report/<uuid>). Must contain the UUID.'),
|
|
57
|
+
confirmPublicShare: z
|
|
58
|
+
.boolean()
|
|
59
|
+
.optional()
|
|
60
|
+
.describe('Must be true to create the public link. Omit to preview what would be shared.'),
|
|
61
|
+
outputFormat: outputFormatParam,
|
|
62
|
+
}, async ({ uuid, reportUrl, confirmPublicShare, outputFormat }) => {
|
|
63
|
+
if ((uuid ? 1 : 0) + (reportUrl ? 1 : 0) !== 1) {
|
|
64
|
+
return { content: [{ type: 'text', text: 'Provide exactly one of uuid or reportUrl.' }], isError: true };
|
|
65
|
+
}
|
|
66
|
+
const ref = parseReportRef(uuid ?? reportUrl);
|
|
67
|
+
if (ref?.kind !== 'uuid') {
|
|
68
|
+
return {
|
|
69
|
+
content: [{ type: 'text', text: 'Sharing needs the report UUID (numeric test IDs are not accepted). Get it from list_test_reports or get_test_report (uuid field), or pass the .../video-report/<uuid> URL.' }],
|
|
70
|
+
isError: true,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
// Fetch first: confirms the report exists and is visible to this credential, and shows what would be exposed.
|
|
75
|
+
const report = await getTestByUuid(ref.uuid);
|
|
76
|
+
const what = `"${report.name}" (${report.status}, ${report.start_time}${report.projectName ? `, project ${report.projectName}` : ''})`;
|
|
77
|
+
if (report.sharingEnabled === false) {
|
|
30
78
|
return {
|
|
31
|
-
content: [{
|
|
32
|
-
type: 'text',
|
|
33
|
-
text: `The report URL contains a UUID, not a numeric test ID. The Digital.ai reporter API does not support UUID-based lookup.\n\n` +
|
|
34
|
-
`Use the numeric test ID from the "Report Test ID" line printed in tearDown (digitalai:reportTestId capability):\n` +
|
|
35
|
-
` get_test_report(testId: <the number from "Report Test ID">)\n\n` +
|
|
36
|
-
`Or find it via: list_test_reports or find_latest_test_for_name.`,
|
|
37
|
-
}],
|
|
79
|
+
content: [{ type: 'text', text: `Public sharing is disabled for ${what}'s project. A project admin must enable report sharing in the Reporter project settings first.` }],
|
|
38
80
|
isError: true,
|
|
39
81
|
};
|
|
40
82
|
}
|
|
41
|
-
|
|
83
|
+
if (confirmPublicShare !== true) {
|
|
42
84
|
return {
|
|
43
|
-
content: [{
|
|
44
|
-
|
|
85
|
+
content: [{
|
|
86
|
+
type: 'text',
|
|
87
|
+
text: `โ ๏ธ Preview โ nothing has been shared.\n\n` +
|
|
88
|
+
`This would create a PUBLIC link to ${what}. Anyone with the link can, without logging in:\n` +
|
|
89
|
+
` โข open the report page and its video\n` +
|
|
90
|
+
` โข read the report data, including all key-value pairs / capabilities\n` +
|
|
91
|
+
`The link lasts 14 days and cannot be revoked except by deleting the report.\n\n` +
|
|
92
|
+
`To proceed, call share_test_report again with confirmPublicShare: true.`,
|
|
93
|
+
}],
|
|
45
94
|
};
|
|
46
95
|
}
|
|
96
|
+
const share = await shareTestReport(ref.uuid);
|
|
97
|
+
const structured = { uuid: ref.uuid, testId: report.test_id, name: report.name, publicUrl: share.publicUrl, expires: share.expires };
|
|
98
|
+
const human = `๐ Public link for ${what}:\n${share.publicUrl}\n\n` +
|
|
99
|
+
`Expires: ${share.expires} (14 days after it was first shared โ re-sharing does not extend it).\n` +
|
|
100
|
+
`Anyone with this link can view the report, its data and its video without logging in. ` +
|
|
101
|
+
`To disable it early, delete the report (delete_test_reports).`;
|
|
102
|
+
return respond(outputFormat, structured, human);
|
|
47
103
|
}
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
104
|
+
catch (e) {
|
|
105
|
+
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
// โโโ get_root_cause_analysis โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
109
|
+
server.tool('get_root_cause_analysis', 'Read the platform\'s AI Root Cause Analysis for a failed test report: the hypothesis, the supporting evidence ' +
|
|
110
|
+
'(log lines with source, time and findings), the analysis status and attempts used, plus the reporter\'s own error ' +
|
|
111
|
+
'classification (errorCategory / errorClassification / cause). Read-only โ it never starts an analysis. ' +
|
|
112
|
+
'Analyses are started from the video report in the Reporter UI; they cover Appium Server tests only and allow ' +
|
|
113
|
+
'3 failed attempts per test. ineligibleReason explains when an analysis cannot be run. ' +
|
|
114
|
+
'To find analysed reports: list_test_reports with filter rca.status = COMPLETED.', {
|
|
115
|
+
uuid: z.string().optional().describe('Test execution UUID. Preferred.'),
|
|
116
|
+
reportUrl: z.string().optional().describe('Report URL (e.g. .../reporter/video-report/<uuid>).'),
|
|
117
|
+
testId: z.number().int().optional().describe('Numeric test id โ unique only within a project; prefer uuid.'),
|
|
118
|
+
outputFormat: outputFormatParam,
|
|
119
|
+
}, async ({ uuid, reportUrl, testId, outputFormat }) => {
|
|
120
|
+
if ([uuid, reportUrl, testId].filter((v) => v != null && v !== '').length !== 1) {
|
|
121
|
+
return { content: [{ type: 'text', text: 'Provide exactly one of uuid, reportUrl or testId.' }], isError: true };
|
|
53
122
|
}
|
|
54
123
|
try {
|
|
55
|
-
const
|
|
56
|
-
|
|
124
|
+
const ref = parseReportRef(uuid ?? reportUrl ?? testId);
|
|
125
|
+
if (!ref)
|
|
126
|
+
return { content: [{ type: 'text', text: `Could not find a report UUID or test id in: ${uuid ?? reportUrl}.` }], isError: true };
|
|
127
|
+
const a = await getRootCauseAnalysis(ref);
|
|
128
|
+
const lines = [
|
|
129
|
+
`๐ Root Cause Analysis โ "${a.name}" (${a.testStatus}${a.framework ? `, ${a.framework}` : ''}${a.projectName ? `, project ${a.projectName}` : ''})`,
|
|
130
|
+
` Status: ${a.status}` +
|
|
131
|
+
(a.attemptCount != null ? ` ยท attempts used ${a.attemptCount}/${RCA_MAX_ATTEMPTS}` : '') +
|
|
132
|
+
(a.serviceEnabled === false ? ' ยท RCA disabled on this cloud' : ''),
|
|
133
|
+
];
|
|
134
|
+
if (a.hypothesis)
|
|
135
|
+
lines.push('', ` Hypothesis: ${a.hypothesis}`);
|
|
136
|
+
if (a.evidence.length) {
|
|
137
|
+
lines.push('', ' Evidence:');
|
|
138
|
+
for (const e of a.evidence) {
|
|
139
|
+
lines.push(` โข ${[e.source, e.time].filter(Boolean).join(' @ ')}`);
|
|
140
|
+
if (e.log)
|
|
141
|
+
lines.push(` log: ${e.log}`);
|
|
142
|
+
if (e.findings)
|
|
143
|
+
lines.push(` โ ${e.findings}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (!a.hypothesis && a.status !== 'completed') {
|
|
147
|
+
lines.push('', a.status === 'none'
|
|
148
|
+
? ' No analysis has been run for this report.'
|
|
149
|
+
: ` No result: the last analysis attempt ended "${a.status}".`);
|
|
150
|
+
}
|
|
151
|
+
const c = a.classification;
|
|
152
|
+
if (c.errorCategory || c.errorClassification || c.cause) {
|
|
153
|
+
lines.push('', ` Reporter classification: ${[c.errorCategory, c.errorClassification].filter(Boolean).join(' / ')}${c.cause ? ` โ ${c.cause}` : ''}`);
|
|
154
|
+
}
|
|
155
|
+
if (a.ineligibleReason)
|
|
156
|
+
lines.push('', ` โน๏ธ ${a.ineligibleReason}`);
|
|
157
|
+
return respond(outputFormat, a, lines.join('\n'));
|
|
57
158
|
}
|
|
58
159
|
catch (e) {
|
|
59
160
|
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
@@ -80,7 +181,7 @@ export function registerReportingTools(server) {
|
|
|
80
181
|
}
|
|
81
182
|
if (UUID_RE.test(reportApiId)) {
|
|
82
183
|
return {
|
|
83
|
-
content: [{ type: 'text', text: `Error: "${reportApiId}" is a test UUID, not a report_api_id.
|
|
184
|
+
content: [{ type: 'text', text: `Error: "${reportApiId}" is a test UUID, not a report_api_id. Use get_test_report(uuid: "${reportApiId}") instead. The report_api_id is a different identifier returned only when starting a manual or web-control session.` }],
|
|
84
185
|
isError: true,
|
|
85
186
|
};
|
|
86
187
|
}
|
|
@@ -133,6 +234,7 @@ export function registerReportingTools(server) {
|
|
|
133
234
|
'"user" (email, exact match โ for "my reports" use the email from get_my_account_info), ' +
|
|
134
235
|
'"has_attachment" ("Y"/"N"), ' +
|
|
135
236
|
'"success" (boolean true/false), ' +
|
|
237
|
+
'"accessibility_report" (JSON boolean true/false, NOT the string "true" โ that 400s; true = runs with an Axe accessibility scan), ' +
|
|
136
238
|
'"test_id" (number), ' +
|
|
137
239
|
'"project_id" (number), ' +
|
|
138
240
|
'"device.os" ("Android"/"iOS" โ case-sensitive), ' +
|
|
@@ -144,7 +246,7 @@ export function registerReportingTools(server) {
|
|
|
144
246
|
operator: z.string().describe('Comparison operator. Supported: "=" (equality), ">" ">=" "<" "<=" (numeric/date), "contains" (substring for name). ' +
|
|
145
247
|
'CSRF-blocked operators: "!=", "like", "startsWith", "in". ' +
|
|
146
248
|
'Note: "success" must use boolean value with "="; string "true" is CSRF-blocked.'),
|
|
147
|
-
value: z.union([z.string(), z.number(), z.boolean()]).describe('Filter value. Use boolean true/false for "success", numbers for numeric fields, strings for text fields.'),
|
|
249
|
+
value: z.union([z.string(), z.number(), z.boolean()]).describe('Filter value. Use boolean true/false for "success" and "accessibility_report", numbers for numeric fields, strings for text fields.'),
|
|
148
250
|
}))
|
|
149
251
|
.optional()
|
|
150
252
|
.describe('Server-side filters. Multiple filters are ANDed. ' +
|
|
@@ -285,6 +387,7 @@ export function registerReportingTools(server) {
|
|
|
285
387
|
'Use groupBy to specify which fields to group on โ e.g. ["device.os"] returns one row per OS. ' +
|
|
286
388
|
'Use pivotBy to add per-status columns (passedCount, failedCount, etc.) instead of separate rows. ' +
|
|
287
389
|
'Useful for dashboards: pass/fail by OS, by test name, by environment, etc. ' +
|
|
390
|
+
'Shared vs dedicated devices: groupBy ["device.pool.actual"] with pivotBy ["status"] (platform 26.7+; null = not recorded, e.g. browser tests or older runs). ' +
|
|
288
391
|
'Note: null OS values represent browser/Selenium sessions. ' +
|
|
289
392
|
'When groupBy includes "device.os", the MCP normalises case variants ("ANDROID"/"IOS") to ' +
|
|
290
393
|
'"Android"/"iOS" and merges their counts, so you always receive at most 3 rows: Android, iOS, null.', {
|
|
@@ -329,20 +432,25 @@ export function registerReportingTools(server) {
|
|
|
329
432
|
for (const row of result.data) {
|
|
330
433
|
const rawOs = row['device.os'];
|
|
331
434
|
const normOs = rawOs == null ? null : (OS_NORM[(String(rawOs)).toLowerCase()] ?? String(rawOs));
|
|
332
|
-
|
|
435
|
+
// Key on EVERY group-by field (OS normalised). Keying on the OS alone collapsed multi-field groupings โ
|
|
436
|
+
// ["device.os","status"] merged Passed and Failed into one row per OS.
|
|
437
|
+
const key = JSON.stringify(groupBy.map((f) => (f === 'device.os' ? normOs : row[f] ?? null)));
|
|
333
438
|
if (!merged[key]) {
|
|
334
439
|
merged[key] = { ...row, 'device.os': normOs };
|
|
335
440
|
}
|
|
336
441
|
else {
|
|
337
|
-
// Sum all numeric count fields
|
|
442
|
+
// Sum all numeric count fields (group-by fields are never summed)
|
|
338
443
|
for (const [k, v] of Object.entries(row)) {
|
|
339
|
-
if (typeof v === 'number' && k
|
|
444
|
+
if (typeof v === 'number' && !groupBy.includes(k)) {
|
|
340
445
|
merged[key][k] = (merged[key][k] ?? 0) + v;
|
|
341
446
|
}
|
|
342
447
|
}
|
|
343
448
|
}
|
|
344
449
|
}
|
|
345
|
-
|
|
450
|
+
const rows = Object.values(merged);
|
|
451
|
+
// `count` is the number of groups โ after merging it must describe the rows actually returned (UAT 2026-10-09:
|
|
452
|
+
// count 5 with 3 rows).
|
|
453
|
+
result = { ...result, data: rows, ...(result.count != null ? { count: rows.length } : {}) };
|
|
346
454
|
}
|
|
347
455
|
return respond(outputFormat, result, formatGroupedTestReports(result));
|
|
348
456
|
}
|
|
@@ -392,7 +500,7 @@ export function registerReportingTools(server) {
|
|
|
392
500
|
}
|
|
393
501
|
});
|
|
394
502
|
// โโโ delete_test_reports โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
395
|
-
server.tool('delete_test_reports', 'Permanently delete one or more test execution records by their numeric IDs. This cannot be undone. Requires confirmDeletion: true. Cloud Admin only
|
|
503
|
+
server.tool('delete_test_reports', 'Permanently delete one or more test execution records by their numeric IDs. This cannot be undone. Requires confirmDeletion: true. Cloud Admin can always delete; a project-level key only when its project\x27s allowUsersDeleteTests setting is on (otherwise the tool refuses up front and explains how to get it enabled). PREFERRED cleanup method whenever the IDs are already known (e.g. from a filtered list_test_reports call) โ more precise than name or date matching.', {
|
|
396
504
|
ids: z
|
|
397
505
|
.array(z.number().int())
|
|
398
506
|
.min(1)
|
|
@@ -455,7 +563,7 @@ export function registerReportingTools(server) {
|
|
|
455
563
|
}
|
|
456
564
|
});
|
|
457
565
|
// โโโ delete_test_reports_by_name โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
458
|
-
server.tool('delete_test_reports_by_name', 'Find and permanently delete test execution records matching a name. Accepts exact match (name) or substring match (nameContains). Searches across all pages. Show a preview first via confirmDeletion: false, then re-call with confirmDeletion: true to execute. If you already have the numeric IDs (e.g. from a filtered list_test_reports call), use delete_test_reports instead โ no name-matching ambiguity. Cloud Admin
|
|
566
|
+
server.tool('delete_test_reports_by_name', 'Find and permanently delete test execution records matching a name. Accepts exact match (name) or substring match (nameContains). Searches across all pages. Show a preview first via confirmDeletion: false, then re-call with confirmDeletion: true to execute. If you already have the numeric IDs (e.g. from a filtered list_test_reports call), use delete_test_reports instead โ no name-matching ambiguity. Cloud Admin can always delete; a project-level key only when its project\x27s allowUsersDeleteTests setting is on (otherwise the tool refuses up front and explains how to get it enabled). IMPORTANT: always pass projectName (exact project name from list_projects) when using Cloud Admin access โ without it the search spans the default reporter scope and tests from separate project reporter instances will not appear. The numeric projectId param is CSRF-blocked on reporter endpoints and is silently ignored.', {
|
|
459
567
|
name: z
|
|
460
568
|
.string()
|
|
461
569
|
.optional()
|
|
@@ -557,23 +665,78 @@ export function registerReportingTools(server) {
|
|
|
557
665
|
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
558
666
|
}
|
|
559
667
|
});
|
|
668
|
+
// โโโ download_test_video โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
669
|
+
server.tool('download_test_video', 'Download only the session video (.mp4) of a test execution โ no ZIP, no logs โ or just one byte range of it. ' +
|
|
670
|
+
'infoOnly: true returns the size without downloading. Byte ranges let you fetch a large recording in pieces, resume ' +
|
|
671
|
+
'a cut-off download, or grab the start/end of a long session. Use download_test_attachments when you also need the logs.' +
|
|
672
|
+
serverFsDownloadNotice(), {
|
|
673
|
+
report: z.string().describe('Report UUID (preferred โ numeric ids collide across projects), numeric test id, or the report URL (e.g. .../reporter/video-report/<uuid>).'),
|
|
674
|
+
localPath: z.string().optional().describe('Where to write the .mp4 (required unless infoOnly). ' + serverFsOutputParam()),
|
|
675
|
+
infoOnly: z.boolean().optional().describe('Return the video size and type without downloading it.'),
|
|
676
|
+
startByte: z.number().int().min(0).optional().describe('First byte of a partial download (0-based). With endByte for a fixed range; alone for "from here to the end" (e.g. resuming).'),
|
|
677
|
+
endByte: z.number().int().min(0).optional().describe('Last byte of a partial download, inclusive. Needs startByte.'),
|
|
678
|
+
lastBytes: z.number().int().min(1).optional().describe('Download only the final N bytes. Do not combine with startByte/endByte.'),
|
|
679
|
+
outputFormat: outputFormatParam,
|
|
680
|
+
}, async ({ report, localPath, infoOnly, startByte, endByte, lastBytes, outputFormat }) => {
|
|
681
|
+
const ref = parseReportRef(report);
|
|
682
|
+
if (!ref)
|
|
683
|
+
return { content: [{ type: 'text', text: `Error: "${report}" is not a report UUID, numeric test id or report URL.` }], isError: true };
|
|
684
|
+
const fail = (msg) => ({ content: [{ type: 'text', text: `Error: ${msg}` }], isError: true });
|
|
685
|
+
if (lastBytes != null && (startByte != null || endByte != null))
|
|
686
|
+
return fail('use either lastBytes or startByte/endByte, not both.');
|
|
687
|
+
if (endByte != null && startByte == null)
|
|
688
|
+
return fail('endByte needs startByte.');
|
|
689
|
+
if (startByte != null && endByte != null && endByte < startByte)
|
|
690
|
+
return fail('endByte must not be before startByte.');
|
|
691
|
+
const range = lastBytes != null ? `bytes=-${lastBytes}` : startByte != null ? `bytes=${startByte}-${endByte ?? ''}` : undefined;
|
|
692
|
+
const idNote = ref.kind === 'testId' ? ' Numeric ids are only unique per project โ prefer the UUID.' : '';
|
|
693
|
+
try {
|
|
694
|
+
if (infoOnly) {
|
|
695
|
+
const info = await getTestVideoInfo(ref);
|
|
696
|
+
const mb = info.totalBytes != null ? `${(info.totalBytes / (1024 * 1024)).toFixed(1)} MB` : 'unknown size';
|
|
697
|
+
return respond(outputFormat, { ...info, rangeRequests: true }, `๐ฌ Video: ${mb} (${info.totalBytes ?? '?'} bytes, ${info.contentType ?? 'unknown type'}). Byte ranges are supported.${idNote}`);
|
|
698
|
+
}
|
|
699
|
+
if (!localPath)
|
|
700
|
+
return fail('localPath is required unless infoOnly is true.');
|
|
701
|
+
const pathErr = validateOutputPath(localPath);
|
|
702
|
+
if (pathErr)
|
|
703
|
+
return fail(pathErr);
|
|
704
|
+
const r = await downloadTestVideo(ref, localPath, range);
|
|
705
|
+
const what = r.partial ? `bytes ${r.contentRange?.replace(/^bytes\s*/, '') ?? range}` : 'full video';
|
|
706
|
+
return respond(outputFormat, { ...r, localPath }, `โ
${what} (${r.bytesWritten} bytes${r.totalBytes != null ? ` of ${r.totalBytes}` : ''}) written to: ${localPath}` +
|
|
707
|
+
(r.partial ? '\nA partial file is a fragment, not a playable video on its own unless it starts at byte 0 and the player tolerates truncation.' : '') +
|
|
708
|
+
idNote);
|
|
709
|
+
}
|
|
710
|
+
catch (e) {
|
|
711
|
+
const msg = e.message;
|
|
712
|
+
if (/\[416\]/.test(msg))
|
|
713
|
+
return fail(`the requested range is outside the video. Call with infoOnly: true to get its size. (${msg})`);
|
|
714
|
+
return fail(msg);
|
|
715
|
+
}
|
|
716
|
+
});
|
|
560
717
|
// โโโ get_test_attachments_download_command โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
561
718
|
server.tool('get_test_attachments_download_command', 'Generates a ready-to-run curl or PowerShell command for downloading a test execution\'s full attachment ZIP (session video .mp4, Appium/device logs) directly to the user\'s local machine. ' +
|
|
562
719
|
commandGeneratorNotice('download_test_attachments', 'download') + ' ' +
|
|
563
720
|
'For text logs only, get_test_log is simpler (returns log text inline, no command). This is the path for the BINARY artifacts (video).\n\n' +
|
|
564
721
|
'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.', {
|
|
565
722
|
uuid: z.string().describe('Test execution UUID (uuid field from get_test_report or list_test_reports).'),
|
|
566
|
-
localPath: z.string().optional().
|
|
723
|
+
localPath: z.string().optional().describe('Path on the user\'s local machine to save the file. Default: "test-attachments.zip" (or "test-video.mp4" for artifact "video") in the current directory.'),
|
|
724
|
+
artifact: z
|
|
725
|
+
.enum(['zip', 'video'])
|
|
726
|
+
.optional()
|
|
727
|
+
.default('zip')
|
|
728
|
+
.describe('"zip" (default): the full attachment ZIP (video + logs). "video": only the session .mp4 โ smaller, no unzip.'),
|
|
567
729
|
localPlatform: z.enum(['windows', 'macos', 'linux']).describe('Platform of the machine that will run the command. ' + localPlatformParamNotice()),
|
|
568
730
|
outputFormat: outputFormatParam,
|
|
569
|
-
}, async ({ uuid, localPath, localPlatform, outputFormat }) => {
|
|
731
|
+
}, async ({ uuid, localPath, artifact, localPlatform, outputFormat }) => {
|
|
732
|
+
const video = artifact === 'video';
|
|
570
733
|
const result = buildDownloadCommand({
|
|
571
|
-
path: `/reporter/api/reports/${uuid}
|
|
572
|
-
localPath: localPath ?? 'test-attachments.zip',
|
|
734
|
+
path: `/reporter/api/reports/${uuid}/${video ? 'video' : 'attachments'}`,
|
|
735
|
+
localPath: localPath ?? (video ? 'test-video.mp4' : 'test-attachments.zip'),
|
|
573
736
|
localPlatform,
|
|
574
|
-
notes: ['The downloaded file is a ZIP โ unzip it to access the .mp4 video and the appium/device/ws logs.'],
|
|
737
|
+
notes: [video ? 'The downloaded file is the session video (.mp4).' : 'The downloaded file is a ZIP โ unzip it to access the .mp4 video and the appium/device/ws logs.'],
|
|
575
738
|
});
|
|
576
|
-
return respond(outputFormat,
|
|
739
|
+
return respond(outputFormat, commandPayload(result), result.humanText);
|
|
577
740
|
});
|
|
578
741
|
// โโโ get_test_log โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
579
742
|
server.tool('get_test_log', 'Retrieve log content from a test execution directly as text โ no file download required. ' +
|
|
@@ -636,12 +799,16 @@ export function registerReportingTools(server) {
|
|
|
636
799
|
}
|
|
637
800
|
});
|
|
638
801
|
// โโโ list_test_attachments โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
639
|
-
server.tool('list_test_attachments', 'Show attachment metadata (file names, types, sizes) for a test execution. Takes the
|
|
640
|
-
|
|
802
|
+
server.tool('list_test_attachments', 'Show attachment metadata (file names, types, sizes) for a test execution. Takes the uuid (preferred โ globally unique) or the numeric testId. Call this before download_test_attachments to confirm attachments exist โ download_test_attachments then takes the uuid shown in the output.', {
|
|
803
|
+
uuid: z.string().optional().describe('Test execution UUID (uuid field from list_test_reports). Preferred.'),
|
|
804
|
+
testId: z.number().int().optional().describe('Numeric test ID (test_id from list_test_reports). Unique only within a project โ prefer uuid.'),
|
|
641
805
|
outputFormat: outputFormatParam,
|
|
642
|
-
}, async ({ testId, outputFormat }) => {
|
|
806
|
+
}, async ({ uuid, testId, outputFormat }) => {
|
|
807
|
+
if ((uuid ? 1 : 0) + (testId != null ? 1 : 0) !== 1) {
|
|
808
|
+
return { content: [{ type: 'text', text: 'Provide exactly one of uuid or testId.' }], isError: true };
|
|
809
|
+
}
|
|
643
810
|
try {
|
|
644
|
-
const report = await getTestById(testId);
|
|
811
|
+
const report = uuid ? await getTestByUuid(uuid) : await getTestById(testId);
|
|
645
812
|
const structured = {
|
|
646
813
|
testId: report.test_id,
|
|
647
814
|
uuid: report.uuid,
|
|
@@ -678,7 +845,7 @@ export function registerReportingTools(server) {
|
|
|
678
845
|
}
|
|
679
846
|
});
|
|
680
847
|
// โโโ get_project_test_summary โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
681
|
-
server.tool('get_project_test_summary', 'Return a
|
|
848
|
+
server.tool('get_project_test_summary', 'Return a pass/fail summary for a project. Status counts cover all six reporter statuses (Passed, Failed, Error, Incomplete, Skipped, Healed) and are all-time totals โ the reporter API does not support date-range filtering for aggregate counts. Error = the test ended abnormally (crash, infrastructure, session ended early โ since platform 26.9 these are no longer Incomplete). Pass rate = (Passed+Healed)/(Passed+Healed+Failed+Error). Top failing and top erroring test names are filtered to the requested time window client-side from the most recent 200 of each.', {
|
|
682
849
|
startDate: z
|
|
683
850
|
.string()
|
|
684
851
|
.optional()
|
|
@@ -694,58 +861,70 @@ export function registerReportingTools(server) {
|
|
|
694
861
|
try {
|
|
695
862
|
const defaultStart = new Date(Date.now() - 48 * 60 * 60 * 1000).toISOString();
|
|
696
863
|
const resolvedStart = startDate ?? defaultStart;
|
|
697
|
-
//
|
|
698
|
-
//
|
|
699
|
-
//
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
864
|
+
// All six status counts in ONE call: grouped with pivotBy ["status"] and no groupBy returns a single row
|
|
865
|
+
// { passedCount, failedCount, errorCount, incompleteCount, skippedCount, healedCount, _count_ } (verified live
|
|
866
|
+
// 2026-10-09). The previous per-status listTests calls only asked for Passed/Failed/Incomplete, so Error,
|
|
867
|
+
// Skipped and Healed never reached the total โ and since 26.9 every crash/infrastructure abort is Error.
|
|
868
|
+
// Recent Failed and Error records are fetched alongside for the windowed top-N names.
|
|
869
|
+
const recent = (status) => listTestsSortedDesc({ limit: 200, page: 1, returnTotalCount: false, filter: [{ property: 'status', operator: '=', value: status }] }, projectId, projectName);
|
|
870
|
+
const [grouped, failedResult, errorResult, byPool] = await Promise.all([
|
|
871
|
+
getGroupedTests({ pivotBy: ['status'] }, projectId, projectName),
|
|
872
|
+
recent('Failed'),
|
|
873
|
+
recent('Error'),
|
|
874
|
+
// device.pool.actual (platform 26.7+): which pool each mobile automation test actually ran on. Shared-device
|
|
875
|
+
// flakiness is a common question; one grouped call answers it. Best-effort โ the summary stands without it.
|
|
876
|
+
getGroupedTests({ groupBy: ['device.pool.actual'], pivotBy: ['status'] }, projectId, projectName).catch(() => null),
|
|
704
877
|
]);
|
|
705
|
-
const
|
|
706
|
-
const
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
878
|
+
const counts = countsFromPivotRow(grouped?.data?.[0]);
|
|
879
|
+
const devicePools = (byPool?.data ?? [])
|
|
880
|
+
.filter((r) => r['device.pool.actual'] != null) // null = not recorded (non-mobile tests, or before 26.7)
|
|
881
|
+
.map((r) => { const c = countsFromPivotRow(r); return { pool: String(r['device.pool.actual']), total: c.total, failed: c.failed, error: c.error, passRate: passRate(c) }; })
|
|
882
|
+
.sort((a, b) => b.total - a.total);
|
|
883
|
+
// Apply the date window client-side on the most recent 200 of each
|
|
710
884
|
// (start_time filter via API key triggers CSRF โ filter locally instead).
|
|
711
885
|
const endTs = endDate ? new Date(endDate).getTime() : Date.now();
|
|
712
886
|
const startTs = new Date(resolvedStart).getTime();
|
|
713
|
-
const
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
const
|
|
887
|
+
const topNames = (records) => {
|
|
888
|
+
const nameCounts = {};
|
|
889
|
+
for (const r of records) {
|
|
890
|
+
const t = new Date(r.start_time).getTime();
|
|
891
|
+
if (t >= startTs && t <= endTs)
|
|
892
|
+
nameCounts[r.name] = (nameCounts[r.name] ?? 0) + 1;
|
|
893
|
+
}
|
|
894
|
+
return Object.entries(nameCounts)
|
|
895
|
+
.sort((a, b) => b[1] - a[1])
|
|
896
|
+
.slice(0, 5)
|
|
897
|
+
.map(([name, count]) => `${name} (${count}x)`);
|
|
898
|
+
};
|
|
899
|
+
const topFailures = topNames(failedResult.data ?? []);
|
|
900
|
+
const topErrors = topNames(errorResult.data ?? []);
|
|
726
901
|
const windowLabel = endDate
|
|
727
902
|
? `${resolvedStart} โ ${endDate}`
|
|
728
903
|
: startDate
|
|
729
904
|
? `${resolvedStart} โ now`
|
|
730
905
|
: `last 48 hours`;
|
|
731
|
-
const
|
|
906
|
+
const unknown = unknownStatusCount(counts);
|
|
732
907
|
const structured = {
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
passRate: parseFloat(passRate),
|
|
908
|
+
...counts,
|
|
909
|
+
...(unknown > 0 ? { otherStatus: unknown } : {}),
|
|
910
|
+
passRate: passRate(counts),
|
|
911
|
+
passRateBasis: PASS_RATE_BASIS,
|
|
738
912
|
topFailures,
|
|
913
|
+
topErrors,
|
|
739
914
|
window: windowLabel,
|
|
915
|
+
...(devicePools.length ? { byDevicePool: devicePools } : {}),
|
|
740
916
|
};
|
|
741
|
-
|
|
917
|
+
const poolLines = devicePools.length
|
|
918
|
+
? ['', ' By device pool (mobile automation, platform 26.7+):', ...devicePools.map((p) => ` ${p.pool.padEnd(10)} ${String(p.total).padStart(8)} tests ยท pass rate ${p.passRate == null ? 'n/a' : `${p.passRate}%`} ยท ${p.failed} failed ยท ${p.error} error`)]
|
|
919
|
+
: [];
|
|
920
|
+
return respond(outputFormat, structured, formatProjectTestSummary(counts, windowLabel, topFailures, topErrors) + poolLines.join('\n'));
|
|
742
921
|
}
|
|
743
922
|
catch (e) {
|
|
744
923
|
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
745
924
|
}
|
|
746
925
|
});
|
|
747
926
|
// โโโ delete_test_reports_before_date โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
748
|
-
server.tool('delete_test_reports_before_date', 'Permanently delete all test execution records started before a given date. Fetches matching IDs automatically then deletes them. Requires confirmDeletion: true. This cannot be undone. Cloud Admin only
|
|
927
|
+
server.tool('delete_test_reports_before_date', 'Permanently delete all test execution records started before a given date. Fetches matching IDs automatically then deletes them. Requires confirmDeletion: true. This cannot be undone. Cloud Admin can always delete; a project-level key only when its project\x27s allowUsersDeleteTests setting is on (otherwise the tool refuses up front and explains how to get it enabled).', {
|
|
749
928
|
beforeDate: z
|
|
750
929
|
.string()
|
|
751
930
|
.describe('ISO 8601 cutoff date. All tests with start_time before this date will be deleted, e.g. "2024-01-01T00:00:00Z".'),
|
|
@@ -804,10 +983,17 @@ export function registerReportingTools(server) {
|
|
|
804
983
|
.optional()
|
|
805
984
|
.default(50)
|
|
806
985
|
.describe('Maximum number of active executions to return (default: 50).'),
|
|
986
|
+
maxAgeHours: z
|
|
987
|
+
.number()
|
|
988
|
+
.min(1)
|
|
989
|
+
.max(168)
|
|
990
|
+
.optional()
|
|
991
|
+
.default(12)
|
|
992
|
+
.describe('Ignore Incomplete records that started longer ago than this โ they are abandoned or never-finalised runs, not running ones (default 12; test runs time out after 4 h by default).'),
|
|
807
993
|
projectId: z.number().int().optional().describe('Scope to this project ID.'),
|
|
808
994
|
projectName: z.string().optional().describe('Scope to this project name.'),
|
|
809
995
|
outputFormat: outputFormatParam,
|
|
810
|
-
}, async ({ limit, projectId, projectName, outputFormat }) => {
|
|
996
|
+
}, async ({ limit, maxAgeHours, projectId, projectName, outputFormat }) => {
|
|
811
997
|
try {
|
|
812
998
|
// Active executions are Incomplete records with null duration.
|
|
813
999
|
// We fetch more than needed since not all Incomplete records are still running.
|
|
@@ -817,11 +1003,22 @@ export function registerReportingTools(server) {
|
|
|
817
1003
|
returnTotalCount: false,
|
|
818
1004
|
filter: [{ property: 'status', operator: '=', value: 'Incomplete' }],
|
|
819
1005
|
}, projectId, projectName);
|
|
820
|
-
|
|
1006
|
+
// Incomplete + null duration also matches runs that were abandoned or never finalised โ the UAT (2026-10-09)
|
|
1007
|
+
// found every "active" execution was 3+ days old. Anything older than maxAgeHours is not running now.
|
|
1008
|
+
const ageCutoff = Date.now() - (maxAgeHours ?? 12) * 3600_000;
|
|
1009
|
+
const unfinished = (result.data ?? []).filter(r => r.duration === null);
|
|
1010
|
+
const recent = unfinished.filter(r => new Date(r.start_time).getTime() >= ageCutoff);
|
|
1011
|
+
const staleExcluded = unfinished.length - recent.length;
|
|
1012
|
+
const active = recent.slice(0, limit ?? 50);
|
|
1013
|
+
const staleNote = staleExcluded > 0
|
|
1014
|
+
? ` ${staleExcluded} older Incomplete record(s) were ignored as stale (started more than ${maxAgeHours ?? 12} h ago โ abandoned or never finalised).`
|
|
1015
|
+
: '';
|
|
821
1016
|
if (active.length === 0) {
|
|
822
|
-
return respond(outputFormat, { count: 0, executions: [] },
|
|
1017
|
+
return respond(outputFormat, { count: 0, executions: [], staleExcluded, maxAgeHours: maxAgeHours ?? 12 }, `No active test executions found.${staleNote}`);
|
|
823
1018
|
}
|
|
824
1019
|
const structured = {
|
|
1020
|
+
staleExcluded,
|
|
1021
|
+
maxAgeHours: maxAgeHours ?? 12,
|
|
825
1022
|
count: active.length,
|
|
826
1023
|
executions: active.map(r => ({
|
|
827
1024
|
testId: r.test_id,
|
|
@@ -839,7 +1036,7 @@ export function registerReportingTools(server) {
|
|
|
839
1036
|
const elapsedSec = Math.floor((elapsedMs % 60000) / 1000);
|
|
840
1037
|
lines.push(` โข ${r.name}`, ` Test ID: ${r.test_id} UUID: ${r.uuid}`, ` Started: ${r.start_time} Elapsed: ${elapsedMin}m ${elapsedSec}s`, ` Project: ${r.project_id}`, '');
|
|
841
1038
|
}
|
|
842
|
-
lines.push(
|
|
1039
|
+
lines.push(`Note: "active" is inferred from Incomplete status + null duration within the last ${maxAgeHours ?? 12} h. A test that finished very recently may appear here until the reporter updates.${staleNote}`);
|
|
843
1040
|
return respond(outputFormat, structured, lines.join('\n'));
|
|
844
1041
|
}
|
|
845
1042
|
catch (e) {
|
|
@@ -886,18 +1083,16 @@ export function registerReportingTools(server) {
|
|
|
886
1083
|
if (runs.length === 0) {
|
|
887
1084
|
return respond(outputFormat, { found: false }, `No executions found for test name containing "${testName}".`);
|
|
888
1085
|
}
|
|
889
|
-
|
|
890
|
-
const
|
|
891
|
-
const
|
|
892
|
-
const
|
|
893
|
-
|
|
894
|
-
const
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
return 'โ ๏ธ';
|
|
900
|
-
}).join(' ');
|
|
1086
|
+
// Classify by status, not `success` โ success is false for Healed (verified live), true only for Passed.
|
|
1087
|
+
const c = tallyStatuses(runs);
|
|
1088
|
+
const passed = c.passed + c.healed;
|
|
1089
|
+
const failed = c.failed;
|
|
1090
|
+
const error = c.error;
|
|
1091
|
+
const other = runs.length - passed - failed - error;
|
|
1092
|
+
const rate = passRate(c);
|
|
1093
|
+
// Sparkline: โ
= Passed/Healed, โ = Failed, ๐ฅ = Error, โ ๏ธ = other โ newest last
|
|
1094
|
+
const icon = (s) => (s === 'Error' ? '๐ฅ' : { pass: 'โ
', fail: 'โ', other: 'โ ๏ธ' }[statusOutcome(s)]);
|
|
1095
|
+
const spark = [...runs].reverse().map(r => icon(r.status)).join(' ');
|
|
901
1096
|
// Consecutive streak from the most recent run
|
|
902
1097
|
const latestStatus = runs[0].status;
|
|
903
1098
|
let streak = 0;
|
|
@@ -911,8 +1106,9 @@ export function registerReportingTools(server) {
|
|
|
911
1106
|
const structured = {
|
|
912
1107
|
testName: runs[0].name,
|
|
913
1108
|
runs: runs.length,
|
|
914
|
-
passed, failed, other,
|
|
915
|
-
passRate:
|
|
1109
|
+
passed, failed, error, other,
|
|
1110
|
+
passRate: rate,
|
|
1111
|
+
passRateBasis: PASS_RATE_BASIS,
|
|
916
1112
|
latestStatus: runs[0].status,
|
|
917
1113
|
latestRun: runs[0].start_time,
|
|
918
1114
|
streak,
|
|
@@ -925,8 +1121,8 @@ export function registerReportingTools(server) {
|
|
|
925
1121
|
};
|
|
926
1122
|
const lines = [
|
|
927
1123
|
`๐ Stability report: "${runs[0].name}"`,
|
|
928
|
-
` Runs examined: ${runs.length} | Pass rate: ${
|
|
929
|
-
` ${passed} passed ยท ${failed} failed ยท ${other} other`,
|
|
1124
|
+
` Runs examined: ${runs.length} | Pass rate: ${rate == null ? 'n/a' : `${rate}%`} | Latest: ${runs[0].status}${streakLabel}`,
|
|
1125
|
+
` ${passed} passed ยท ${failed} failed ยท ${error} error ยท ${other} other`,
|
|
930
1126
|
``,
|
|
931
1127
|
` Trend (oldest โ newest):`,
|
|
932
1128
|
` ${spark}`,
|
|
@@ -934,8 +1130,7 @@ export function registerReportingTools(server) {
|
|
|
934
1130
|
` Most recent ${Math.min(5, runs.length)} runs:`,
|
|
935
1131
|
...runs.slice(0, 5).map(r => {
|
|
936
1132
|
const dur = r.duration != null ? `${(r.duration / 1000).toFixed(1)}s` : 'n/a';
|
|
937
|
-
|
|
938
|
-
return ` ${icon} ${r.status} โ ${r.start_time} (${dur})`;
|
|
1133
|
+
return ` ${icon(r.status)} ${r.status} โ ${r.start_time} (${dur})`;
|
|
939
1134
|
}),
|
|
940
1135
|
];
|
|
941
1136
|
return respond(outputFormat, structured, lines.join('\n'));
|
|
@@ -966,11 +1161,10 @@ export function registerReportingTools(server) {
|
|
|
966
1161
|
const os = String(row['device.os'] ?? '');
|
|
967
1162
|
if (!name || (os !== 'Android' && os !== 'iOS'))
|
|
968
1163
|
continue;
|
|
969
|
-
const
|
|
970
|
-
const total = Number(row['_count_'] ?? (Number(row['passedCount'] ?? 0) + Number(row['failedCount'] ?? 0) + Number(row['incompleteCount'] ?? 0) + Number(row['errorCount'] ?? 0)));
|
|
1164
|
+
const c = countsFromPivotRow(row);
|
|
971
1165
|
if (!map[name])
|
|
972
1166
|
map[name] = {};
|
|
973
|
-
map[name][os] = {
|
|
1167
|
+
map[name][os] = { rate: passRate(c) ?? 0, total: c.total };
|
|
974
1168
|
}
|
|
975
1169
|
// Find divergent tests
|
|
976
1170
|
const divergent = Object.entries(map)
|
|
@@ -982,8 +1176,8 @@ export function registerReportingTools(server) {
|
|
|
982
1176
|
.map(([name, platforms]) => {
|
|
983
1177
|
const a = platforms.Android;
|
|
984
1178
|
const i = platforms.iOS;
|
|
985
|
-
const androidPct = a.
|
|
986
|
-
const iosPct = i.
|
|
1179
|
+
const androidPct = a.rate;
|
|
1180
|
+
const iosPct = i.rate;
|
|
987
1181
|
return {
|
|
988
1182
|
name,
|
|
989
1183
|
androidPassRate: parseFloat(androidPct.toFixed(1)),
|
|
@@ -1063,7 +1257,10 @@ export function registerReportingTools(server) {
|
|
|
1063
1257
|
continue;
|
|
1064
1258
|
}
|
|
1065
1259
|
records.push({ status: r.status, start_time: r.start_time });
|
|
1260
|
+
// The record cap ended the scan before the cutoff was reached: older days in the window were never read.
|
|
1261
|
+
// (UAT 2026-10-09: a 14-day trend stopped at 5,000 records on day 6 and reported scanCapped: false.)
|
|
1066
1262
|
if (records.length >= maxRecords) {
|
|
1263
|
+
scanCapped = true;
|
|
1067
1264
|
done = true;
|
|
1068
1265
|
break;
|
|
1069
1266
|
}
|
|
@@ -1093,50 +1290,53 @@ export function registerReportingTools(server) {
|
|
|
1093
1290
|
}
|
|
1094
1291
|
return d.toISOString().slice(0, 10);
|
|
1095
1292
|
};
|
|
1293
|
+
const grouped = {};
|
|
1294
|
+
for (const r of records)
|
|
1295
|
+
(grouped[bucketKey(r.start_time)] ??= []).push(r);
|
|
1296
|
+
// passed = Passed + Healed; Error (abnormal end โ crash/infrastructure, 26.9+) is its own column, not "other".
|
|
1096
1297
|
const buckets = {};
|
|
1097
|
-
for (const
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
buckets[key].total++;
|
|
1102
|
-
if (r.status === 'Passed')
|
|
1103
|
-
buckets[key].passed++;
|
|
1104
|
-
else if (r.status === 'Failed')
|
|
1105
|
-
buckets[key].failed++;
|
|
1106
|
-
else
|
|
1107
|
-
buckets[key].other++;
|
|
1298
|
+
for (const [key, rs] of Object.entries(grouped)) {
|
|
1299
|
+
const c = tallyStatuses(rs);
|
|
1300
|
+
const passed = c.passed + c.healed;
|
|
1301
|
+
buckets[key] = { total: c.total, passed, failed: c.failed, error: c.error, other: c.total - passed - c.failed - c.error, passRate: passRate(c) };
|
|
1108
1302
|
}
|
|
1109
1303
|
const sorted = Object.entries(buckets).sort(([a], [b]) => a.localeCompare(b));
|
|
1304
|
+
// Earliest record actually read โ when the scan was capped, days before this are missing, not empty.
|
|
1305
|
+
const coveredFrom = records.reduce((min, r) => (r.start_time < min ? r.start_time : min), records[0].start_time);
|
|
1110
1306
|
const structured = {
|
|
1111
1307
|
bucketBy,
|
|
1112
1308
|
lookbackDays,
|
|
1113
1309
|
recordsScanned: records.length,
|
|
1114
1310
|
cappedAt: records.length >= maxRecords ? maxRecords : null,
|
|
1115
|
-
// true
|
|
1311
|
+
// true whenever maxRecords ended the scan before the lookback window was fully covered
|
|
1116
1312
|
scanCapped,
|
|
1313
|
+
windowComplete: !scanCapped,
|
|
1314
|
+
coveredFrom: scanCapped ? coveredFrom : new Date(cutoffTs).toISOString(),
|
|
1117
1315
|
buckets: sorted.map(([date, b]) => ({
|
|
1118
1316
|
date,
|
|
1119
1317
|
total: b.total,
|
|
1120
1318
|
passed: b.passed,
|
|
1121
1319
|
failed: b.failed,
|
|
1320
|
+
error: b.error,
|
|
1122
1321
|
other: b.other,
|
|
1123
|
-
passRate: b.
|
|
1322
|
+
passRate: b.passRate,
|
|
1124
1323
|
})),
|
|
1324
|
+
passRateBasis: PASS_RATE_BASIS,
|
|
1125
1325
|
};
|
|
1126
1326
|
const lines = [
|
|
1127
1327
|
`๐
Test execution trend (${bucketBy === 'week' ? 'weekly' : 'daily'}, last ${lookbackDays} days โ ${records.length} records scanned)\n`,
|
|
1128
|
-
` ${'Date'.padEnd(12)} ${'Total'.padStart(6)} ${'Passed'.padStart(7)} ${'Failed'.padStart(7)} ${'Pass%'.padStart(7)}`,
|
|
1129
|
-
` ${'โ'.repeat(
|
|
1328
|
+
` ${'Date'.padEnd(12)} ${'Total'.padStart(6)} ${'Passed'.padStart(7)} ${'Failed'.padStart(7)} ${'Error'.padStart(7)} ${'Pass%'.padStart(7)}`,
|
|
1329
|
+
` ${'โ'.repeat(52)}`,
|
|
1130
1330
|
...sorted.map(([date, b]) => {
|
|
1131
|
-
const pct = b.
|
|
1132
|
-
return ` ${date.padEnd(12)} ${String(b.total).padStart(6)} ${String(b.passed).padStart(7)} ${String(b.failed).padStart(7)} ${pct.padStart(7)}`;
|
|
1331
|
+
const pct = b.passRate == null ? 'โ' : b.passRate.toFixed(1);
|
|
1332
|
+
return ` ${date.padEnd(12)} ${String(b.total).padStart(6)} ${String(b.passed).padStart(7)} ${String(b.failed).padStart(7)} ${String(b.error).padStart(7)} ${pct.padStart(7)}`;
|
|
1133
1333
|
}),
|
|
1334
|
+
`\n Passed includes Healed. Pass% = (Passed+Healed)/(Passed+Healed+Failed+Error).`,
|
|
1134
1335
|
];
|
|
1135
|
-
if (
|
|
1136
|
-
lines.push(`\n โ ๏ธ
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
lines.push(`\n โ ๏ธ Incomplete: the platform refused server-side sort for this credential, so records were scanned unsorted and the scan stopped at maxRecords (${maxRecords}) before the full ${lookbackDays}-day window was covered. Increase maxRecords for a complete picture.`);
|
|
1336
|
+
if (scanCapped) {
|
|
1337
|
+
lines.push(`\n โ ๏ธ INCOMPLETE WINDOW: the scan stopped at maxRecords (${maxRecords}) and only covers ${coveredFrom.slice(0, 10)} onward โ ` +
|
|
1338
|
+
`days before that are MISSING from this trend, not days with zero executions. ` +
|
|
1339
|
+
`Increase maxRecords (max 25,000) or reduce lookbackDays for the full ${lookbackDays}-day window.`);
|
|
1140
1340
|
}
|
|
1141
1341
|
return respond(outputFormat, structured, lines.join('\n'));
|
|
1142
1342
|
}
|