@gaffer-sh/mcp 0.4.2 → 0.6.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/LICENSE +21 -0
- package/README.md +86 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1618 -1193
- package/dist/index.js.map +1 -0
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,518 +1,519 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/index.ts
|
|
2
|
+
import { createRequire } from "node:module";
|
|
4
3
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
4
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
//#region src/api-client.ts
|
|
8
|
+
const pkg = createRequire(import.meta.url)("../package.json");
|
|
9
|
+
const REQUEST_TIMEOUT_MS = 3e4;
|
|
10
|
+
const MAX_RETRIES = 3;
|
|
11
|
+
const INITIAL_RETRY_DELAY_MS = 1e3;
|
|
12
|
+
const RETRYABLE_STATUS_CODES = [
|
|
13
|
+
401,
|
|
14
|
+
429,
|
|
15
|
+
500,
|
|
16
|
+
502,
|
|
17
|
+
503,
|
|
18
|
+
504
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* Sleep for a given number of milliseconds
|
|
22
|
+
*/
|
|
12
23
|
function sleep(ms) {
|
|
13
|
-
|
|
24
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
14
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Detect token type from prefix
|
|
28
|
+
* - gaf_ = user API Key (read-only, cross-project)
|
|
29
|
+
* - gfr_ = Project Upload Token (legacy, single project)
|
|
30
|
+
*/
|
|
15
31
|
function detectTokenType(token) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
return "project";
|
|
32
|
+
if (token.startsWith("gaf_")) return "user";
|
|
33
|
+
return "project";
|
|
20
34
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
* Get a browser-navigable URL for viewing a test report
|
|
426
|
-
*
|
|
427
|
-
* @param options - Query options
|
|
428
|
-
* @param options.projectId - The project ID (required)
|
|
429
|
-
* @param options.testRunId - The test run ID (required)
|
|
430
|
-
* @param options.filename - Specific file to open (default: index.html)
|
|
431
|
-
* @returns URL with signed token for browser access
|
|
432
|
-
*/
|
|
433
|
-
async getReportBrowserUrl(options) {
|
|
434
|
-
if (!this.isUserToken()) {
|
|
435
|
-
throw new Error("getReportBrowserUrl requires a user API Key (gaf_).");
|
|
436
|
-
}
|
|
437
|
-
if (!options.projectId) {
|
|
438
|
-
throw new Error("projectId is required");
|
|
439
|
-
}
|
|
440
|
-
if (!options.testRunId) {
|
|
441
|
-
throw new Error("testRunId is required");
|
|
442
|
-
}
|
|
443
|
-
return this.request(
|
|
444
|
-
`/user/projects/${options.projectId}/reports/${options.testRunId}/browser-url`,
|
|
445
|
-
{
|
|
446
|
-
...options.filename && { filename: options.filename }
|
|
447
|
-
}
|
|
448
|
-
);
|
|
449
|
-
}
|
|
35
|
+
/**
|
|
36
|
+
* Gaffer API v1 client for MCP server
|
|
37
|
+
*
|
|
38
|
+
* Supports two authentication modes:
|
|
39
|
+
* 1. User API Keys (gaf_) - Read-only access to all user's projects
|
|
40
|
+
* 2. Project Upload Tokens (gfr_) - Legacy, single project access
|
|
41
|
+
*/
|
|
42
|
+
var GafferApiClient = class GafferApiClient {
|
|
43
|
+
apiKey;
|
|
44
|
+
baseUrl;
|
|
45
|
+
tokenType;
|
|
46
|
+
constructor(config) {
|
|
47
|
+
this.apiKey = config.apiKey;
|
|
48
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
49
|
+
this.tokenType = detectTokenType(config.apiKey);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create client from environment variables
|
|
53
|
+
*
|
|
54
|
+
* Supports:
|
|
55
|
+
* - GAFFER_API_KEY (for user API Keys gaf_)
|
|
56
|
+
*/
|
|
57
|
+
static fromEnv() {
|
|
58
|
+
const apiKey = process.env.GAFFER_API_KEY;
|
|
59
|
+
if (!apiKey) throw new Error("GAFFER_API_KEY environment variable is required");
|
|
60
|
+
return new GafferApiClient({
|
|
61
|
+
apiKey,
|
|
62
|
+
baseUrl: process.env.GAFFER_API_URL || "https://app.gaffer.sh"
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Check if using a user API Key (enables cross-project features)
|
|
67
|
+
*/
|
|
68
|
+
isUserToken() {
|
|
69
|
+
return this.tokenType === "user";
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Make authenticated request to Gaffer API with retry logic
|
|
73
|
+
*/
|
|
74
|
+
async request(endpoint, params) {
|
|
75
|
+
const url = new URL(`/api/v1${endpoint}`, this.baseUrl);
|
|
76
|
+
if (params) {
|
|
77
|
+
for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== null) url.searchParams.set(key, String(value));
|
|
78
|
+
}
|
|
79
|
+
let lastError = null;
|
|
80
|
+
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
81
|
+
const controller = new AbortController();
|
|
82
|
+
const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
83
|
+
try {
|
|
84
|
+
const response = await fetch(url.toString(), {
|
|
85
|
+
method: "GET",
|
|
86
|
+
headers: {
|
|
87
|
+
"X-API-Key": this.apiKey,
|
|
88
|
+
"Accept": "application/json",
|
|
89
|
+
"User-Agent": `gaffer-mcp/${pkg.version}`
|
|
90
|
+
},
|
|
91
|
+
signal: controller.signal
|
|
92
|
+
});
|
|
93
|
+
if (!response.ok) {
|
|
94
|
+
const errorData = await response.json().catch(() => ({}));
|
|
95
|
+
if (RETRYABLE_STATUS_CODES.includes(response.status) && attempt < MAX_RETRIES) {
|
|
96
|
+
let delayMs = INITIAL_RETRY_DELAY_MS * 2 ** attempt;
|
|
97
|
+
if (response.status === 429) {
|
|
98
|
+
const retryAfter = response.headers.get("Retry-After");
|
|
99
|
+
if (retryAfter) delayMs = Math.max(delayMs, Number.parseInt(retryAfter, 10) * 1e3);
|
|
100
|
+
}
|
|
101
|
+
lastError = new Error(errorData.error?.message || `API request failed: ${response.status}`);
|
|
102
|
+
await sleep(delayMs);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const errorMessage = errorData.error?.message || `API request failed: ${response.status}`;
|
|
106
|
+
throw new Error(errorMessage);
|
|
107
|
+
}
|
|
108
|
+
return response.json();
|
|
109
|
+
} catch (error) {
|
|
110
|
+
clearTimeout(timeoutId);
|
|
111
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
112
|
+
lastError = /* @__PURE__ */ new Error(`Request timed out after ${REQUEST_TIMEOUT_MS}ms`);
|
|
113
|
+
if (attempt < MAX_RETRIES) {
|
|
114
|
+
await sleep(INITIAL_RETRY_DELAY_MS * 2 ** attempt);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
throw lastError;
|
|
118
|
+
}
|
|
119
|
+
if (error instanceof TypeError && attempt < MAX_RETRIES) {
|
|
120
|
+
lastError = error;
|
|
121
|
+
await sleep(INITIAL_RETRY_DELAY_MS * 2 ** attempt);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
throw error;
|
|
125
|
+
} finally {
|
|
126
|
+
clearTimeout(timeoutId);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
throw lastError || /* @__PURE__ */ new Error("Request failed after retries");
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* List all projects the user has access to
|
|
133
|
+
* Requires user API Key (gaf_)
|
|
134
|
+
*
|
|
135
|
+
* @param options - Query options
|
|
136
|
+
* @param options.organizationId - Filter by organization ID
|
|
137
|
+
* @param options.limit - Maximum number of results
|
|
138
|
+
* @param options.offset - Offset for pagination
|
|
139
|
+
*/
|
|
140
|
+
async listProjects(options = {}) {
|
|
141
|
+
if (!this.isUserToken()) throw new Error("listProjects requires a user API Key (gaf_). Upload Tokens (gfr_) can only access a single project.");
|
|
142
|
+
return this.request("/user/projects", {
|
|
143
|
+
...options.organizationId && { organizationId: options.organizationId },
|
|
144
|
+
...options.limit && { limit: options.limit },
|
|
145
|
+
...options.offset && { offset: options.offset }
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get project health analytics
|
|
150
|
+
*
|
|
151
|
+
* @param options - Query options
|
|
152
|
+
* @param options.projectId - Required for user tokens, ignored for project tokens
|
|
153
|
+
* @param options.days - Analysis period in days (default: 30)
|
|
154
|
+
*/
|
|
155
|
+
async getProjectHealth(options = {}) {
|
|
156
|
+
if (this.isUserToken()) {
|
|
157
|
+
if (!options.projectId) throw new Error("projectId is required when using a user API Key");
|
|
158
|
+
return this.request(`/user/projects/${options.projectId}/health`, { days: options.days || 30 });
|
|
159
|
+
}
|
|
160
|
+
return this.request("/project/analytics", { days: options.days || 30 });
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Get test history for a specific test
|
|
164
|
+
*
|
|
165
|
+
* @param options - Query options
|
|
166
|
+
* @param options.projectId - Required for user tokens, ignored for project tokens
|
|
167
|
+
* @param options.testName - Test name to search for
|
|
168
|
+
* @param options.filePath - File path to search for
|
|
169
|
+
* @param options.limit - Maximum number of results
|
|
170
|
+
*/
|
|
171
|
+
async getTestHistory(options) {
|
|
172
|
+
const testName = options.testName?.trim();
|
|
173
|
+
const filePath = options.filePath?.trim();
|
|
174
|
+
if (!testName && !filePath) throw new Error("Either testName or filePath is required (and must not be empty)");
|
|
175
|
+
if (this.isUserToken()) {
|
|
176
|
+
if (!options.projectId) throw new Error("projectId is required when using a user API Key");
|
|
177
|
+
return this.request(`/user/projects/${options.projectId}/test-history`, {
|
|
178
|
+
...testName && { testName },
|
|
179
|
+
...filePath && { filePath },
|
|
180
|
+
...options.limit && { limit: options.limit }
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
return this.request("/project/test-history", {
|
|
184
|
+
...testName && { testName },
|
|
185
|
+
...filePath && { filePath },
|
|
186
|
+
...options.limit && { limit: options.limit }
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Get flaky tests for the project
|
|
191
|
+
*
|
|
192
|
+
* @param options - Query options
|
|
193
|
+
* @param options.projectId - Required for user tokens, ignored for project tokens
|
|
194
|
+
* @param options.threshold - Minimum flip rate to be considered flaky (0-1)
|
|
195
|
+
* @param options.limit - Maximum number of results
|
|
196
|
+
* @param options.days - Analysis period in days
|
|
197
|
+
*/
|
|
198
|
+
async getFlakyTests(options = {}) {
|
|
199
|
+
if (this.isUserToken()) {
|
|
200
|
+
if (!options.projectId) throw new Error("projectId is required when using a user API Key");
|
|
201
|
+
return this.request(`/user/projects/${options.projectId}/flaky-tests`, {
|
|
202
|
+
...options.threshold && { threshold: options.threshold },
|
|
203
|
+
...options.limit && { limit: options.limit },
|
|
204
|
+
...options.days && { days: options.days }
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return this.request("/project/flaky-tests", {
|
|
208
|
+
...options.threshold && { threshold: options.threshold },
|
|
209
|
+
...options.limit && { limit: options.limit },
|
|
210
|
+
...options.days && { days: options.days }
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* List test runs for the project
|
|
215
|
+
*
|
|
216
|
+
* @param options - Query options
|
|
217
|
+
* @param options.projectId - Required for user tokens, ignored for project tokens
|
|
218
|
+
* @param options.commitSha - Filter by commit SHA
|
|
219
|
+
* @param options.branch - Filter by branch name
|
|
220
|
+
* @param options.status - Filter by status ('passed' or 'failed')
|
|
221
|
+
* @param options.limit - Maximum number of results
|
|
222
|
+
*/
|
|
223
|
+
async getTestRuns(options = {}) {
|
|
224
|
+
if (this.isUserToken()) {
|
|
225
|
+
if (!options.projectId) throw new Error("projectId is required when using a user API Key");
|
|
226
|
+
return this.request(`/user/projects/${options.projectId}/test-runs`, {
|
|
227
|
+
...options.commitSha && { commitSha: options.commitSha },
|
|
228
|
+
...options.branch && { branch: options.branch },
|
|
229
|
+
...options.status && { status: options.status },
|
|
230
|
+
...options.limit && { limit: options.limit }
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return this.request("/project/test-runs", {
|
|
234
|
+
...options.commitSha && { commitSha: options.commitSha },
|
|
235
|
+
...options.branch && { branch: options.branch },
|
|
236
|
+
...options.status && { status: options.status },
|
|
237
|
+
...options.limit && { limit: options.limit }
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Get report files for a test run
|
|
242
|
+
*
|
|
243
|
+
* @param testRunId - The test run ID
|
|
244
|
+
* @returns Report metadata with download URLs for each file
|
|
245
|
+
*/
|
|
246
|
+
async getReport(testRunId) {
|
|
247
|
+
if (!this.isUserToken()) throw new Error("getReport requires a user API Key (gaf_). Upload Tokens (gfr_) cannot access reports via API.");
|
|
248
|
+
if (!testRunId) throw new Error("testRunId is required");
|
|
249
|
+
return this.request(`/user/test-runs/${testRunId}/report`);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Get slowest tests for a project
|
|
253
|
+
*
|
|
254
|
+
* @param options - Query options
|
|
255
|
+
* @param options.projectId - The project ID (required)
|
|
256
|
+
* @param options.days - Analysis period in days (default: 30)
|
|
257
|
+
* @param options.limit - Maximum number of results (default: 20)
|
|
258
|
+
* @param options.framework - Filter by test framework
|
|
259
|
+
* @param options.branch - Filter by git branch name
|
|
260
|
+
* @returns Slowest tests sorted by P95 duration
|
|
261
|
+
*/
|
|
262
|
+
async getSlowestTests(options) {
|
|
263
|
+
if (!this.isUserToken()) throw new Error("getSlowestTests requires a user API Key (gaf_).");
|
|
264
|
+
if (!options.projectId) throw new Error("projectId is required");
|
|
265
|
+
return this.request(`/user/projects/${options.projectId}/slowest-tests`, {
|
|
266
|
+
...options.days && { days: options.days },
|
|
267
|
+
...options.limit && { limit: options.limit },
|
|
268
|
+
...options.framework && { framework: options.framework },
|
|
269
|
+
...options.branch && { branch: options.branch }
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Get parsed test results for a specific test run
|
|
274
|
+
*
|
|
275
|
+
* @param options - Query options
|
|
276
|
+
* @param options.projectId - The project ID (required)
|
|
277
|
+
* @param options.testRunId - The test run ID (required)
|
|
278
|
+
* @param options.status - Filter by test status ('passed', 'failed', 'skipped')
|
|
279
|
+
* @param options.limit - Maximum number of results (default: 100)
|
|
280
|
+
* @param options.offset - Pagination offset (default: 0)
|
|
281
|
+
* @returns Parsed test cases with pagination
|
|
282
|
+
*/
|
|
283
|
+
async getTestRunDetails(options) {
|
|
284
|
+
if (!this.isUserToken()) throw new Error("getTestRunDetails requires a user API Key (gaf_).");
|
|
285
|
+
if (!options.projectId) throw new Error("projectId is required");
|
|
286
|
+
if (!options.testRunId) throw new Error("testRunId is required");
|
|
287
|
+
return this.request(`/user/projects/${options.projectId}/test-runs/${options.testRunId}/details`, {
|
|
288
|
+
...options.status && { status: options.status },
|
|
289
|
+
...options.limit && { limit: options.limit },
|
|
290
|
+
...options.offset && { offset: options.offset }
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Compare test metrics between two commits or test runs
|
|
295
|
+
*
|
|
296
|
+
* @param options - Query options
|
|
297
|
+
* @param options.projectId - The project ID (required)
|
|
298
|
+
* @param options.testName - The test name to compare (required)
|
|
299
|
+
* @param options.beforeCommit - Commit SHA for before (use with afterCommit)
|
|
300
|
+
* @param options.afterCommit - Commit SHA for after (use with beforeCommit)
|
|
301
|
+
* @param options.beforeRunId - Test run ID for before (use with afterRunId)
|
|
302
|
+
* @param options.afterRunId - Test run ID for after (use with beforeRunId)
|
|
303
|
+
* @returns Comparison of test metrics
|
|
304
|
+
*/
|
|
305
|
+
async compareTestMetrics(options) {
|
|
306
|
+
if (!this.isUserToken()) throw new Error("compareTestMetrics requires a user API Key (gaf_).");
|
|
307
|
+
if (!options.projectId) throw new Error("projectId is required");
|
|
308
|
+
if (!options.testName) throw new Error("testName is required");
|
|
309
|
+
return this.request(`/user/projects/${options.projectId}/compare-test`, {
|
|
310
|
+
testName: options.testName,
|
|
311
|
+
...options.beforeCommit && { beforeCommit: options.beforeCommit },
|
|
312
|
+
...options.afterCommit && { afterCommit: options.afterCommit },
|
|
313
|
+
...options.beforeRunId && { beforeRunId: options.beforeRunId },
|
|
314
|
+
...options.afterRunId && { afterRunId: options.afterRunId }
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Get coverage summary for a project
|
|
319
|
+
*
|
|
320
|
+
* @param options - Query options
|
|
321
|
+
* @param options.projectId - The project ID (required)
|
|
322
|
+
* @param options.days - Analysis period in days (default: 30)
|
|
323
|
+
* @returns Coverage summary with trends and lowest coverage files
|
|
324
|
+
*/
|
|
325
|
+
async getCoverageSummary(options) {
|
|
326
|
+
if (!this.isUserToken()) throw new Error("getCoverageSummary requires a user API Key (gaf_).");
|
|
327
|
+
if (!options.projectId) throw new Error("projectId is required");
|
|
328
|
+
return this.request(`/user/projects/${options.projectId}/coverage-summary`, { ...options.days && { days: options.days } });
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Get coverage files for a project with filtering
|
|
332
|
+
*
|
|
333
|
+
* @param options - Query options
|
|
334
|
+
* @param options.projectId - The project ID (required)
|
|
335
|
+
* @param options.filePath - Filter to specific file path
|
|
336
|
+
* @param options.minCoverage - Minimum coverage percentage
|
|
337
|
+
* @param options.maxCoverage - Maximum coverage percentage
|
|
338
|
+
* @param options.limit - Maximum number of results
|
|
339
|
+
* @param options.offset - Pagination offset
|
|
340
|
+
* @param options.sortBy - Sort by 'path' or 'coverage'
|
|
341
|
+
* @param options.sortOrder - Sort order 'asc' or 'desc'
|
|
342
|
+
* @returns List of files with coverage data
|
|
343
|
+
*/
|
|
344
|
+
async getCoverageFiles(options) {
|
|
345
|
+
if (!this.isUserToken()) throw new Error("getCoverageFiles requires a user API Key (gaf_).");
|
|
346
|
+
if (!options.projectId) throw new Error("projectId is required");
|
|
347
|
+
return this.request(`/user/projects/${options.projectId}/coverage/files`, {
|
|
348
|
+
...options.filePath && { filePath: options.filePath },
|
|
349
|
+
...options.minCoverage !== void 0 && { minCoverage: options.minCoverage },
|
|
350
|
+
...options.maxCoverage !== void 0 && { maxCoverage: options.maxCoverage },
|
|
351
|
+
...options.limit && { limit: options.limit },
|
|
352
|
+
...options.offset && { offset: options.offset },
|
|
353
|
+
...options.sortBy && { sortBy: options.sortBy },
|
|
354
|
+
...options.sortOrder && { sortOrder: options.sortOrder }
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Get risk areas (files with low coverage AND test failures)
|
|
359
|
+
*
|
|
360
|
+
* @param options - Query options
|
|
361
|
+
* @param options.projectId - The project ID (required)
|
|
362
|
+
* @param options.days - Analysis period in days (default: 30)
|
|
363
|
+
* @param options.coverageThreshold - Include files below this coverage (default: 80)
|
|
364
|
+
* @returns List of risk areas sorted by risk score
|
|
365
|
+
*/
|
|
366
|
+
async getCoverageRiskAreas(options) {
|
|
367
|
+
if (!this.isUserToken()) throw new Error("getCoverageRiskAreas requires a user API Key (gaf_).");
|
|
368
|
+
if (!options.projectId) throw new Error("projectId is required");
|
|
369
|
+
return this.request(`/user/projects/${options.projectId}/coverage/risk-areas`, {
|
|
370
|
+
...options.days && { days: options.days },
|
|
371
|
+
...options.coverageThreshold !== void 0 && { coverageThreshold: options.coverageThreshold }
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Get a browser-navigable URL for viewing a test report
|
|
376
|
+
*
|
|
377
|
+
* @param options - Query options
|
|
378
|
+
* @param options.projectId - The project ID (required)
|
|
379
|
+
* @param options.testRunId - The test run ID (required)
|
|
380
|
+
* @param options.filename - Specific file to open (default: index.html)
|
|
381
|
+
* @returns URL with signed token for browser access
|
|
382
|
+
*/
|
|
383
|
+
async getReportBrowserUrl(options) {
|
|
384
|
+
if (!this.isUserToken()) throw new Error("getReportBrowserUrl requires a user API Key (gaf_).");
|
|
385
|
+
if (!options.projectId) throw new Error("projectId is required");
|
|
386
|
+
if (!options.testRunId) throw new Error("testRunId is required");
|
|
387
|
+
return this.request(`/user/projects/${options.projectId}/reports/${options.testRunId}/browser-url`, { ...options.filename && { filename: options.filename } });
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Get failure clusters for a test run
|
|
391
|
+
*
|
|
392
|
+
* @param options - Query options
|
|
393
|
+
* @param options.projectId - The project ID (required)
|
|
394
|
+
* @param options.testRunId - The test run ID (required)
|
|
395
|
+
* @returns Failure clusters grouped by error similarity
|
|
396
|
+
*/
|
|
397
|
+
async getFailureClusters(options) {
|
|
398
|
+
if (!this.isUserToken()) throw new Error("getFailureClusters requires a user API Key (gaf_).");
|
|
399
|
+
if (!options.projectId) throw new Error("projectId is required");
|
|
400
|
+
if (!options.testRunId) throw new Error("testRunId is required");
|
|
401
|
+
return this.request(`/user/projects/${options.projectId}/test-runs/${options.testRunId}/failure-clusters`);
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* List upload sessions for a project
|
|
405
|
+
*
|
|
406
|
+
* @param options - Query options
|
|
407
|
+
* @param options.projectId - The project ID (required)
|
|
408
|
+
* @param options.commitSha - Filter by commit SHA
|
|
409
|
+
* @param options.branch - Filter by branch name
|
|
410
|
+
* @param options.limit - Maximum number of results (default: 10)
|
|
411
|
+
* @param options.offset - Pagination offset (default: 0)
|
|
412
|
+
* @returns Paginated list of upload sessions
|
|
413
|
+
*/
|
|
414
|
+
async listUploadSessions(options) {
|
|
415
|
+
if (!this.isUserToken()) throw new Error("listUploadSessions requires a user API Key (gaf_).");
|
|
416
|
+
if (!options.projectId) throw new Error("projectId is required");
|
|
417
|
+
return this.request(`/user/projects/${options.projectId}/upload-sessions`, {
|
|
418
|
+
...options.commitSha && { commitSha: options.commitSha },
|
|
419
|
+
...options.branch && { branch: options.branch },
|
|
420
|
+
...options.limit && { limit: options.limit },
|
|
421
|
+
...options.offset && { offset: options.offset }
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Get upload session detail with linked results
|
|
426
|
+
*
|
|
427
|
+
* @param options - Query options
|
|
428
|
+
* @param options.projectId - The project ID (required)
|
|
429
|
+
* @param options.sessionId - The upload session ID (required)
|
|
430
|
+
* @returns Upload session details with linked test runs and coverage reports
|
|
431
|
+
*/
|
|
432
|
+
async getUploadSessionDetail(options) {
|
|
433
|
+
if (!this.isUserToken()) throw new Error("getUploadSessionDetail requires a user API Key (gaf_).");
|
|
434
|
+
if (!options.projectId) throw new Error("projectId is required");
|
|
435
|
+
if (!options.sessionId) throw new Error("sessionId is required");
|
|
436
|
+
return this.request(`/user/projects/${options.projectId}/upload-sessions/${options.sessionId}`);
|
|
437
|
+
}
|
|
450
438
|
};
|
|
451
439
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
440
|
+
//#endregion
|
|
441
|
+
//#region src/tools/compare-test-metrics.ts
|
|
442
|
+
/**
|
|
443
|
+
* Input schema for compare_test_metrics tool
|
|
444
|
+
*/
|
|
445
|
+
const compareTestMetricsInputSchema = {
|
|
446
|
+
projectId: z.string().describe("Project ID. Required when using a user API Key (gaf_). Use list_projects to find project IDs."),
|
|
447
|
+
testName: z.string().describe("The test name to compare. Can be the short name or full name including describe blocks."),
|
|
448
|
+
beforeCommit: z.string().optional().describe("Commit SHA for the \"before\" measurement. Use with afterCommit."),
|
|
449
|
+
afterCommit: z.string().optional().describe("Commit SHA for the \"after\" measurement. Use with beforeCommit."),
|
|
450
|
+
beforeRunId: z.string().optional().describe("Test run ID for the \"before\" measurement. Use with afterRunId."),
|
|
451
|
+
afterRunId: z.string().optional().describe("Test run ID for the \"after\" measurement. Use with beforeRunId.")
|
|
461
452
|
};
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
453
|
+
/**
|
|
454
|
+
* Output schema for compare_test_metrics tool
|
|
455
|
+
*/
|
|
456
|
+
const compareTestMetricsOutputSchema = {
|
|
457
|
+
testName: z.string(),
|
|
458
|
+
before: z.object({
|
|
459
|
+
testRunId: z.string(),
|
|
460
|
+
commit: z.string().nullable(),
|
|
461
|
+
branch: z.string().nullable(),
|
|
462
|
+
status: z.enum([
|
|
463
|
+
"passed",
|
|
464
|
+
"failed",
|
|
465
|
+
"skipped"
|
|
466
|
+
]),
|
|
467
|
+
durationMs: z.number().nullable(),
|
|
468
|
+
createdAt: z.string()
|
|
469
|
+
}),
|
|
470
|
+
after: z.object({
|
|
471
|
+
testRunId: z.string(),
|
|
472
|
+
commit: z.string().nullable(),
|
|
473
|
+
branch: z.string().nullable(),
|
|
474
|
+
status: z.enum([
|
|
475
|
+
"passed",
|
|
476
|
+
"failed",
|
|
477
|
+
"skipped"
|
|
478
|
+
]),
|
|
479
|
+
durationMs: z.number().nullable(),
|
|
480
|
+
createdAt: z.string()
|
|
481
|
+
}),
|
|
482
|
+
change: z.object({
|
|
483
|
+
durationMs: z.number().nullable(),
|
|
484
|
+
percentChange: z.number().nullable(),
|
|
485
|
+
statusChanged: z.boolean()
|
|
486
|
+
})
|
|
485
487
|
};
|
|
488
|
+
/**
|
|
489
|
+
* Execute compare_test_metrics tool
|
|
490
|
+
*/
|
|
486
491
|
async function executeCompareTestMetrics(client, input) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
testName: input.testName,
|
|
505
|
-
beforeCommit: input.beforeCommit,
|
|
506
|
-
afterCommit: input.afterCommit,
|
|
507
|
-
beforeRunId: input.beforeRunId,
|
|
508
|
-
afterRunId: input.afterRunId
|
|
509
|
-
});
|
|
510
|
-
return response;
|
|
492
|
+
const hasCommits = input.beforeCommit && input.afterCommit;
|
|
493
|
+
const hasRunIds = input.beforeRunId && input.afterRunId;
|
|
494
|
+
if (!hasCommits && !hasRunIds) throw new Error("Must provide either (beforeCommit + afterCommit) or (beforeRunId + afterRunId)");
|
|
495
|
+
if (hasCommits) {
|
|
496
|
+
if (input.beforeCommit.trim().length === 0 || input.afterCommit.trim().length === 0) throw new Error("beforeCommit and afterCommit must not be empty strings");
|
|
497
|
+
}
|
|
498
|
+
if (hasRunIds) {
|
|
499
|
+
if (input.beforeRunId.trim().length === 0 || input.afterRunId.trim().length === 0) throw new Error("beforeRunId and afterRunId must not be empty strings");
|
|
500
|
+
}
|
|
501
|
+
return await client.compareTestMetrics({
|
|
502
|
+
projectId: input.projectId,
|
|
503
|
+
testName: input.testName,
|
|
504
|
+
beforeCommit: input.beforeCommit,
|
|
505
|
+
afterCommit: input.afterCommit,
|
|
506
|
+
beforeRunId: input.beforeRunId,
|
|
507
|
+
afterRunId: input.afterRunId
|
|
508
|
+
});
|
|
511
509
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
510
|
+
/**
|
|
511
|
+
* Tool metadata
|
|
512
|
+
*/
|
|
513
|
+
const compareTestMetricsMetadata = {
|
|
514
|
+
name: "compare_test_metrics",
|
|
515
|
+
title: "Compare Test Metrics",
|
|
516
|
+
description: `Compare test metrics between two commits or test runs.
|
|
516
517
|
|
|
517
518
|
Useful for measuring the impact of code changes on test performance or reliability.
|
|
518
519
|
|
|
@@ -549,46 +550,58 @@ Use cases:
|
|
|
549
550
|
Tip: Use get_test_history first to find the commit SHAs or test run IDs you want to compare.`
|
|
550
551
|
};
|
|
551
552
|
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
553
|
+
//#endregion
|
|
554
|
+
//#region src/tools/find-uncovered-failure-areas.ts
|
|
555
|
+
/**
|
|
556
|
+
* Input schema for find_uncovered_failure_areas tool
|
|
557
|
+
*/
|
|
558
|
+
const findUncoveredFailureAreasInputSchema = {
|
|
559
|
+
projectId: z.string().describe("Project ID to analyze. Required. Use list_projects to find project IDs."),
|
|
560
|
+
days: z.number().int().min(1).max(365).optional().describe("Number of days to analyze for test failures (default: 30)"),
|
|
561
|
+
coverageThreshold: z.number().min(0).max(100).optional().describe("Include files with coverage below this percentage (default: 80)")
|
|
558
562
|
};
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
563
|
+
/**
|
|
564
|
+
* Output schema for find_uncovered_failure_areas tool
|
|
565
|
+
*/
|
|
566
|
+
const findUncoveredFailureAreasOutputSchema = {
|
|
567
|
+
hasCoverage: z.boolean(),
|
|
568
|
+
hasTestResults: z.boolean(),
|
|
569
|
+
riskAreas: z.array(z.object({
|
|
570
|
+
filePath: z.string(),
|
|
571
|
+
coverage: z.number(),
|
|
572
|
+
failureCount: z.number(),
|
|
573
|
+
riskScore: z.number(),
|
|
574
|
+
testNames: z.array(z.string())
|
|
575
|
+
})),
|
|
576
|
+
message: z.string().optional()
|
|
570
577
|
};
|
|
578
|
+
/**
|
|
579
|
+
* Execute find_uncovered_failure_areas tool
|
|
580
|
+
*/
|
|
571
581
|
async function executeFindUncoveredFailureAreas(client, input) {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
582
|
+
const response = await client.getCoverageRiskAreas({
|
|
583
|
+
projectId: input.projectId,
|
|
584
|
+
days: input.days,
|
|
585
|
+
coverageThreshold: input.coverageThreshold
|
|
586
|
+
});
|
|
587
|
+
return {
|
|
588
|
+
hasCoverage: response.hasCoverage,
|
|
589
|
+
hasTestResults: response.hasTestResults,
|
|
590
|
+
riskAreas: response.riskAreas,
|
|
591
|
+
message: response.message
|
|
592
|
+
};
|
|
583
593
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
594
|
+
/**
|
|
595
|
+
* Tool metadata
|
|
596
|
+
*/
|
|
597
|
+
const findUncoveredFailureAreasMetadata = {
|
|
598
|
+
name: "find_uncovered_failure_areas",
|
|
599
|
+
title: "Find Uncovered Failure Areas",
|
|
600
|
+
description: `Find areas of code that have both low coverage AND test failures.
|
|
588
601
|
|
|
589
602
|
This cross-references test failures with coverage data to identify high-risk
|
|
590
603
|
areas in your codebase that need attention. Files are ranked by a "risk score"
|
|
591
|
-
calculated as: (100 - coverage%)
|
|
604
|
+
calculated as: (100 - coverage%) × failureCount.
|
|
592
605
|
|
|
593
606
|
When using a user API Key (gaf_), you must provide a projectId.
|
|
594
607
|
Use list_projects first to find available project IDs.
|
|
@@ -605,56 +618,67 @@ Returns:
|
|
|
605
618
|
Use this to prioritize which parts of your codebase need better test coverage.`
|
|
606
619
|
};
|
|
607
620
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region src/tools/get-coverage-for-file.ts
|
|
623
|
+
/**
|
|
624
|
+
* Input schema for get_coverage_for_file tool
|
|
625
|
+
*/
|
|
626
|
+
const getCoverageForFileInputSchema = {
|
|
627
|
+
projectId: z.string().describe("Project ID to get coverage for. Required. Use list_projects to find project IDs."),
|
|
628
|
+
filePath: z.string().describe("File path to get coverage for. Can be exact path or partial match.")
|
|
613
629
|
};
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
630
|
+
/**
|
|
631
|
+
* Output schema for get_coverage_for_file tool
|
|
632
|
+
*/
|
|
633
|
+
const getCoverageForFileOutputSchema = {
|
|
634
|
+
hasCoverage: z.boolean(),
|
|
635
|
+
files: z.array(z.object({
|
|
636
|
+
path: z.string(),
|
|
637
|
+
lines: z.object({
|
|
638
|
+
covered: z.number(),
|
|
639
|
+
total: z.number(),
|
|
640
|
+
percentage: z.number()
|
|
641
|
+
}),
|
|
642
|
+
branches: z.object({
|
|
643
|
+
covered: z.number(),
|
|
644
|
+
total: z.number(),
|
|
645
|
+
percentage: z.number()
|
|
646
|
+
}),
|
|
647
|
+
functions: z.object({
|
|
648
|
+
covered: z.number(),
|
|
649
|
+
total: z.number(),
|
|
650
|
+
percentage: z.number()
|
|
651
|
+
})
|
|
652
|
+
})),
|
|
653
|
+
message: z.string().optional()
|
|
635
654
|
};
|
|
655
|
+
/**
|
|
656
|
+
* Execute get_coverage_for_file tool
|
|
657
|
+
*/
|
|
636
658
|
async function executeGetCoverageForFile(client, input) {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
};
|
|
659
|
+
const response = await client.getCoverageFiles({
|
|
660
|
+
projectId: input.projectId,
|
|
661
|
+
filePath: input.filePath,
|
|
662
|
+
limit: 10
|
|
663
|
+
});
|
|
664
|
+
return {
|
|
665
|
+
hasCoverage: response.hasCoverage,
|
|
666
|
+
files: response.files.map((f) => ({
|
|
667
|
+
path: f.path,
|
|
668
|
+
lines: f.lines,
|
|
669
|
+
branches: f.branches,
|
|
670
|
+
functions: f.functions
|
|
671
|
+
})),
|
|
672
|
+
message: response.message
|
|
673
|
+
};
|
|
653
674
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
675
|
+
/**
|
|
676
|
+
* Tool metadata
|
|
677
|
+
*/
|
|
678
|
+
const getCoverageForFileMetadata = {
|
|
679
|
+
name: "get_coverage_for_file",
|
|
680
|
+
title: "Get Coverage for File",
|
|
681
|
+
description: `Get coverage metrics for a specific file or files matching a path pattern.
|
|
658
682
|
|
|
659
683
|
When using a user API Key (gaf_), you must provide a projectId.
|
|
660
684
|
Use list_projects first to find available project IDs.
|
|
@@ -680,50 +704,66 @@ heavily-imported files, and code handling auth/payments/data mutations.
|
|
|
680
704
|
Prioritize: high utilization + low coverage = highest impact.`
|
|
681
705
|
};
|
|
682
706
|
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
707
|
+
//#endregion
|
|
708
|
+
//#region src/tools/get-coverage-summary.ts
|
|
709
|
+
/**
|
|
710
|
+
* Input schema for get_coverage_summary tool
|
|
711
|
+
*/
|
|
712
|
+
const getCoverageSummaryInputSchema = {
|
|
713
|
+
projectId: z.string().describe("Project ID to get coverage for. Required. Use list_projects to find project IDs."),
|
|
714
|
+
days: z.number().int().min(1).max(365).optional().describe("Number of days to analyze for trends (default: 30)")
|
|
688
715
|
};
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
716
|
+
/**
|
|
717
|
+
* Output schema for get_coverage_summary tool
|
|
718
|
+
*/
|
|
719
|
+
const getCoverageSummaryOutputSchema = {
|
|
720
|
+
hasCoverage: z.boolean(),
|
|
721
|
+
current: z.object({
|
|
722
|
+
lines: z.number(),
|
|
723
|
+
branches: z.number(),
|
|
724
|
+
functions: z.number()
|
|
725
|
+
}).optional(),
|
|
726
|
+
trend: z.object({
|
|
727
|
+
direction: z.enum([
|
|
728
|
+
"up",
|
|
729
|
+
"down",
|
|
730
|
+
"stable"
|
|
731
|
+
]),
|
|
732
|
+
change: z.number()
|
|
733
|
+
}).optional(),
|
|
734
|
+
totalReports: z.number(),
|
|
735
|
+
latestReportDate: z.string().nullable().optional(),
|
|
736
|
+
lowestCoverageFiles: z.array(z.object({
|
|
737
|
+
path: z.string(),
|
|
738
|
+
coverage: z.number()
|
|
739
|
+
})).optional(),
|
|
740
|
+
message: z.string().optional()
|
|
707
741
|
};
|
|
742
|
+
/**
|
|
743
|
+
* Execute get_coverage_summary tool
|
|
744
|
+
*/
|
|
708
745
|
async function executeGetCoverageSummary(client, input) {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
746
|
+
const response = await client.getCoverageSummary({
|
|
747
|
+
projectId: input.projectId,
|
|
748
|
+
days: input.days
|
|
749
|
+
});
|
|
750
|
+
return {
|
|
751
|
+
hasCoverage: response.hasCoverage,
|
|
752
|
+
current: response.current,
|
|
753
|
+
trend: response.trend,
|
|
754
|
+
totalReports: response.totalReports,
|
|
755
|
+
latestReportDate: response.latestReportDate,
|
|
756
|
+
lowestCoverageFiles: response.lowestCoverageFiles,
|
|
757
|
+
message: response.message
|
|
758
|
+
};
|
|
722
759
|
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
760
|
+
/**
|
|
761
|
+
* Tool metadata
|
|
762
|
+
*/
|
|
763
|
+
const getCoverageSummaryMetadata = {
|
|
764
|
+
name: "get_coverage_summary",
|
|
765
|
+
title: "Get Coverage Summary",
|
|
766
|
+
description: `Get the coverage metrics summary for a project.
|
|
727
767
|
|
|
728
768
|
When using a user API Key (gaf_), you must provide a projectId.
|
|
729
769
|
Use list_projects first to find available project IDs.
|
|
@@ -742,102 +782,204 @@ specific areas (e.g., "server/services", "src/api", "lib/core"). This helps iden
|
|
|
742
782
|
high-value targets in critical code paths rather than just the files with lowest coverage.`
|
|
743
783
|
};
|
|
744
784
|
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
785
|
+
//#endregion
|
|
786
|
+
//#region src/tools/get-failure-clusters.ts
|
|
787
|
+
/**
|
|
788
|
+
* Input schema for get_failure_clusters tool
|
|
789
|
+
*/
|
|
790
|
+
const getFailureClustersInputSchema = {
|
|
791
|
+
projectId: z.string().describe("Project ID. Use list_projects to find project IDs."),
|
|
792
|
+
testRunId: z.string().describe("Test run ID to get failure clusters for. Use list_test_runs to find test run IDs.")
|
|
793
|
+
};
|
|
794
|
+
/**
|
|
795
|
+
* Output schema for get_failure_clusters tool
|
|
796
|
+
*/
|
|
797
|
+
const getFailureClustersOutputSchema = {
|
|
798
|
+
clusters: z.array(z.object({
|
|
799
|
+
representativeError: z.string(),
|
|
800
|
+
count: z.number(),
|
|
801
|
+
tests: z.array(z.object({
|
|
802
|
+
name: z.string(),
|
|
803
|
+
fullName: z.string(),
|
|
804
|
+
errorMessage: z.string(),
|
|
805
|
+
filePath: z.string().nullable()
|
|
806
|
+
})),
|
|
807
|
+
similarity: z.number()
|
|
808
|
+
})),
|
|
809
|
+
totalFailures: z.number()
|
|
810
|
+
};
|
|
811
|
+
/**
|
|
812
|
+
* Execute get_failure_clusters tool
|
|
813
|
+
*/
|
|
814
|
+
async function executeGetFailureClusters(client, input) {
|
|
815
|
+
return client.getFailureClusters({
|
|
816
|
+
projectId: input.projectId,
|
|
817
|
+
testRunId: input.testRunId
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Tool metadata
|
|
822
|
+
*/
|
|
823
|
+
const getFailureClustersMetadata = {
|
|
824
|
+
name: "get_failure_clusters",
|
|
825
|
+
title: "Get Failure Clusters",
|
|
826
|
+
description: `Group failed tests by root cause using error message similarity.
|
|
827
|
+
|
|
828
|
+
When using a user API Key (gaf_), you must provide a projectId.
|
|
829
|
+
Use list_projects to find available project IDs, and list_test_runs to find test run IDs.
|
|
830
|
+
|
|
831
|
+
Parameters:
|
|
832
|
+
- projectId (required): The project ID
|
|
833
|
+
- testRunId (required): The test run ID to analyze
|
|
834
|
+
|
|
835
|
+
Returns:
|
|
836
|
+
- clusters: Array of failure clusters, each containing:
|
|
837
|
+
- representativeError: The error message representing this cluster
|
|
838
|
+
- count: Number of tests with this same root cause
|
|
839
|
+
- tests: Array of individual failed tests in this cluster
|
|
840
|
+
- name: Short test name
|
|
841
|
+
- fullName: Full test name including describe blocks
|
|
842
|
+
- errorMessage: The specific error message
|
|
843
|
+
- filePath: Test file path (null if not recorded)
|
|
844
|
+
- similarity: Similarity threshold used for clustering (0-1)
|
|
845
|
+
- totalFailures: Total number of failed tests across all clusters
|
|
846
|
+
|
|
847
|
+
Use cases:
|
|
848
|
+
- "Group these 15 failures by root cause" — often reveals 2-3 distinct bugs
|
|
849
|
+
- "Which error affects the most tests?" — fix the largest cluster first
|
|
850
|
+
- "Are these failures related?" — check if they land in the same cluster
|
|
851
|
+
|
|
852
|
+
Tip: Use get_test_run_details with status='failed' first to see raw failures,
|
|
853
|
+
then use this tool to understand which failures share the same root cause.`
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
//#endregion
|
|
857
|
+
//#region src/tools/get-flaky-tests.ts
|
|
858
|
+
/**
|
|
859
|
+
* Input schema for get_flaky_tests tool
|
|
860
|
+
*/
|
|
861
|
+
const getFlakyTestsInputSchema = {
|
|
862
|
+
projectId: z.string().optional().describe("Project ID to get flaky tests for. Required when using a user API Key (gaf_). Use list_projects to find project IDs."),
|
|
863
|
+
threshold: z.number().min(0).max(1).optional().describe("Minimum flip rate to be considered flaky (0-1, default: 0.1 = 10%)"),
|
|
864
|
+
limit: z.number().int().min(1).max(100).optional().describe("Maximum number of flaky tests to return (default: 50)"),
|
|
865
|
+
days: z.number().int().min(1).max(365).optional().describe("Analysis period in days (default: 30)")
|
|
752
866
|
};
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
867
|
+
/**
|
|
868
|
+
* Output schema for get_flaky_tests tool
|
|
869
|
+
*/
|
|
870
|
+
const getFlakyTestsOutputSchema = {
|
|
871
|
+
flakyTests: z.array(z.object({
|
|
872
|
+
name: z.string(),
|
|
873
|
+
flipRate: z.number(),
|
|
874
|
+
flipCount: z.number(),
|
|
875
|
+
totalRuns: z.number(),
|
|
876
|
+
lastSeen: z.string(),
|
|
877
|
+
flakinessScore: z.number()
|
|
878
|
+
})),
|
|
879
|
+
summary: z.object({
|
|
880
|
+
threshold: z.number(),
|
|
881
|
+
totalFlaky: z.number(),
|
|
882
|
+
period: z.number()
|
|
883
|
+
})
|
|
766
884
|
};
|
|
885
|
+
/**
|
|
886
|
+
* Execute get_flaky_tests tool
|
|
887
|
+
*/
|
|
767
888
|
async function executeGetFlakyTests(client, input) {
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
889
|
+
const response = await client.getFlakyTests({
|
|
890
|
+
projectId: input.projectId,
|
|
891
|
+
threshold: input.threshold,
|
|
892
|
+
limit: input.limit,
|
|
893
|
+
days: input.days
|
|
894
|
+
});
|
|
895
|
+
return {
|
|
896
|
+
flakyTests: response.flakyTests,
|
|
897
|
+
summary: response.summary
|
|
898
|
+
};
|
|
778
899
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
900
|
+
/**
|
|
901
|
+
* Tool metadata
|
|
902
|
+
*/
|
|
903
|
+
const getFlakyTestsMetadata = {
|
|
904
|
+
name: "get_flaky_tests",
|
|
905
|
+
title: "Get Flaky Tests",
|
|
906
|
+
description: `Get the list of flaky tests in a project.
|
|
783
907
|
|
|
784
908
|
When using a user API Key (gaf_), you must provide a projectId.
|
|
785
909
|
Use list_projects first to find available project IDs.
|
|
786
910
|
|
|
787
|
-
A test is considered flaky if it frequently switches between pass and fail states
|
|
788
|
-
|
|
911
|
+
A test is considered flaky if it frequently switches between pass and fail states.
|
|
912
|
+
Tests are ranked by a composite flakinessScore that factors in flip behavior,
|
|
913
|
+
failure rate, and duration variability.
|
|
789
914
|
|
|
790
915
|
Returns:
|
|
791
|
-
- List of flaky tests with:
|
|
916
|
+
- List of flaky tests sorted by flakinessScore (most flaky first), with:
|
|
792
917
|
- name: Test name
|
|
793
918
|
- flipRate: How often the test flips between pass/fail (0-1)
|
|
794
919
|
- flipCount: Number of status transitions
|
|
795
920
|
- totalRuns: Total test executions analyzed
|
|
796
921
|
- lastSeen: When the test last ran
|
|
922
|
+
- flakinessScore: Composite score (0-1) combining flip proximity, failure rate, and duration variability
|
|
797
923
|
- Summary with threshold used and total count
|
|
798
924
|
|
|
799
925
|
Use this after get_project_health shows flaky tests exist, to identify which
|
|
800
926
|
specific tests are flaky and need investigation.`
|
|
801
927
|
};
|
|
802
928
|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
929
|
+
//#endregion
|
|
930
|
+
//#region src/tools/get-project-health.ts
|
|
931
|
+
/**
|
|
932
|
+
* Input schema for get_project_health tool
|
|
933
|
+
*/
|
|
934
|
+
const getProjectHealthInputSchema = {
|
|
935
|
+
projectId: z.string().optional().describe("Project ID to get health for. Required when using a user API Key (gaf_). Use list_projects to find project IDs."),
|
|
936
|
+
days: z.number().int().min(1).max(365).optional().describe("Number of days to analyze (default: 30)")
|
|
808
937
|
};
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
938
|
+
/**
|
|
939
|
+
* Output schema for get_project_health tool
|
|
940
|
+
*/
|
|
941
|
+
const getProjectHealthOutputSchema = {
|
|
942
|
+
projectName: z.string(),
|
|
943
|
+
healthScore: z.number(),
|
|
944
|
+
passRate: z.number().nullable(),
|
|
945
|
+
testRunCount: z.number(),
|
|
946
|
+
flakyTestCount: z.number(),
|
|
947
|
+
trend: z.enum([
|
|
948
|
+
"up",
|
|
949
|
+
"down",
|
|
950
|
+
"stable"
|
|
951
|
+
]),
|
|
952
|
+
period: z.object({
|
|
953
|
+
days: z.number(),
|
|
954
|
+
start: z.string(),
|
|
955
|
+
end: z.string()
|
|
956
|
+
})
|
|
821
957
|
};
|
|
958
|
+
/**
|
|
959
|
+
* Execute get_project_health tool
|
|
960
|
+
*/
|
|
822
961
|
async function executeGetProjectHealth(client, input) {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
962
|
+
const response = await client.getProjectHealth({
|
|
963
|
+
projectId: input.projectId,
|
|
964
|
+
days: input.days
|
|
965
|
+
});
|
|
966
|
+
return {
|
|
967
|
+
projectName: response.analytics.projectName,
|
|
968
|
+
healthScore: response.analytics.healthScore,
|
|
969
|
+
passRate: response.analytics.passRate,
|
|
970
|
+
testRunCount: response.analytics.testRunCount,
|
|
971
|
+
flakyTestCount: response.analytics.flakyTestCount,
|
|
972
|
+
trend: response.analytics.trend,
|
|
973
|
+
period: response.analytics.period
|
|
974
|
+
};
|
|
836
975
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
976
|
+
/**
|
|
977
|
+
* Tool metadata
|
|
978
|
+
*/
|
|
979
|
+
const getProjectHealthMetadata = {
|
|
980
|
+
name: "get_project_health",
|
|
981
|
+
title: "Get Project Health",
|
|
982
|
+
description: `Get the health metrics for a project.
|
|
841
983
|
|
|
842
984
|
When using a user API Key (gaf_), you must provide a projectId.
|
|
843
985
|
Use list_projects first to find available project IDs.
|
|
@@ -852,38 +994,50 @@ Returns:
|
|
|
852
994
|
Use this to understand the current state of your test suite.`
|
|
853
995
|
};
|
|
854
996
|
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
997
|
+
//#endregion
|
|
998
|
+
//#region src/tools/get-report-browser-url.ts
|
|
999
|
+
/**
|
|
1000
|
+
* Input schema for get_report_browser_url tool
|
|
1001
|
+
*/
|
|
1002
|
+
const getReportBrowserUrlInputSchema = {
|
|
1003
|
+
projectId: z.string().describe("Project ID the test run belongs to. Required. Use list_projects to find project IDs."),
|
|
1004
|
+
testRunId: z.string().describe("The test run ID to get the report URL for. Use list_test_runs to find test run IDs."),
|
|
1005
|
+
filename: z.string().optional().describe("Specific file to open (default: index.html or first HTML file)")
|
|
861
1006
|
};
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
1007
|
+
/**
|
|
1008
|
+
* Output schema for get_report_browser_url tool
|
|
1009
|
+
*/
|
|
1010
|
+
const getReportBrowserUrlOutputSchema = {
|
|
1011
|
+
url: z.string(),
|
|
1012
|
+
filename: z.string(),
|
|
1013
|
+
testRunId: z.string(),
|
|
1014
|
+
expiresAt: z.string(),
|
|
1015
|
+
expiresInSeconds: z.number()
|
|
868
1016
|
};
|
|
1017
|
+
/**
|
|
1018
|
+
* Execute get_report_browser_url tool
|
|
1019
|
+
*/
|
|
869
1020
|
async function executeGetReportBrowserUrl(client, input) {
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
1021
|
+
const response = await client.getReportBrowserUrl({
|
|
1022
|
+
projectId: input.projectId,
|
|
1023
|
+
testRunId: input.testRunId,
|
|
1024
|
+
filename: input.filename
|
|
1025
|
+
});
|
|
1026
|
+
return {
|
|
1027
|
+
url: response.url,
|
|
1028
|
+
filename: response.filename,
|
|
1029
|
+
testRunId: response.testRunId,
|
|
1030
|
+
expiresAt: response.expiresAt,
|
|
1031
|
+
expiresInSeconds: response.expiresInSeconds
|
|
1032
|
+
};
|
|
882
1033
|
}
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
1034
|
+
/**
|
|
1035
|
+
* Tool metadata
|
|
1036
|
+
*/
|
|
1037
|
+
const getReportBrowserUrlMetadata = {
|
|
1038
|
+
name: "get_report_browser_url",
|
|
1039
|
+
title: "Get Report Browser URL",
|
|
1040
|
+
description: `Get a browser-navigable URL for viewing a test report (Playwright, Vitest, etc.).
|
|
887
1041
|
|
|
888
1042
|
Returns a signed URL that can be opened directly in a browser without requiring
|
|
889
1043
|
the user to log in. The URL expires after 30 minutes for security.
|
|
@@ -906,44 +1060,54 @@ The returned URL can be shared with users who need to view the report.
|
|
|
906
1060
|
Note: URLs expire after 30 minutes for security.`
|
|
907
1061
|
};
|
|
908
1062
|
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
1063
|
+
//#endregion
|
|
1064
|
+
//#region src/tools/get-report.ts
|
|
1065
|
+
/**
|
|
1066
|
+
* Input schema for get_report tool
|
|
1067
|
+
*/
|
|
1068
|
+
const getReportInputSchema = { testRunId: z.string().describe("The test run ID to get report files for. Use list_test_runs to find test run IDs.") };
|
|
1069
|
+
/**
|
|
1070
|
+
* Output schema for get_report tool
|
|
1071
|
+
*/
|
|
1072
|
+
const getReportOutputSchema = {
|
|
1073
|
+
testRunId: z.string(),
|
|
1074
|
+
projectId: z.string(),
|
|
1075
|
+
projectName: z.string(),
|
|
1076
|
+
resultSchema: z.string().optional(),
|
|
1077
|
+
files: z.array(z.object({
|
|
1078
|
+
filename: z.string(),
|
|
1079
|
+
size: z.number(),
|
|
1080
|
+
contentType: z.string(),
|
|
1081
|
+
downloadUrl: z.string()
|
|
1082
|
+
})),
|
|
1083
|
+
urlExpiresInSeconds: z.number().optional()
|
|
926
1084
|
};
|
|
1085
|
+
/**
|
|
1086
|
+
* Execute get_report tool
|
|
1087
|
+
*/
|
|
927
1088
|
async function executeGetReport(client, input) {
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1089
|
+
const response = await client.getReport(input.testRunId);
|
|
1090
|
+
return {
|
|
1091
|
+
testRunId: response.testRunId,
|
|
1092
|
+
projectId: response.projectId,
|
|
1093
|
+
projectName: response.projectName,
|
|
1094
|
+
resultSchema: response.resultSchema,
|
|
1095
|
+
files: response.files.map((file) => ({
|
|
1096
|
+
filename: file.filename,
|
|
1097
|
+
size: file.size,
|
|
1098
|
+
contentType: file.contentType,
|
|
1099
|
+
downloadUrl: file.downloadUrl
|
|
1100
|
+
})),
|
|
1101
|
+
urlExpiresInSeconds: response.urlExpiresInSeconds
|
|
1102
|
+
};
|
|
942
1103
|
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
1104
|
+
/**
|
|
1105
|
+
* Tool metadata
|
|
1106
|
+
*/
|
|
1107
|
+
const getReportMetadata = {
|
|
1108
|
+
name: "get_report",
|
|
1109
|
+
title: "Get Report Files",
|
|
1110
|
+
description: `Get URLs for report files uploaded with a test run.
|
|
947
1111
|
|
|
948
1112
|
IMPORTANT: This tool returns download URLs, not file content. You must fetch the URLs separately.
|
|
949
1113
|
|
|
@@ -979,57 +1143,69 @@ Use cases:
|
|
|
979
1143
|
- "Parse the JUnit XML results" (then WebFetch the XML URL)`
|
|
980
1144
|
};
|
|
981
1145
|
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
1146
|
+
//#endregion
|
|
1147
|
+
//#region src/tools/get-slowest-tests.ts
|
|
1148
|
+
/**
|
|
1149
|
+
* Input schema for get_slowest_tests tool
|
|
1150
|
+
*/
|
|
1151
|
+
const getSlowestTestsInputSchema = {
|
|
1152
|
+
projectId: z.string().describe("Project ID to get slowest tests for. Required. Use list_projects to find project IDs."),
|
|
1153
|
+
days: z.number().int().min(1).max(365).optional().describe("Analysis period in days (default: 30)"),
|
|
1154
|
+
limit: z.number().int().min(1).max(100).optional().describe("Maximum number of tests to return (default: 20)"),
|
|
1155
|
+
framework: z.string().optional().describe("Filter by test framework (e.g., \"playwright\", \"vitest\", \"jest\")"),
|
|
1156
|
+
branch: z.string().optional().describe("Filter by git branch name (e.g., \"main\", \"develop\")")
|
|
990
1157
|
};
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1158
|
+
/**
|
|
1159
|
+
* Output schema for get_slowest_tests tool
|
|
1160
|
+
*/
|
|
1161
|
+
const getSlowestTestsOutputSchema = {
|
|
1162
|
+
slowestTests: z.array(z.object({
|
|
1163
|
+
name: z.string(),
|
|
1164
|
+
fullName: z.string(),
|
|
1165
|
+
filePath: z.string().optional(),
|
|
1166
|
+
framework: z.string().optional(),
|
|
1167
|
+
avgDurationMs: z.number(),
|
|
1168
|
+
p95DurationMs: z.number(),
|
|
1169
|
+
runCount: z.number()
|
|
1170
|
+
})),
|
|
1171
|
+
summary: z.object({
|
|
1172
|
+
projectId: z.string(),
|
|
1173
|
+
projectName: z.string(),
|
|
1174
|
+
period: z.number(),
|
|
1175
|
+
totalReturned: z.number()
|
|
1176
|
+
})
|
|
1007
1177
|
};
|
|
1178
|
+
/**
|
|
1179
|
+
* Execute get_slowest_tests tool
|
|
1180
|
+
*/
|
|
1008
1181
|
async function executeGetSlowestTests(client, input) {
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1182
|
+
const response = await client.getSlowestTests({
|
|
1183
|
+
projectId: input.projectId,
|
|
1184
|
+
days: input.days,
|
|
1185
|
+
limit: input.limit,
|
|
1186
|
+
framework: input.framework,
|
|
1187
|
+
branch: input.branch
|
|
1188
|
+
});
|
|
1189
|
+
return {
|
|
1190
|
+
slowestTests: response.slowestTests.map((test) => ({
|
|
1191
|
+
name: test.name,
|
|
1192
|
+
fullName: test.fullName,
|
|
1193
|
+
filePath: test.filePath,
|
|
1194
|
+
framework: test.framework,
|
|
1195
|
+
avgDurationMs: test.avgDurationMs,
|
|
1196
|
+
p95DurationMs: test.p95DurationMs,
|
|
1197
|
+
runCount: test.runCount
|
|
1198
|
+
})),
|
|
1199
|
+
summary: response.summary
|
|
1200
|
+
};
|
|
1028
1201
|
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1202
|
+
/**
|
|
1203
|
+
* Tool metadata
|
|
1204
|
+
*/
|
|
1205
|
+
const getSlowestTestsMetadata = {
|
|
1206
|
+
name: "get_slowest_tests",
|
|
1207
|
+
title: "Get Slowest Tests",
|
|
1208
|
+
description: `Get the slowest tests in a project, sorted by P95 duration.
|
|
1033
1209
|
|
|
1034
1210
|
When using a user API Key (gaf_), you must provide a projectId.
|
|
1035
1211
|
Use list_projects first to find available project IDs.
|
|
@@ -1059,64 +1235,78 @@ Use cases:
|
|
|
1059
1235
|
- "What are the slowest tests on the main branch?"`
|
|
1060
1236
|
};
|
|
1061
1237
|
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1238
|
+
//#endregion
|
|
1239
|
+
//#region src/tools/get-test-history.ts
|
|
1240
|
+
/**
|
|
1241
|
+
* Input schema for get_test_history tool
|
|
1242
|
+
*/
|
|
1243
|
+
const getTestHistoryInputSchema = {
|
|
1244
|
+
projectId: z.string().optional().describe("Project ID to get test history for. Required when using a user API Key (gaf_). Use list_projects to find project IDs."),
|
|
1245
|
+
testName: z.string().optional().describe("Exact test name to search for"),
|
|
1246
|
+
filePath: z.string().optional().describe("File path containing the test"),
|
|
1247
|
+
limit: z.number().int().min(1).max(100).optional().describe("Maximum number of results (default: 20)")
|
|
1069
1248
|
};
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1249
|
+
/**
|
|
1250
|
+
* Output schema for get_test_history tool
|
|
1251
|
+
*/
|
|
1252
|
+
const getTestHistoryOutputSchema = {
|
|
1253
|
+
history: z.array(z.object({
|
|
1254
|
+
testRunId: z.string(),
|
|
1255
|
+
createdAt: z.string(),
|
|
1256
|
+
branch: z.string().optional(),
|
|
1257
|
+
commitSha: z.string().optional(),
|
|
1258
|
+
status: z.enum([
|
|
1259
|
+
"passed",
|
|
1260
|
+
"failed",
|
|
1261
|
+
"skipped",
|
|
1262
|
+
"pending"
|
|
1263
|
+
]),
|
|
1264
|
+
durationMs: z.number(),
|
|
1265
|
+
message: z.string().optional()
|
|
1266
|
+
})),
|
|
1267
|
+
summary: z.object({
|
|
1268
|
+
totalRuns: z.number(),
|
|
1269
|
+
passedRuns: z.number(),
|
|
1270
|
+
failedRuns: z.number(),
|
|
1271
|
+
passRate: z.number().nullable()
|
|
1272
|
+
})
|
|
1086
1273
|
};
|
|
1274
|
+
/**
|
|
1275
|
+
* Execute get_test_history tool
|
|
1276
|
+
*/
|
|
1087
1277
|
async function executeGetTestHistory(client, input) {
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
passRate: response.summary.passRate
|
|
1113
|
-
}
|
|
1114
|
-
};
|
|
1278
|
+
if (!input.testName && !input.filePath) throw new Error("Either testName or filePath is required");
|
|
1279
|
+
const response = await client.getTestHistory({
|
|
1280
|
+
projectId: input.projectId,
|
|
1281
|
+
testName: input.testName,
|
|
1282
|
+
filePath: input.filePath,
|
|
1283
|
+
limit: input.limit || 20
|
|
1284
|
+
});
|
|
1285
|
+
return {
|
|
1286
|
+
history: response.history.map((entry) => ({
|
|
1287
|
+
testRunId: entry.testRunId,
|
|
1288
|
+
createdAt: entry.createdAt,
|
|
1289
|
+
branch: entry.branch,
|
|
1290
|
+
commitSha: entry.commitSha,
|
|
1291
|
+
status: entry.test.status,
|
|
1292
|
+
durationMs: entry.test.durationMs,
|
|
1293
|
+
message: entry.test.message || void 0
|
|
1294
|
+
})),
|
|
1295
|
+
summary: {
|
|
1296
|
+
totalRuns: response.summary.totalRuns,
|
|
1297
|
+
passedRuns: response.summary.passedRuns,
|
|
1298
|
+
failedRuns: response.summary.failedRuns,
|
|
1299
|
+
passRate: response.summary.passRate
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1115
1302
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1303
|
+
/**
|
|
1304
|
+
* Tool metadata
|
|
1305
|
+
*/
|
|
1306
|
+
const getTestHistoryMetadata = {
|
|
1307
|
+
name: "get_test_history",
|
|
1308
|
+
title: "Get Test History",
|
|
1309
|
+
description: `Get the pass/fail history for a specific test.
|
|
1120
1310
|
|
|
1121
1311
|
When using a user API Key (gaf_), you must provide a projectId.
|
|
1122
1312
|
Use list_projects first to find available project IDs.
|
|
@@ -1135,57 +1325,86 @@ Returns:
|
|
|
1135
1325
|
Use this to investigate flaky tests or understand test stability.`
|
|
1136
1326
|
};
|
|
1137
1327
|
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1328
|
+
//#endregion
|
|
1329
|
+
//#region src/tools/get-test-run-details.ts
|
|
1330
|
+
/**
|
|
1331
|
+
* Input schema for get_test_run_details tool
|
|
1332
|
+
*/
|
|
1333
|
+
const getTestRunDetailsInputSchema = {
|
|
1334
|
+
testRunId: z.string().describe("The test run ID to get details for. Use list_test_runs to find test run IDs."),
|
|
1335
|
+
projectId: z.string().describe("Project ID the test run belongs to. Required when using a user API Key (gaf_). Use list_projects to find project IDs."),
|
|
1336
|
+
status: z.enum([
|
|
1337
|
+
"passed",
|
|
1338
|
+
"failed",
|
|
1339
|
+
"skipped"
|
|
1340
|
+
]).optional().describe("Filter tests by status. Returns only tests matching this status."),
|
|
1341
|
+
limit: z.number().int().min(1).max(500).optional().describe("Maximum number of tests to return (default: 100, max: 500)"),
|
|
1342
|
+
offset: z.number().int().min(0).optional().describe("Number of tests to skip for pagination (default: 0)")
|
|
1146
1343
|
};
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1344
|
+
/**
|
|
1345
|
+
* Output schema for get_test_run_details tool
|
|
1346
|
+
*/
|
|
1347
|
+
const getTestRunDetailsOutputSchema = {
|
|
1348
|
+
testRunId: z.string(),
|
|
1349
|
+
commitSha: z.string().nullable(),
|
|
1350
|
+
branch: z.string().nullable(),
|
|
1351
|
+
framework: z.string().nullable(),
|
|
1352
|
+
createdAt: z.string(),
|
|
1353
|
+
summary: z.object({
|
|
1354
|
+
passed: z.number(),
|
|
1355
|
+
failed: z.number(),
|
|
1356
|
+
skipped: z.number(),
|
|
1357
|
+
total: z.number()
|
|
1358
|
+
}),
|
|
1359
|
+
tests: z.array(z.object({
|
|
1360
|
+
name: z.string(),
|
|
1361
|
+
fullName: z.string(),
|
|
1362
|
+
status: z.enum([
|
|
1363
|
+
"passed",
|
|
1364
|
+
"failed",
|
|
1365
|
+
"skipped"
|
|
1366
|
+
]),
|
|
1367
|
+
durationMs: z.number().nullable(),
|
|
1368
|
+
filePath: z.string().nullable(),
|
|
1369
|
+
error: z.string().nullable(),
|
|
1370
|
+
errorStack: z.string().nullable()
|
|
1371
|
+
})),
|
|
1372
|
+
pagination: z.object({
|
|
1373
|
+
total: z.number(),
|
|
1374
|
+
limit: z.number(),
|
|
1375
|
+
offset: z.number(),
|
|
1376
|
+
hasMore: z.boolean()
|
|
1377
|
+
})
|
|
1169
1378
|
};
|
|
1379
|
+
/**
|
|
1380
|
+
* Execute get_test_run_details tool
|
|
1381
|
+
*/
|
|
1170
1382
|
async function executeGetTestRunDetails(client, input) {
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1383
|
+
const response = await client.getTestRunDetails({
|
|
1384
|
+
projectId: input.projectId,
|
|
1385
|
+
testRunId: input.testRunId,
|
|
1386
|
+
status: input.status,
|
|
1387
|
+
limit: input.limit,
|
|
1388
|
+
offset: input.offset
|
|
1389
|
+
});
|
|
1390
|
+
return {
|
|
1391
|
+
testRunId: response.testRunId,
|
|
1392
|
+
commitSha: response.commitSha,
|
|
1393
|
+
branch: response.branch,
|
|
1394
|
+
framework: response.framework,
|
|
1395
|
+
createdAt: response.createdAt,
|
|
1396
|
+
summary: response.summary,
|
|
1397
|
+
tests: response.tests,
|
|
1398
|
+
pagination: response.pagination
|
|
1399
|
+
};
|
|
1184
1400
|
}
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1401
|
+
/**
|
|
1402
|
+
* Tool metadata
|
|
1403
|
+
*/
|
|
1404
|
+
const getTestRunDetailsMetadata = {
|
|
1405
|
+
name: "get_test_run_details",
|
|
1406
|
+
title: "Get Test Run Details",
|
|
1407
|
+
description: `Get parsed test results for a specific test run.
|
|
1189
1408
|
|
|
1190
1409
|
When using a user API Key (gaf_), you must provide a projectId.
|
|
1191
1410
|
Use list_projects to find available project IDs, and list_test_runs to find test run IDs.
|
|
@@ -1199,6 +1418,10 @@ Parameters:
|
|
|
1199
1418
|
|
|
1200
1419
|
Returns:
|
|
1201
1420
|
- testRunId: The test run ID
|
|
1421
|
+
- commitSha: Git commit SHA (null if not recorded)
|
|
1422
|
+
- branch: Git branch name (null if not recorded)
|
|
1423
|
+
- framework: Test framework (e.g., "playwright", "vitest")
|
|
1424
|
+
- createdAt: When the test run was created (ISO 8601)
|
|
1202
1425
|
- summary: Overall counts (passed, failed, skipped, total)
|
|
1203
1426
|
- tests: Array of individual test results with:
|
|
1204
1427
|
- name: Short test name
|
|
@@ -1207,6 +1430,7 @@ Returns:
|
|
|
1207
1430
|
- durationMs: Test duration in milliseconds (null if not recorded)
|
|
1208
1431
|
- filePath: Test file path (null if not recorded)
|
|
1209
1432
|
- error: Error message for failed tests (null otherwise)
|
|
1433
|
+
- errorStack: Full stack trace for failed tests (null otherwise)
|
|
1210
1434
|
- pagination: Pagination info (total, limit, offset, hasMore)
|
|
1211
1435
|
|
|
1212
1436
|
Use cases:
|
|
@@ -1219,63 +1443,74 @@ Note: For aggregate analytics like flaky test detection or duration trends,
|
|
|
1219
1443
|
use get_test_history, get_flaky_tests, or get_slowest_tests instead.`
|
|
1220
1444
|
};
|
|
1221
1445
|
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1446
|
+
//#endregion
|
|
1447
|
+
//#region src/tools/get-untested-files.ts
|
|
1448
|
+
/**
|
|
1449
|
+
* Input schema for get_untested_files tool
|
|
1450
|
+
*/
|
|
1451
|
+
const getUntestedFilesInputSchema = {
|
|
1452
|
+
projectId: z.string().describe("Project ID to analyze. Required. Use list_projects to find project IDs."),
|
|
1453
|
+
maxCoverage: z.number().min(0).max(100).optional().describe("Maximum coverage percentage to include (default: 10 for \"untested\")"),
|
|
1454
|
+
limit: z.number().int().min(1).max(100).optional().describe("Maximum number of files to return (default: 20)")
|
|
1228
1455
|
};
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1456
|
+
/**
|
|
1457
|
+
* Output schema for get_untested_files tool
|
|
1458
|
+
*/
|
|
1459
|
+
const getUntestedFilesOutputSchema = {
|
|
1460
|
+
hasCoverage: z.boolean(),
|
|
1461
|
+
files: z.array(z.object({
|
|
1462
|
+
path: z.string(),
|
|
1463
|
+
lines: z.object({
|
|
1464
|
+
covered: z.number(),
|
|
1465
|
+
total: z.number(),
|
|
1466
|
+
percentage: z.number()
|
|
1467
|
+
}),
|
|
1468
|
+
branches: z.object({
|
|
1469
|
+
covered: z.number(),
|
|
1470
|
+
total: z.number(),
|
|
1471
|
+
percentage: z.number()
|
|
1472
|
+
}),
|
|
1473
|
+
functions: z.object({
|
|
1474
|
+
covered: z.number(),
|
|
1475
|
+
total: z.number(),
|
|
1476
|
+
percentage: z.number()
|
|
1477
|
+
})
|
|
1478
|
+
})),
|
|
1479
|
+
totalCount: z.number(),
|
|
1480
|
+
message: z.string().optional()
|
|
1251
1481
|
};
|
|
1482
|
+
/**
|
|
1483
|
+
* Execute get_untested_files tool
|
|
1484
|
+
*/
|
|
1252
1485
|
async function executeGetUntestedFiles(client, input) {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
};
|
|
1486
|
+
const maxCoverage = input.maxCoverage ?? 10;
|
|
1487
|
+
const limit = input.limit ?? 20;
|
|
1488
|
+
const response = await client.getCoverageFiles({
|
|
1489
|
+
projectId: input.projectId,
|
|
1490
|
+
maxCoverage,
|
|
1491
|
+
limit,
|
|
1492
|
+
sortBy: "coverage",
|
|
1493
|
+
sortOrder: "asc"
|
|
1494
|
+
});
|
|
1495
|
+
return {
|
|
1496
|
+
hasCoverage: response.hasCoverage,
|
|
1497
|
+
files: response.files.map((f) => ({
|
|
1498
|
+
path: f.path,
|
|
1499
|
+
lines: f.lines,
|
|
1500
|
+
branches: f.branches,
|
|
1501
|
+
functions: f.functions
|
|
1502
|
+
})),
|
|
1503
|
+
totalCount: response.pagination.total,
|
|
1504
|
+
message: response.message
|
|
1505
|
+
};
|
|
1274
1506
|
}
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1507
|
+
/**
|
|
1508
|
+
* Tool metadata
|
|
1509
|
+
*/
|
|
1510
|
+
const getUntestedFilesMetadata = {
|
|
1511
|
+
name: "get_untested_files",
|
|
1512
|
+
title: "Get Untested Files",
|
|
1513
|
+
description: `Get files with little or no test coverage.
|
|
1279
1514
|
|
|
1280
1515
|
Returns files sorted by coverage percentage (lowest first), filtered
|
|
1281
1516
|
to only include files below a coverage threshold.
|
|
@@ -1302,44 +1537,167 @@ To prioritize effectively, explore the codebase to understand which code is heav
|
|
|
1302
1537
|
for those specific paths.`
|
|
1303
1538
|
};
|
|
1304
1539
|
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1540
|
+
//#endregion
|
|
1541
|
+
//#region src/tools/get-upload-status.ts
|
|
1542
|
+
/**
|
|
1543
|
+
* Input schema for get_upload_status tool
|
|
1544
|
+
*/
|
|
1545
|
+
const getUploadStatusInputSchema = {
|
|
1546
|
+
projectId: z.string().describe("Project ID. Use list_projects to find project IDs."),
|
|
1547
|
+
sessionId: z.string().optional().describe("Specific upload session ID. If provided, returns detailed status for that session. Otherwise, lists recent sessions."),
|
|
1548
|
+
commitSha: z.string().optional().describe("Filter sessions by commit SHA. Useful for checking if results for a specific commit are ready."),
|
|
1549
|
+
branch: z.string().optional().describe("Filter sessions by branch name.")
|
|
1550
|
+
};
|
|
1551
|
+
/**
|
|
1552
|
+
* Output schema for get_upload_status tool
|
|
1553
|
+
*/
|
|
1554
|
+
const getUploadStatusOutputSchema = {
|
|
1555
|
+
sessions: z.array(z.object({
|
|
1556
|
+
id: z.string(),
|
|
1557
|
+
processingStatus: z.string(),
|
|
1558
|
+
commitSha: z.string().nullable(),
|
|
1559
|
+
branch: z.string().nullable(),
|
|
1560
|
+
pendingFileCount: z.number(),
|
|
1561
|
+
failedFileCount: z.number(),
|
|
1562
|
+
createdAt: z.string(),
|
|
1563
|
+
updatedAt: z.string()
|
|
1564
|
+
})).optional(),
|
|
1565
|
+
session: z.object({
|
|
1566
|
+
id: z.string(),
|
|
1567
|
+
processingStatus: z.string(),
|
|
1568
|
+
commitSha: z.string().nullable(),
|
|
1569
|
+
branch: z.string().nullable(),
|
|
1570
|
+
createdAt: z.string()
|
|
1571
|
+
}).optional(),
|
|
1572
|
+
testRuns: z.array(z.object({
|
|
1573
|
+
id: z.string(),
|
|
1574
|
+
framework: z.string().nullable(),
|
|
1575
|
+
summary: z.object({
|
|
1576
|
+
passed: z.number(),
|
|
1577
|
+
failed: z.number(),
|
|
1578
|
+
skipped: z.number(),
|
|
1579
|
+
total: z.number()
|
|
1580
|
+
}),
|
|
1581
|
+
createdAt: z.string()
|
|
1582
|
+
})).optional(),
|
|
1583
|
+
coverageReports: z.array(z.object({
|
|
1584
|
+
id: z.string(),
|
|
1585
|
+
format: z.string(),
|
|
1586
|
+
createdAt: z.string()
|
|
1587
|
+
})).optional(),
|
|
1588
|
+
pagination: z.object({
|
|
1589
|
+
total: z.number(),
|
|
1590
|
+
limit: z.number(),
|
|
1591
|
+
offset: z.number(),
|
|
1592
|
+
hasMore: z.boolean()
|
|
1593
|
+
}).optional()
|
|
1594
|
+
};
|
|
1595
|
+
/**
|
|
1596
|
+
* Execute get_upload_status tool
|
|
1597
|
+
*/
|
|
1598
|
+
async function executeGetUploadStatus(client, input) {
|
|
1599
|
+
if (input.sessionId) return client.getUploadSessionDetail({
|
|
1600
|
+
projectId: input.projectId,
|
|
1601
|
+
sessionId: input.sessionId
|
|
1602
|
+
});
|
|
1603
|
+
return client.listUploadSessions({
|
|
1604
|
+
projectId: input.projectId,
|
|
1605
|
+
commitSha: input.commitSha,
|
|
1606
|
+
branch: input.branch
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
/**
|
|
1610
|
+
* Tool metadata
|
|
1611
|
+
*/
|
|
1612
|
+
const getUploadStatusMetadata = {
|
|
1613
|
+
name: "get_upload_status",
|
|
1614
|
+
title: "Get Upload Status",
|
|
1615
|
+
description: `Check if CI results have been uploaded and processed.
|
|
1616
|
+
|
|
1617
|
+
Use this tool to answer "are my test results ready?" after pushing code.
|
|
1618
|
+
|
|
1619
|
+
Parameters:
|
|
1620
|
+
- projectId (required): The project ID
|
|
1621
|
+
- sessionId (optional): Specific upload session ID for detailed status
|
|
1622
|
+
- commitSha (optional): Filter by commit SHA to find uploads for a specific commit
|
|
1623
|
+
- branch (optional): Filter by branch name
|
|
1624
|
+
|
|
1625
|
+
Behavior:
|
|
1626
|
+
- If sessionId is provided: returns detailed status with linked test runs and coverage reports
|
|
1627
|
+
- Otherwise: returns a list of recent upload sessions (filtered by commitSha/branch if provided)
|
|
1628
|
+
|
|
1629
|
+
Processing statuses:
|
|
1630
|
+
- "pending" — upload received, processing not started
|
|
1631
|
+
- "processing" — files are being parsed
|
|
1632
|
+
- "completed" — all files processed successfully, results are ready
|
|
1633
|
+
- "error" — some files failed to process
|
|
1634
|
+
|
|
1635
|
+
Workflow:
|
|
1636
|
+
1. After pushing code, call with commitSha to find the upload session
|
|
1637
|
+
2. Check processingStatus — if "completed", results are ready
|
|
1638
|
+
3. If "processing" or "pending", wait and check again
|
|
1639
|
+
4. Once completed, use the linked testRunIds with get_test_run_details
|
|
1640
|
+
|
|
1641
|
+
Returns (list mode):
|
|
1642
|
+
- sessions: Array of upload sessions with processing status
|
|
1643
|
+
- pagination: Pagination info
|
|
1644
|
+
|
|
1645
|
+
Returns (detail mode):
|
|
1646
|
+
- session: Upload session details
|
|
1647
|
+
- testRuns: Linked test run summaries (id, framework, pass/fail counts)
|
|
1648
|
+
- coverageReports: Linked coverage report summaries (id, format)`
|
|
1310
1649
|
};
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1650
|
+
|
|
1651
|
+
//#endregion
|
|
1652
|
+
//#region src/tools/list-projects.ts
|
|
1653
|
+
/**
|
|
1654
|
+
* Input schema for list_projects tool
|
|
1655
|
+
*/
|
|
1656
|
+
const listProjectsInputSchema = {
|
|
1657
|
+
organizationId: z.string().optional().describe("Filter by organization ID (optional)"),
|
|
1658
|
+
limit: z.number().int().min(1).max(100).optional().describe("Maximum number of projects to return (default: 50)")
|
|
1659
|
+
};
|
|
1660
|
+
/**
|
|
1661
|
+
* Output schema for list_projects tool
|
|
1662
|
+
*/
|
|
1663
|
+
const listProjectsOutputSchema = {
|
|
1664
|
+
projects: z.array(z.object({
|
|
1665
|
+
id: z.string(),
|
|
1666
|
+
name: z.string(),
|
|
1667
|
+
description: z.string().nullable().optional(),
|
|
1668
|
+
organization: z.object({
|
|
1669
|
+
id: z.string(),
|
|
1670
|
+
name: z.string(),
|
|
1671
|
+
slug: z.string()
|
|
1672
|
+
})
|
|
1673
|
+
})),
|
|
1674
|
+
total: z.number()
|
|
1323
1675
|
};
|
|
1676
|
+
/**
|
|
1677
|
+
* Execute list_projects tool
|
|
1678
|
+
*/
|
|
1324
1679
|
async function executeListProjects(client, input) {
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1680
|
+
const response = await client.listProjects({
|
|
1681
|
+
organizationId: input.organizationId,
|
|
1682
|
+
limit: input.limit
|
|
1683
|
+
});
|
|
1684
|
+
return {
|
|
1685
|
+
projects: response.projects.map((p) => ({
|
|
1686
|
+
id: p.id,
|
|
1687
|
+
name: p.name,
|
|
1688
|
+
description: p.description,
|
|
1689
|
+
organization: p.organization
|
|
1690
|
+
})),
|
|
1691
|
+
total: response.pagination.total
|
|
1692
|
+
};
|
|
1338
1693
|
}
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1694
|
+
/**
|
|
1695
|
+
* Tool metadata
|
|
1696
|
+
*/
|
|
1697
|
+
const listProjectsMetadata = {
|
|
1698
|
+
name: "list_projects",
|
|
1699
|
+
title: "List Projects",
|
|
1700
|
+
description: `List all projects you have access to.
|
|
1343
1701
|
|
|
1344
1702
|
Returns a list of projects with their IDs, names, and organization info.
|
|
1345
1703
|
Use this to find project IDs for other tools like get_project_health.
|
|
@@ -1347,60 +1705,72 @@ Use this to find project IDs for other tools like get_project_health.
|
|
|
1347
1705
|
Requires a user API Key (gaf_). Get one from Account Settings in the Gaffer dashboard.`
|
|
1348
1706
|
};
|
|
1349
1707
|
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1708
|
+
//#endregion
|
|
1709
|
+
//#region src/tools/list-test-runs.ts
|
|
1710
|
+
/**
|
|
1711
|
+
* Input schema for list_test_runs tool
|
|
1712
|
+
*/
|
|
1713
|
+
const listTestRunsInputSchema = {
|
|
1714
|
+
projectId: z.string().optional().describe("Project ID to list test runs for. Required when using a user API Key (gaf_). Use list_projects to find project IDs."),
|
|
1715
|
+
commitSha: z.string().optional().describe("Filter by commit SHA (exact or prefix match)"),
|
|
1716
|
+
branch: z.string().optional().describe("Filter by branch name"),
|
|
1717
|
+
status: z.enum(["passed", "failed"]).optional().describe("Filter by status: \"passed\" (no failures) or \"failed\" (has failures)"),
|
|
1718
|
+
limit: z.number().int().min(1).max(100).optional().describe("Maximum number of test runs to return (default: 20)")
|
|
1358
1719
|
};
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1720
|
+
/**
|
|
1721
|
+
* Output schema for list_test_runs tool
|
|
1722
|
+
*/
|
|
1723
|
+
const listTestRunsOutputSchema = {
|
|
1724
|
+
testRuns: z.array(z.object({
|
|
1725
|
+
id: z.string(),
|
|
1726
|
+
commitSha: z.string().optional(),
|
|
1727
|
+
branch: z.string().optional(),
|
|
1728
|
+
passedCount: z.number(),
|
|
1729
|
+
failedCount: z.number(),
|
|
1730
|
+
skippedCount: z.number(),
|
|
1731
|
+
totalCount: z.number(),
|
|
1732
|
+
createdAt: z.string()
|
|
1733
|
+
})),
|
|
1734
|
+
pagination: z.object({
|
|
1735
|
+
total: z.number(),
|
|
1736
|
+
hasMore: z.boolean()
|
|
1737
|
+
})
|
|
1374
1738
|
};
|
|
1739
|
+
/**
|
|
1740
|
+
* Execute list_test_runs tool
|
|
1741
|
+
*/
|
|
1375
1742
|
async function executeListTestRuns(client, input) {
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1743
|
+
const response = await client.getTestRuns({
|
|
1744
|
+
projectId: input.projectId,
|
|
1745
|
+
commitSha: input.commitSha,
|
|
1746
|
+
branch: input.branch,
|
|
1747
|
+
status: input.status,
|
|
1748
|
+
limit: input.limit || 20
|
|
1749
|
+
});
|
|
1750
|
+
return {
|
|
1751
|
+
testRuns: response.testRuns.map((run) => ({
|
|
1752
|
+
id: run.id,
|
|
1753
|
+
commitSha: run.commitSha || void 0,
|
|
1754
|
+
branch: run.branch || void 0,
|
|
1755
|
+
passedCount: run.summary.passed,
|
|
1756
|
+
failedCount: run.summary.failed,
|
|
1757
|
+
skippedCount: run.summary.skipped,
|
|
1758
|
+
totalCount: run.summary.total,
|
|
1759
|
+
createdAt: run.createdAt
|
|
1760
|
+
})),
|
|
1761
|
+
pagination: {
|
|
1762
|
+
total: response.pagination.total,
|
|
1763
|
+
hasMore: response.pagination.hasMore
|
|
1764
|
+
}
|
|
1765
|
+
};
|
|
1399
1766
|
}
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1767
|
+
/**
|
|
1768
|
+
* Tool metadata
|
|
1769
|
+
*/
|
|
1770
|
+
const listTestRunsMetadata = {
|
|
1771
|
+
name: "list_test_runs",
|
|
1772
|
+
title: "List Test Runs",
|
|
1773
|
+
description: `List recent test runs for a project with optional filtering.
|
|
1404
1774
|
|
|
1405
1775
|
When using a user API Key (gaf_), you must provide a projectId.
|
|
1406
1776
|
Use list_projects first to find available project IDs.
|
|
@@ -1425,75 +1795,86 @@ Use cases:
|
|
|
1425
1795
|
- "What's the status of tests on my feature branch?"`
|
|
1426
1796
|
};
|
|
1427
1797
|
|
|
1428
|
-
|
|
1798
|
+
//#endregion
|
|
1799
|
+
//#region src/index.ts
|
|
1800
|
+
/**
|
|
1801
|
+
* Log error to stderr for observability
|
|
1802
|
+
* MCP uses stdout for communication, so stderr is safe for logging
|
|
1803
|
+
*/
|
|
1429
1804
|
function logError(toolName, error) {
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
console.error(stack);
|
|
1436
|
-
}
|
|
1805
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
1806
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
1807
|
+
const stack = error instanceof Error ? error.stack : void 0;
|
|
1808
|
+
console.error(`[${timestamp}] [gaffer-mcp] ${toolName} failed: ${message}`);
|
|
1809
|
+
if (stack) console.error(stack);
|
|
1437
1810
|
}
|
|
1811
|
+
/**
|
|
1812
|
+
* Handle tool error: log it and return MCP error response
|
|
1813
|
+
*/
|
|
1438
1814
|
function handleToolError(toolName, error) {
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1815
|
+
logError(toolName, error);
|
|
1816
|
+
return {
|
|
1817
|
+
content: [{
|
|
1818
|
+
type: "text",
|
|
1819
|
+
text: `Error: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1820
|
+
}],
|
|
1821
|
+
isError: true
|
|
1822
|
+
};
|
|
1445
1823
|
}
|
|
1824
|
+
/**
|
|
1825
|
+
* Register a tool with the MCP server using a consistent pattern.
|
|
1826
|
+
* Reduces boilerplate by handling error wrapping and response formatting.
|
|
1827
|
+
*/
|
|
1446
1828
|
function registerTool(server, client, tool) {
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
);
|
|
1829
|
+
server.registerTool(tool.metadata.name, {
|
|
1830
|
+
title: tool.metadata.title,
|
|
1831
|
+
description: tool.metadata.description,
|
|
1832
|
+
inputSchema: tool.inputSchema,
|
|
1833
|
+
outputSchema: tool.outputSchema
|
|
1834
|
+
}, async (input) => {
|
|
1835
|
+
try {
|
|
1836
|
+
const output = await tool.execute(client, input);
|
|
1837
|
+
return {
|
|
1838
|
+
content: [{
|
|
1839
|
+
type: "text",
|
|
1840
|
+
text: JSON.stringify(output, null, 2)
|
|
1841
|
+
}],
|
|
1842
|
+
structuredContent: output
|
|
1843
|
+
};
|
|
1844
|
+
} catch (error) {
|
|
1845
|
+
return handleToolError(tool.metadata.name, error);
|
|
1846
|
+
}
|
|
1847
|
+
});
|
|
1467
1848
|
}
|
|
1849
|
+
/**
|
|
1850
|
+
* Gaffer MCP Server
|
|
1851
|
+
*
|
|
1852
|
+
* Provides AI assistants with access to test history and health metrics.
|
|
1853
|
+
*
|
|
1854
|
+
* Supports two authentication modes:
|
|
1855
|
+
* 1. User API Keys (gaf_) - Read-only access to all user's projects
|
|
1856
|
+
* Set via GAFFER_API_KEY environment variable
|
|
1857
|
+
* 2. Project Upload Tokens (gfr_) - Legacy, single project access
|
|
1858
|
+
*/
|
|
1468
1859
|
async function main() {
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
process.exit(1);
|
|
1488
|
-
}
|
|
1489
|
-
const client = GafferApiClient.fromEnv();
|
|
1490
|
-
const server = new McpServer(
|
|
1491
|
-
{
|
|
1492
|
-
name: "gaffer",
|
|
1493
|
-
version: "0.1.0"
|
|
1494
|
-
},
|
|
1495
|
-
{
|
|
1496
|
-
instructions: `Gaffer provides test analytics and coverage data for your projects.
|
|
1860
|
+
if (!process.env.GAFFER_API_KEY) {
|
|
1861
|
+
console.error("Error: GAFFER_API_KEY environment variable is required");
|
|
1862
|
+
console.error("");
|
|
1863
|
+
console.error("Get your API Key from: https://app.gaffer.sh/account/api-keys");
|
|
1864
|
+
console.error("");
|
|
1865
|
+
console.error("Then configure Claude Code or Cursor with:");
|
|
1866
|
+
console.error(JSON.stringify({ mcpServers: { gaffer: {
|
|
1867
|
+
command: "npx",
|
|
1868
|
+
args: ["-y", "@gaffer-sh/mcp"],
|
|
1869
|
+
env: { GAFFER_API_KEY: "gaf_your-api-key-here" }
|
|
1870
|
+
} } }, null, 2));
|
|
1871
|
+
process.exit(1);
|
|
1872
|
+
}
|
|
1873
|
+
const client = GafferApiClient.fromEnv();
|
|
1874
|
+
const server = new McpServer({
|
|
1875
|
+
name: "gaffer",
|
|
1876
|
+
version: "0.1.0"
|
|
1877
|
+
}, { instructions: `Gaffer provides test analytics and coverage data for your projects.
|
|
1497
1878
|
|
|
1498
1879
|
## Coverage Analysis Best Practices
|
|
1499
1880
|
|
|
@@ -1511,7 +1892,7 @@ When helping users improve test coverage, combine coverage data with codebase ex
|
|
|
1511
1892
|
|
|
1512
1893
|
3. **Use path-based queries**: The get_untested_files tool may return many files of a certain type (e.g., UI components). For targeted analysis, use get_coverage_for_file with path prefixes to focus on specific areas of the codebase.
|
|
1513
1894
|
|
|
1514
|
-
4. **Iterate**: Get baseline
|
|
1895
|
+
4. **Iterate**: Get baseline → identify targets → write tests → re-check coverage after CI uploads new results.
|
|
1515
1896
|
|
|
1516
1897
|
## Finding Invisible Files
|
|
1517
1898
|
|
|
@@ -1523,97 +1904,141 @@ To find invisible files:
|
|
|
1523
1904
|
3. Compare the lists - files in local but NOT in Gaffer are invisible
|
|
1524
1905
|
4. These files need tests that actually import them
|
|
1525
1906
|
|
|
1526
|
-
Example: If get_coverage_for_file("server/api") returns user.ts, auth.ts, but Glob finds user.ts, auth.ts, billing.ts - then billing.ts is invisible and needs tests that import it
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1907
|
+
Example: If get_coverage_for_file("server/api") returns user.ts, auth.ts, but Glob finds user.ts, auth.ts, billing.ts - then billing.ts is invisible and needs tests that import it.
|
|
1908
|
+
|
|
1909
|
+
## Agentic CI / Test Failure Diagnosis
|
|
1910
|
+
|
|
1911
|
+
When helping diagnose CI failures or fix failing tests:
|
|
1912
|
+
|
|
1913
|
+
1. **Check flakiness first**: Use get_flaky_tests to identify non-deterministic tests.
|
|
1914
|
+
Skip flaky tests unless the user specifically wants to stabilize them.
|
|
1915
|
+
|
|
1916
|
+
2. **Get failure details**: Use get_test_run_details with status='failed'
|
|
1917
|
+
to see error messages and stack traces for failing tests.
|
|
1918
|
+
|
|
1919
|
+
3. **Group by root cause**: Use get_failure_clusters to see which failures
|
|
1920
|
+
share the same underlying error — fix the root cause, not individual tests.
|
|
1921
|
+
|
|
1922
|
+
4. **Check history**: Use get_test_history to understand if the failure is new
|
|
1923
|
+
(regression) or recurring (existing bug).
|
|
1924
|
+
|
|
1925
|
+
5. **Verify fixes**: After code changes, use compare_test_metrics to confirm
|
|
1926
|
+
the specific test now passes.
|
|
1927
|
+
|
|
1928
|
+
6. **Prioritize by risk**: Use find_uncovered_failure_areas to identify
|
|
1929
|
+
which failing code has the lowest test coverage — fix those first.
|
|
1930
|
+
|
|
1931
|
+
## Checking Upload Status
|
|
1932
|
+
|
|
1933
|
+
When an agent needs to know if CI results are ready:
|
|
1934
|
+
|
|
1935
|
+
1. Use get_upload_status with commitSha or branch to find upload sessions
|
|
1936
|
+
2. Check processingStatus: "completed" means results are ready, "processing" means wait
|
|
1937
|
+
3. Once completed, use the linked testRunIds to get test results` });
|
|
1938
|
+
registerTool(server, client, {
|
|
1939
|
+
metadata: getProjectHealthMetadata,
|
|
1940
|
+
inputSchema: getProjectHealthInputSchema,
|
|
1941
|
+
outputSchema: getProjectHealthOutputSchema,
|
|
1942
|
+
execute: executeGetProjectHealth
|
|
1943
|
+
});
|
|
1944
|
+
registerTool(server, client, {
|
|
1945
|
+
metadata: getTestHistoryMetadata,
|
|
1946
|
+
inputSchema: getTestHistoryInputSchema,
|
|
1947
|
+
outputSchema: getTestHistoryOutputSchema,
|
|
1948
|
+
execute: executeGetTestHistory
|
|
1949
|
+
});
|
|
1950
|
+
registerTool(server, client, {
|
|
1951
|
+
metadata: getFlakyTestsMetadata,
|
|
1952
|
+
inputSchema: getFlakyTestsInputSchema,
|
|
1953
|
+
outputSchema: getFlakyTestsOutputSchema,
|
|
1954
|
+
execute: executeGetFlakyTests
|
|
1955
|
+
});
|
|
1956
|
+
registerTool(server, client, {
|
|
1957
|
+
metadata: listTestRunsMetadata,
|
|
1958
|
+
inputSchema: listTestRunsInputSchema,
|
|
1959
|
+
outputSchema: listTestRunsOutputSchema,
|
|
1960
|
+
execute: executeListTestRuns
|
|
1961
|
+
});
|
|
1962
|
+
registerTool(server, client, {
|
|
1963
|
+
metadata: listProjectsMetadata,
|
|
1964
|
+
inputSchema: listProjectsInputSchema,
|
|
1965
|
+
outputSchema: listProjectsOutputSchema,
|
|
1966
|
+
execute: executeListProjects
|
|
1967
|
+
});
|
|
1968
|
+
registerTool(server, client, {
|
|
1969
|
+
metadata: getReportMetadata,
|
|
1970
|
+
inputSchema: getReportInputSchema,
|
|
1971
|
+
outputSchema: getReportOutputSchema,
|
|
1972
|
+
execute: executeGetReport
|
|
1973
|
+
});
|
|
1974
|
+
registerTool(server, client, {
|
|
1975
|
+
metadata: getSlowestTestsMetadata,
|
|
1976
|
+
inputSchema: getSlowestTestsInputSchema,
|
|
1977
|
+
outputSchema: getSlowestTestsOutputSchema,
|
|
1978
|
+
execute: executeGetSlowestTests
|
|
1979
|
+
});
|
|
1980
|
+
registerTool(server, client, {
|
|
1981
|
+
metadata: getTestRunDetailsMetadata,
|
|
1982
|
+
inputSchema: getTestRunDetailsInputSchema,
|
|
1983
|
+
outputSchema: getTestRunDetailsOutputSchema,
|
|
1984
|
+
execute: executeGetTestRunDetails
|
|
1985
|
+
});
|
|
1986
|
+
registerTool(server, client, {
|
|
1987
|
+
metadata: getFailureClustersMetadata,
|
|
1988
|
+
inputSchema: getFailureClustersInputSchema,
|
|
1989
|
+
outputSchema: getFailureClustersOutputSchema,
|
|
1990
|
+
execute: executeGetFailureClusters
|
|
1991
|
+
});
|
|
1992
|
+
registerTool(server, client, {
|
|
1993
|
+
metadata: compareTestMetricsMetadata,
|
|
1994
|
+
inputSchema: compareTestMetricsInputSchema,
|
|
1995
|
+
outputSchema: compareTestMetricsOutputSchema,
|
|
1996
|
+
execute: executeCompareTestMetrics
|
|
1997
|
+
});
|
|
1998
|
+
registerTool(server, client, {
|
|
1999
|
+
metadata: getCoverageSummaryMetadata,
|
|
2000
|
+
inputSchema: getCoverageSummaryInputSchema,
|
|
2001
|
+
outputSchema: getCoverageSummaryOutputSchema,
|
|
2002
|
+
execute: executeGetCoverageSummary
|
|
2003
|
+
});
|
|
2004
|
+
registerTool(server, client, {
|
|
2005
|
+
metadata: getCoverageForFileMetadata,
|
|
2006
|
+
inputSchema: getCoverageForFileInputSchema,
|
|
2007
|
+
outputSchema: getCoverageForFileOutputSchema,
|
|
2008
|
+
execute: executeGetCoverageForFile
|
|
2009
|
+
});
|
|
2010
|
+
registerTool(server, client, {
|
|
2011
|
+
metadata: findUncoveredFailureAreasMetadata,
|
|
2012
|
+
inputSchema: findUncoveredFailureAreasInputSchema,
|
|
2013
|
+
outputSchema: findUncoveredFailureAreasOutputSchema,
|
|
2014
|
+
execute: executeFindUncoveredFailureAreas
|
|
2015
|
+
});
|
|
2016
|
+
registerTool(server, client, {
|
|
2017
|
+
metadata: getUntestedFilesMetadata,
|
|
2018
|
+
inputSchema: getUntestedFilesInputSchema,
|
|
2019
|
+
outputSchema: getUntestedFilesOutputSchema,
|
|
2020
|
+
execute: executeGetUntestedFiles
|
|
2021
|
+
});
|
|
2022
|
+
registerTool(server, client, {
|
|
2023
|
+
metadata: getReportBrowserUrlMetadata,
|
|
2024
|
+
inputSchema: getReportBrowserUrlInputSchema,
|
|
2025
|
+
outputSchema: getReportBrowserUrlOutputSchema,
|
|
2026
|
+
execute: executeGetReportBrowserUrl
|
|
2027
|
+
});
|
|
2028
|
+
registerTool(server, client, {
|
|
2029
|
+
metadata: getUploadStatusMetadata,
|
|
2030
|
+
inputSchema: getUploadStatusInputSchema,
|
|
2031
|
+
outputSchema: getUploadStatusOutputSchema,
|
|
2032
|
+
execute: executeGetUploadStatus
|
|
2033
|
+
});
|
|
2034
|
+
const transport = new StdioServerTransport();
|
|
2035
|
+
await server.connect(transport);
|
|
1615
2036
|
}
|
|
1616
2037
|
main().catch((error) => {
|
|
1617
|
-
|
|
1618
|
-
|
|
2038
|
+
console.error("Fatal error:", error);
|
|
2039
|
+
process.exit(1);
|
|
1619
2040
|
});
|
|
2041
|
+
|
|
2042
|
+
//#endregion
|
|
2043
|
+
export { };
|
|
2044
|
+
//# sourceMappingURL=index.js.map
|