perfai-cloud-mcp 0.2.0 → 0.3.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.
Files changed (67) hide show
  1. package/README.md +31 -19
  2. package/dist/auth/oauthFlow.d.ts +1 -1
  3. package/dist/auth/oauthFlow.js +3 -3
  4. package/dist/auth/tokenValidator.d.ts +2 -2
  5. package/dist/auth/tokenValidator.js +3 -3
  6. package/dist/client/apiClient.d.ts +6 -4
  7. package/dist/client/apiClient.d.ts.map +1 -1
  8. package/dist/client/apiClient.js +38 -9
  9. package/dist/client/authManager.d.ts +9 -0
  10. package/dist/client/authManager.d.ts.map +1 -1
  11. package/dist/client/authManager.js +21 -0
  12. package/dist/client/types.d.ts +2 -0
  13. package/dist/client/types.d.ts.map +1 -1
  14. package/dist/config.d.ts +3 -0
  15. package/dist/config.d.ts.map +1 -1
  16. package/dist/config.js +16 -0
  17. package/dist/prompts.d.ts +31 -0
  18. package/dist/prompts.d.ts.map +1 -0
  19. package/dist/prompts.js +53 -0
  20. package/dist/server.js +29 -4
  21. package/dist/tools/index.d.ts +45 -17
  22. package/dist/tools/index.d.ts.map +1 -1
  23. package/dist/tools/protected/autoFix.d.ts +5 -1
  24. package/dist/tools/protected/autoFix.d.ts.map +1 -1
  25. package/dist/tools/protected/autoFix.js +27 -12
  26. package/dist/tools/protected/autoFixAll.d.ts +6 -2
  27. package/dist/tools/protected/autoFixAll.d.ts.map +1 -1
  28. package/dist/tools/protected/autoFixAll.js +29 -32
  29. package/dist/tools/protected/getFixSummary.d.ts +5 -1
  30. package/dist/tools/protected/getFixSummary.d.ts.map +1 -1
  31. package/dist/tools/protected/getFixSummary.js +35 -36
  32. package/dist/tools/protected/getVulnerabilities.d.ts +5 -1
  33. package/dist/tools/protected/getVulnerabilities.d.ts.map +1 -1
  34. package/dist/tools/protected/getVulnerabilities.js +7 -5
  35. package/dist/tools/protected/listApps.d.ts +1 -1
  36. package/dist/tools/protected/listApps.d.ts.map +1 -1
  37. package/dist/tools/protected/listApps.js +2 -1
  38. package/dist/tools/protected/logout.d.ts +1 -1
  39. package/dist/tools/protected/logout.js +1 -1
  40. package/dist/tools/protected/manageOrganizations.d.ts.map +1 -1
  41. package/dist/tools/protected/manageOrganizations.js +4 -5
  42. package/dist/tools/protected/registerApp.d.ts +1 -1
  43. package/dist/tools/protected/registerApp.js +3 -3
  44. package/dist/tools/protected/runSecurityTest.d.ts +5 -1
  45. package/dist/tools/protected/runSecurityTest.d.ts.map +1 -1
  46. package/dist/tools/protected/runSecurityTest.js +7 -5
  47. package/dist/tools/protected/selectApp.d.ts +1 -1
  48. package/dist/tools/protected/selectApp.d.ts.map +1 -1
  49. package/dist/tools/protected/selectApp.js +3 -1
  50. package/dist/tools/protected/vulnerabilityActions.d.ts +12 -4
  51. package/dist/tools/protected/vulnerabilityActions.d.ts.map +1 -1
  52. package/dist/tools/protected/vulnerabilityActions.js +25 -6
  53. package/dist/tools/public/authStatus.d.ts +1 -1
  54. package/dist/tools/public/authStatus.js +1 -1
  55. package/dist/tools/public/login.d.ts +12 -2
  56. package/dist/tools/public/login.d.ts.map +1 -1
  57. package/dist/tools/public/login.js +78 -86
  58. package/dist/utils/appResolver.d.ts +24 -0
  59. package/dist/utils/appResolver.d.ts.map +1 -0
  60. package/dist/utils/appResolver.js +156 -0
  61. package/dist/utils/formatters.d.ts.map +1 -1
  62. package/dist/utils/formatters.js +4 -1
  63. package/dist/utils/promptBuilder.d.ts +8 -2
  64. package/dist/utils/promptBuilder.d.ts.map +1 -1
  65. package/dist/utils/promptBuilder.js +42 -26
  66. package/package.json +7 -8
  67. package/LICENSE +0 -21
@@ -24,11 +24,11 @@ export declare const PUBLIC_TOOLS: {
24
24
  readonly properties: {
25
25
  readonly email: {
26
26
  readonly type: "string";
27
- readonly description: "PerfAI account email (optional)";
27
+ readonly description: "Perfai account email (optional)";
28
28
  };
29
29
  readonly password: {
30
30
  readonly type: "string";
31
- readonly description: "PerfAI account password (optional)";
31
+ readonly description: "Perfai account password (optional)";
32
32
  };
33
33
  };
34
34
  readonly additionalProperties: false;
@@ -36,7 +36,7 @@ export declare const PUBLIC_TOOLS: {
36
36
  };
37
37
  readonly auth_status: {
38
38
  readonly name: "auth_status";
39
- readonly description: "🔎 Check whether the server currently holds a valid PerfAI session.";
39
+ readonly description: "🔎 Check whether the server currently holds a valid Perfai session.";
40
40
  readonly inputSchema: {
41
41
  readonly type: "object";
42
42
  readonly properties: {};
@@ -47,7 +47,7 @@ export declare const PUBLIC_TOOLS: {
47
47
  export declare const PROTECTED_TOOLS: {
48
48
  readonly logout: {
49
49
  readonly name: "logout";
50
- readonly description: "🚪 Clear the current PerfAI session and selected app/task state.";
50
+ readonly description: "🚪 Clear the current Perfai session and selected app/task state.";
51
51
  readonly inputSchema: {
52
52
  readonly type: "object";
53
53
  readonly properties: {};
@@ -89,7 +89,7 @@ export declare const PROTECTED_TOOLS: {
89
89
  };
90
90
  readonly createTestAccounts: {
91
91
  readonly type: "boolean";
92
- readonly description: "Let PerfAI auto sign-up test accounts during onboarding (default: true)";
92
+ readonly description: "Let Perfai auto sign-up test accounts during onboarding (default: true)";
93
93
  };
94
94
  readonly skipEndpoints: {
95
95
  readonly type: "array";
@@ -127,7 +127,7 @@ export declare const PROTECTED_TOOLS: {
127
127
  };
128
128
  readonly list_apps: {
129
129
  readonly name: "list_apps";
130
- readonly description: "📋 List previously registered apps (GET /v1/apps). Supports search + pagination.";
130
+ readonly description: string;
131
131
  readonly inputSchema: {
132
132
  readonly type: "object";
133
133
  readonly properties: {
@@ -149,7 +149,7 @@ export declare const PROTECTED_TOOLS: {
149
149
  };
150
150
  readonly select_app: {
151
151
  readonly name: "select_app";
152
- readonly description: "🎯 Set the 'current app' for subsequent tools (run_security_test, get_vulnerabilities, etc.) by appId.";
152
+ readonly description: string;
153
153
  readonly inputSchema: {
154
154
  readonly type: "object";
155
155
  readonly properties: {
@@ -187,9 +187,13 @@ export declare const PROTECTED_TOOLS: {
187
187
  readonly inputSchema: {
188
188
  readonly type: "object";
189
189
  readonly properties: {
190
+ readonly app: {
191
+ readonly type: "string";
192
+ readonly description: string;
193
+ };
190
194
  readonly appId: {
191
195
  readonly type: "string";
192
- readonly description: "App ID (defaults to the current app)";
196
+ readonly description: "App ID (alternative to app; defaults to the current app)";
193
197
  };
194
198
  };
195
199
  readonly additionalProperties: false;
@@ -219,9 +223,13 @@ export declare const PROTECTED_TOOLS: {
219
223
  readonly inputSchema: {
220
224
  readonly type: "object";
221
225
  readonly properties: {
226
+ readonly app: {
227
+ readonly type: "string";
228
+ readonly description: string;
229
+ };
222
230
  readonly appId: {
223
231
  readonly type: "string";
224
- readonly description: "App ID (defaults to the current app)";
232
+ readonly description: "App ID (alternative to app; defaults to the current app)";
225
233
  };
226
234
  readonly search: {
227
235
  readonly type: "string";
@@ -268,9 +276,13 @@ export declare const PROTECTED_TOOLS: {
268
276
  readonly type: "string";
269
277
  readonly description: "Sequence number from get_vulnerabilities (e.g. '3') or raw vulnerability id";
270
278
  };
279
+ readonly app: {
280
+ readonly type: "string";
281
+ readonly description: string;
282
+ };
271
283
  readonly appId: {
272
284
  readonly type: "string";
273
- readonly description: "App ID (defaults to the current app)";
285
+ readonly description: "App ID (alternative to app; defaults to the current app)";
274
286
  };
275
287
  };
276
288
  readonly required: readonly ["vulnerability_id"];
@@ -283,9 +295,13 @@ export declare const PROTECTED_TOOLS: {
283
295
  readonly inputSchema: {
284
296
  readonly type: "object";
285
297
  readonly properties: {
298
+ readonly app: {
299
+ readonly type: "string";
300
+ readonly description: string;
301
+ };
286
302
  readonly appId: {
287
303
  readonly type: "string";
288
- readonly description: "App ID (defaults to the current app)";
304
+ readonly description: "App ID (alternative to app; defaults to the current app)";
289
305
  };
290
306
  readonly severity: {
291
307
  readonly type: "string";
@@ -294,7 +310,7 @@ export declare const PROTECTED_TOOLS: {
294
310
  };
295
311
  readonly max_fixes: {
296
312
  readonly type: "number";
297
- readonly description: "Maximum number of fixes to include (default: all)";
313
+ readonly description: "Fix only the N most severe open vulnerabilities (default: all)";
298
314
  };
299
315
  };
300
316
  readonly additionalProperties: false;
@@ -306,9 +322,13 @@ export declare const PROTECTED_TOOLS: {
306
322
  readonly inputSchema: {
307
323
  readonly type: "object";
308
324
  readonly properties: {
325
+ readonly app: {
326
+ readonly type: "string";
327
+ readonly description: string;
328
+ };
309
329
  readonly appId: {
310
330
  readonly type: "string";
311
- readonly description: "App ID (defaults to the current app)";
331
+ readonly description: "App ID (alternative to app; defaults to the current app)";
312
332
  };
313
333
  };
314
334
  readonly additionalProperties: false;
@@ -316,10 +336,13 @@ export declare const PROTECTED_TOOLS: {
316
336
  };
317
337
  readonly dismiss_vulnerability: {
318
338
  readonly name: "dismiss_vulnerability";
319
- readonly description: "🙈 Dismiss a finding as a false positive / won't-fix (POST /v1/vulnerabilities/{id}/dismiss).";
339
+ readonly description: string;
320
340
  readonly inputSchema: {
321
- readonly type: "object";
322
341
  readonly properties: {
342
+ readonly reason: {
343
+ readonly type: "string";
344
+ readonly description: string;
345
+ };
323
346
  readonly vulnerability_id: {
324
347
  readonly type: "string";
325
348
  readonly description: "Sequence number from get_vulnerabilities (e.g. '3') or raw vulnerability id";
@@ -329,6 +352,7 @@ export declare const PROTECTED_TOOLS: {
329
352
  readonly description: "App ID (defaults to the current app)";
330
353
  };
331
354
  };
355
+ readonly type: "object";
332
356
  readonly required: readonly ["vulnerability_id"];
333
357
  readonly additionalProperties: false;
334
358
  };
@@ -354,10 +378,13 @@ export declare const PROTECTED_TOOLS: {
354
378
  };
355
379
  readonly mark_vulnerability_fixed: {
356
380
  readonly name: "mark_vulnerability_fixed";
357
- readonly description: "✅ Mark a finding as fixed after applying the suggested fix (POST /v1/vulnerabilities/{id}/fix).";
381
+ readonly description: string;
358
382
  readonly inputSchema: {
359
- readonly type: "object";
360
383
  readonly properties: {
384
+ readonly comment: {
385
+ readonly type: "string";
386
+ readonly description: "Optional short note on what was changed";
387
+ };
361
388
  readonly vulnerability_id: {
362
389
  readonly type: "string";
363
390
  readonly description: "Sequence number from get_vulnerabilities (e.g. '3') or raw vulnerability id";
@@ -367,6 +394,7 @@ export declare const PROTECTED_TOOLS: {
367
394
  readonly description: "App ID (defaults to the current app)";
368
395
  };
369
396
  };
397
+ readonly type: "object";
370
398
  readonly required: readonly ["vulnerability_id"];
371
399
  readonly additionalProperties: false;
372
400
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAkB,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,EAAc,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAA2B,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AACxG,OAAO,EAAmB,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAsB,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACzF,OAAO,EAAgB,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAiB,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAA4B,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAC3G,OAAO,EAAuB,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5F,OAAO,EAAuB,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5F,OAAO,EAA0B,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AACrG,OAAO,EAAkB,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAe,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAkB,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAqB,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,EAEL,0BAA0B,EAE1B,yBAAyB,EAEzB,4BAA4B,EAC7B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d,eAAe,EACf,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,0BAA0B,EAC1B,yBAAyB,EACzB,4BAA4B,GAC7B,CAAC"}
@@ -9,9 +9,13 @@ export declare const autoFixTool: {
9
9
  readonly type: "string";
10
10
  readonly description: "Sequence number from get_vulnerabilities (e.g. '3') or raw vulnerability id";
11
11
  };
12
+ readonly app: {
13
+ readonly type: "string";
14
+ readonly description: string;
15
+ };
12
16
  readonly appId: {
13
17
  readonly type: "string";
14
- readonly description: "App ID (defaults to the current app)";
18
+ readonly description: "App ID (alternative to app; defaults to the current app)";
15
19
  };
16
20
  };
17
21
  readonly required: readonly ["vulnerability_id"];
@@ -1 +1 @@
1
- {"version":3,"file":"autoFix.d.ts","sourceRoot":"","sources":["../../../src/tools/protected/autoFix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG1D,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;CAsBd,CAAC;AAEX,wBAAsB,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CA8C9E"}
1
+ {"version":3,"file":"autoFix.d.ts","sourceRoot":"","sources":["../../../src/tools/protected/autoFix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAM1D,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;CAuBd,CAAC;AAEX,wBAAsB,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAuD9E"}
@@ -1,3 +1,5 @@
1
+ import { getAllVulnerabilities } from "../../client/apiClient.js";
2
+ import { APP_NAME_PROPERTY, resolveApp } from "../../utils/appResolver.js";
1
3
  import { buildAutoFixInstruction } from "../../utils/promptBuilder.js";
2
4
  export const autoFixTool = {
3
5
  name: "auto_fix",
@@ -12,9 +14,10 @@ export const autoFixTool = {
12
14
  type: "string",
13
15
  description: "Sequence number from get_vulnerabilities (e.g. '3') or raw vulnerability id",
14
16
  },
17
+ app: APP_NAME_PROPERTY,
15
18
  appId: {
16
19
  type: "string",
17
- description: "App ID (defaults to the current app)",
20
+ description: "App ID (alternative to app; defaults to the current app)",
18
21
  },
19
22
  },
20
23
  required: ["vulnerability_id"],
@@ -22,32 +25,45 @@ export const autoFixTool = {
22
25
  },
23
26
  };
24
27
  export async function handleAutoFix(auth, args) {
25
- const appId = args?.appId ?? auth.currentAppId;
26
- if (!appId) {
28
+ if (!args?.vulnerability_id) {
27
29
  return {
28
- content: [{ type: "text", text: "❌ No app selected. Run register_app or select_app first." }],
30
+ content: [{ type: "text", text: "❌ vulnerability_id is required." }],
29
31
  };
30
32
  }
31
- if (!args?.vulnerability_id) {
33
+ let appLabel;
34
+ let vuln;
35
+ try {
36
+ const resolved = await resolveApp(auth, args);
37
+ if (!resolved.ok)
38
+ return { content: [{ type: "text", text: resolved.message }] };
39
+ const { appId } = resolved.app;
40
+ appLabel = resolved.app.label;
41
+ vuln = auth.getCachedVulnerability(appId, args.vulnerability_id);
42
+ if (!vuln) {
43
+ // Fresh session (e.g. the user named the app directly) — load findings instead of failing.
44
+ auth.cacheVulnerabilities(appId, await getAllVulnerabilities(auth, appId));
45
+ vuln = auth.getCachedVulnerability(appId, args.vulnerability_id);
46
+ }
47
+ }
48
+ catch (error) {
32
49
  return {
33
- content: [{ type: "text", text: "❌ vulnerability_id is required." }],
50
+ content: [{ type: "text", text: `❌ Failed to fetch vulnerabilities: ${error instanceof Error ? error.message : String(error)}` }],
34
51
  };
35
52
  }
36
- const vuln = auth.getCachedVulnerability(appId, args.vulnerability_id);
37
53
  if (!vuln) {
38
54
  return {
39
55
  content: [
40
56
  {
41
57
  type: "text",
42
- text: `❌ Could not find "${args.vulnerability_id}" in the last get_vulnerabilities listing ` +
43
- `for this app. Run get_vulnerabilities first, then reference the # it shows.`,
58
+ text: `❌ Could not find vulnerability "${args.vulnerability_id}" for "${appLabel}". ` +
59
+ `Run get_vulnerabilities to see the numbered list.`,
44
60
  },
45
61
  ],
46
62
  };
47
63
  }
48
- if (vuln.isFixed) {
64
+ if (vuln.isFixed || vuln.fixClaimed) {
49
65
  return {
50
- content: [{ type: "text", text: `✅ Vulnerability #${args.vulnerability_id} is already marked as fixed.` }],
66
+ content: [{ type: "text", text: `✅ Vulnerability #${args.vulnerability_id} is already ${vuln.isFixed ? "fixed" : "claimed fixed (pending re-scan)"}.` }],
51
67
  };
52
68
  }
53
69
  if (vuln.isDismissed) {
@@ -57,7 +73,6 @@ export async function handleAutoFix(auth, args) {
57
73
  }
58
74
  const seq = Number(args.vulnerability_id);
59
75
  const sequence = Number.isInteger(seq) && seq > 0 ? seq : 1;
60
- const appLabel = auth.currentAppUrl ?? appId;
61
76
  return {
62
77
  content: [{ type: "text", text: buildAutoFixInstruction(appLabel, vuln, sequence) }],
63
78
  };
@@ -5,9 +5,13 @@ export declare const autoFixAllTool: {
5
5
  readonly inputSchema: {
6
6
  readonly type: "object";
7
7
  readonly properties: {
8
+ readonly app: {
9
+ readonly type: "string";
10
+ readonly description: string;
11
+ };
8
12
  readonly appId: {
9
13
  readonly type: "string";
10
- readonly description: "App ID (defaults to the current app)";
14
+ readonly description: "App ID (alternative to app; defaults to the current app)";
11
15
  };
12
16
  readonly severity: {
13
17
  readonly type: "string";
@@ -16,7 +20,7 @@ export declare const autoFixAllTool: {
16
20
  };
17
21
  readonly max_fixes: {
18
22
  readonly type: "number";
19
- readonly description: "Maximum number of fixes to include (default: all)";
23
+ readonly description: "Fix only the N most severe open vulnerabilities (default: all)";
20
24
  };
21
25
  };
22
26
  readonly additionalProperties: false;
@@ -1 +1 @@
1
- {"version":3,"file":"autoFixAll.d.ts","sourceRoot":"","sources":["../../../src/tools/protected/autoFixAll.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAI1D,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;CA0BjB,CAAC;AAEX,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAyDjF"}
1
+ {"version":3,"file":"autoFixAll.d.ts","sourceRoot":"","sources":["../../../src/tools/protected/autoFixAll.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAM1D,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BjB,CAAC;AAEX,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CA8CjF"}
@@ -1,17 +1,24 @@
1
- import { getVulnerabilities } from "../../client/apiClient.js";
2
- import { buildBatchFixPlan } from "../../utils/promptBuilder.js";
1
+ import { getAllVulnerabilities } from "../../client/apiClient.js";
2
+ import { FIX_BATCH_SIZE } from "../../config.js";
3
+ import { APP_NAME_PROPERTY, resolveApp } from "../../utils/appResolver.js";
4
+ import { buildBatchFixPlan, isOpen, sortBySeverity } from "../../utils/promptBuilder.js";
3
5
  export const autoFixAllTool = {
4
6
  name: "auto_fix_all",
5
- description: "🔧 Auto-fix ALL unfixed vulnerabilities for the current app. Fetches every vulnerability, " +
6
- "builds a prioritized fix plan (critical → low), and returns structured step-by-step " +
7
- "instructions for each. You (the AI assistant) should execute each fix in order, then call " +
8
- "mark_vulnerability_fixed for each one after applying the code change.",
7
+ description: "🔧 ONE-CALL FIX. When the user says \"<App> fix all\", \"<App> fix critical\" or \"<App> fix 3\" " +
8
+ "(e.g. \"Bookstore fix all\"), call this tool directly with app: \"<App>\" — do NOT call login, list_apps, " +
9
+ "select_app or manage_organizations first; sign-in happens automatically and the name is resolved " +
10
+ "across all of the user's orgs. " +
11
+ "\"fix all\" → no filter; \"fix critical|high|medium|low\" → severity; \"fix N\" → max_fixes: N " +
12
+ "(the N most severe). Returns a prioritized plan (critical → low) that you execute autonomously: " +
13
+ "fix each finding and call mark_vulnerability_fixed, or — if it does not apply to the code — " +
14
+ "silently call dismiss_vulnerability with a specific reason.",
9
15
  inputSchema: {
10
16
  type: "object",
11
17
  properties: {
18
+ app: APP_NAME_PROPERTY,
12
19
  appId: {
13
20
  type: "string",
14
- description: "App ID (defaults to the current app)",
21
+ description: "App ID (alternative to app; defaults to the current app)",
15
22
  },
16
23
  severity: {
17
24
  type: "string",
@@ -20,35 +27,23 @@ export const autoFixAllTool = {
20
27
  },
21
28
  max_fixes: {
22
29
  type: "number",
23
- description: "Maximum number of fixes to include (default: all)",
30
+ description: "Fix only the N most severe open vulnerabilities (default: all)",
24
31
  },
25
32
  },
26
33
  additionalProperties: false,
27
34
  },
28
35
  };
29
36
  export async function handleAutoFixAll(auth, args) {
30
- const appId = args?.appId ?? auth.currentAppId;
31
- if (!appId) {
32
- return {
33
- content: [{ type: "text", text: "❌ No app selected. Run register_app or select_app first." }],
34
- };
35
- }
36
37
  try {
37
- // Fetch all vulnerabilities (paginate through all pages)
38
- let allVulnerabilities = [];
39
- let page = 1;
40
- const pageSize = 100;
41
- while (true) {
42
- const result = await getVulnerabilities(auth, appId, { page, pageSize });
43
- allVulnerabilities = allVulnerabilities.concat(result.data);
44
- if (allVulnerabilities.length >= result.total)
45
- break;
46
- page++;
47
- }
48
- // Cache them for mark_vulnerability_fixed calls later
38
+ const resolved = await resolveApp(auth, args);
39
+ if (!resolved.ok)
40
+ return { content: [{ type: "text", text: resolved.message }] };
41
+ const { appId, label } = resolved.app;
42
+ const allVulnerabilities = await getAllVulnerabilities(auth, appId);
43
+ // Cache them for mark_vulnerability_fixed / dismiss_vulnerability calls later
49
44
  auth.cacheVulnerabilities(appId, allVulnerabilities);
50
- // Apply filters
51
- let toFix = allVulnerabilities.filter(v => !v.isFixed && !v.isDismissed);
45
+ // Sort before limiting, so "fix 1" means the most severe open finding.
46
+ let toFix = sortBySeverity(allVulnerabilities.filter(isOpen));
52
47
  if (args?.severity) {
53
48
  const target = args.severity.toLowerCase();
54
49
  toFix = toFix.filter(v => (v.severity ?? "").toLowerCase() === target);
@@ -58,12 +53,14 @@ export async function handleAutoFixAll(auth, args) {
58
53
  }
59
54
  if (toFix.length === 0) {
60
55
  const msg = args?.severity
61
- ? `✅ No unfixed ${args.severity} vulnerabilities found.`
62
- : "✅ No unfixed vulnerabilities found. All issues are either fixed or dismissed.";
56
+ ? `✅ No open ${args.severity} vulnerabilities for "${label}".`
57
+ : `✅ No open vulnerabilities for "${label}" — everything is fixed, claimed fixed, or dismissed.`;
63
58
  return { content: [{ type: "text", text: msg }] };
64
59
  }
65
- const appLabel = auth.currentAppUrl ?? appId;
66
- const plan = buildBatchFixPlan(appLabel, toFix);
60
+ // Large apps are returned in batches so one response never blows the client's
61
+ // tool-output limit; handled items drop out of isOpen, so the next call is the next batch.
62
+ const batch = toFix.slice(0, FIX_BATCH_SIZE);
63
+ const plan = buildBatchFixPlan(label, batch, toFix.length - batch.length);
67
64
  return { content: [{ type: "text", text: plan }] };
68
65
  }
69
66
  catch (error) {
@@ -5,9 +5,13 @@ export declare const getFixSummaryTool: {
5
5
  readonly inputSchema: {
6
6
  readonly type: "object";
7
7
  readonly properties: {
8
+ readonly app: {
9
+ readonly type: "string";
10
+ readonly description: string;
11
+ };
8
12
  readonly appId: {
9
13
  readonly type: "string";
10
- readonly description: "App ID (defaults to the current app)";
14
+ readonly description: "App ID (alternative to app; defaults to the current app)";
11
15
  };
12
16
  };
13
17
  readonly additionalProperties: false;
@@ -1 +1 @@
1
- {"version":3,"file":"getFixSummary.d.ts","sourceRoot":"","sources":["../../../src/tools/protected/getFixSummary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG1D,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;CAgBpB,CAAC;AASX,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAuEpF"}
1
+ {"version":3,"file":"getFixSummary.d.ts","sourceRoot":"","sources":["../../../src/tools/protected/getFixSummary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAM1D,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;CAgBpB,CAAC;AAaX,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAgEpF"}
@@ -1,15 +1,17 @@
1
- import { getVulnerabilities } from "../../client/apiClient.js";
1
+ import { getAllVulnerabilities } from "../../client/apiClient.js";
2
+ import { APP_NAME_PROPERTY, resolveApp } from "../../utils/appResolver.js";
3
+ import { isOpen } from "../../utils/promptBuilder.js";
2
4
  export const getFixSummaryTool = {
3
5
  name: "get_fix_summary",
4
- description: "📊 Show a summary of vulnerability fix progress for the current app — how many are " +
5
- "fixed, unfixed, dismissed, broken down by severity. Use after running auto_fix / auto_fix_all " +
6
- "to verify progress.",
6
+ description: "📊 Show fix progress for an app — fixed, skipped as not applicable (dismissed), and still open, " +
7
+ "broken down by severity. Call it at the end of an auto_fix_all run and report its one-line counts.",
7
8
  inputSchema: {
8
9
  type: "object",
9
10
  properties: {
11
+ app: APP_NAME_PROPERTY,
10
12
  appId: {
11
13
  type: "string",
12
- description: "App ID (defaults to the current app)",
14
+ description: "App ID (alternative to app; defaults to the current app)",
13
15
  },
14
16
  },
15
17
  additionalProperties: false,
@@ -21,59 +23,56 @@ const SEVERITY_ICON = {
21
23
  medium: "🟡",
22
24
  low: "🟢",
23
25
  };
26
+ // A fix claim counts as fixed here; it is confirmed (isFixed) or dropped by the next scan.
27
+ const isFixedOrClaimed = (v) => Boolean(v.isFixed || v.fixClaimed);
28
+ const isSkipped = (v) => Boolean(v.isDismissed && !isFixedOrClaimed(v));
24
29
  export async function handleGetFixSummary(auth, args) {
25
- const appId = args?.appId ?? auth.currentAppId;
26
- if (!appId) {
27
- return {
28
- content: [{ type: "text", text: "❌ No app selected. Run register_app or select_app first." }],
29
- };
30
- }
31
30
  try {
32
- let allVulnerabilities = [];
33
- let page = 1;
34
- const pageSize = 100;
35
- while (true) {
36
- const result = await getVulnerabilities(auth, appId, { page, pageSize });
37
- allVulnerabilities = allVulnerabilities.concat(result.data);
38
- if (allVulnerabilities.length >= result.total)
39
- break;
40
- page++;
41
- }
31
+ const resolved = await resolveApp(auth, args);
32
+ if (!resolved.ok)
33
+ return { content: [{ type: "text", text: resolved.message }] };
34
+ const { appId, label } = resolved.app;
35
+ const allVulnerabilities = await getAllVulnerabilities(auth, appId);
42
36
  const total = allVulnerabilities.length;
43
37
  if (total === 0) {
44
- return { content: [{ type: "text", text: "No vulnerabilities found for this app." }] };
38
+ return { content: [{ type: "text", text: `No vulnerabilities found for "${label}".` }] };
45
39
  }
46
- const fixed = allVulnerabilities.filter(v => v.isFixed);
47
- const dismissed = allVulnerabilities.filter(v => v.isDismissed && !v.isFixed);
48
- const unfixed = allVulnerabilities.filter(v => !v.isFixed && !v.isDismissed);
40
+ const fixed = allVulnerabilities.filter(isFixedOrClaimed);
41
+ const pendingRescan = allVulnerabilities.filter(v => v.fixClaimed && !v.isFixed);
42
+ const skipped = allVulnerabilities.filter(isSkipped);
43
+ const open = allVulnerabilities.filter(isOpen);
49
44
  // Breakdown by severity
50
45
  const severities = ["critical", "high", "medium", "low"];
51
46
  const breakdownRows = severities
52
47
  .map(s => {
53
48
  const icon = SEVERITY_ICON[s] ?? "⚪";
54
49
  const all = allVulnerabilities.filter(v => (v.severity ?? "").toLowerCase() === s);
55
- const f = all.filter(v => v.isFixed).length;
56
- const d = all.filter(v => v.isDismissed && !v.isFixed).length;
57
- const u = all.filter(v => !v.isFixed && !v.isDismissed).length;
58
50
  if (all.length === 0)
59
51
  return null;
60
- return `| ${icon} ${s.charAt(0).toUpperCase() + s.slice(1)} | ${all.length} | ${f} | ${u} | ${d} |`;
52
+ const f = all.filter(isFixedOrClaimed).length;
53
+ const d = all.filter(isSkipped).length;
54
+ const o = all.filter(isOpen).length;
55
+ return `| ${icon} ${s.charAt(0).toUpperCase() + s.slice(1)} | ${all.length} | ${f} | ${d} | ${o} |`;
61
56
  })
62
57
  .filter(Boolean)
63
58
  .join("\n");
64
- const pct = total > 0 ? Math.round((fixed.length / total) * 100) : 0;
59
+ const pct = Math.round((fixed.length / total) * 100);
65
60
  const progressBar = "█".repeat(Math.round(pct / 5)) + "░".repeat(20 - Math.round(pct / 5));
66
- let summary = `# Fix Progress: ${auth.currentAppUrl ?? appId}\n\n`;
61
+ let summary = `# Fix Progress: ${label}\n\n`;
62
+ summary += `**${fixed.length} fixed, ${skipped.length} skipped as not applicable, ${open.length} still open.**\n\n`;
67
63
  summary += `\`${progressBar}\` **${pct}%** (${fixed.length}/${total} fixed)\n\n`;
68
- summary += `| Severity | Total | Fixed | Unfixed | Dismissed |\n`;
64
+ summary += `| Severity | Total | Fixed | Skipped | Open |\n`;
69
65
  summary += `| --- | --- | --- | --- | --- |\n`;
70
66
  summary += breakdownRows + "\n";
71
- summary += `| **Total** | **${total}** | **${fixed.length}** | **${unfixed.length}** | **${dismissed.length}** |\n\n`;
72
- if (unfixed.length > 0) {
73
- summary += `**${unfixed.length} vulnerabilities still need fixing.** Run \`auto_fix_all\` to get fix instructions for all remaining issues.\n`;
67
+ summary += `| **Total** | **${total}** | **${fixed.length}** | **${skipped.length}** | **${open.length}** |\n\n`;
68
+ if (pendingRescan.length > 0) {
69
+ summary += `${pendingRescan.length} of the fixed are claimed fixes — the next security test confirms them.\n`;
70
+ }
71
+ if (open.length > 0) {
72
+ summary += `**${open.length} vulnerabilities still need fixing.** Run \`auto_fix_all\` to continue.\n`;
74
73
  }
75
74
  else {
76
- summary += `✅ **All vulnerabilities are resolved!**\n`;
75
+ summary += `✅ **Nothing left to fix.**\n`;
77
76
  }
78
77
  return { content: [{ type: "text", text: summary }] };
79
78
  }
@@ -5,9 +5,13 @@ export declare const getVulnerabilitiesTool: {
5
5
  readonly inputSchema: {
6
6
  readonly type: "object";
7
7
  readonly properties: {
8
+ readonly app: {
9
+ readonly type: "string";
10
+ readonly description: string;
11
+ };
8
12
  readonly appId: {
9
13
  readonly type: "string";
10
- readonly description: "App ID (defaults to the current app)";
14
+ readonly description: "App ID (alternative to app; defaults to the current app)";
11
15
  };
12
16
  readonly search: {
13
17
  readonly type: "string";
@@ -1 +1 @@
1
- {"version":3,"file":"getVulnerabilities.d.ts","sourceRoot":"","sources":["../../../src/tools/protected/getVulnerabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAI1D,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;CAezB,CAAC;AAEX,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAyBzF"}
1
+ {"version":3,"file":"getVulnerabilities.d.ts","sourceRoot":"","sources":["../../../src/tools/protected/getVulnerabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAK1D,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgBzB,CAAC;AAEX,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAwBzF"}
@@ -1,4 +1,5 @@
1
1
  import { getVulnerabilities } from "../../client/apiClient.js";
2
+ import { APP_NAME_PROPERTY, resolveApp } from "../../utils/appResolver.js";
2
3
  import { formatVulnerabilityList } from "../../utils/formatters.js";
3
4
  export const getVulnerabilitiesTool = {
4
5
  name: "get_vulnerabilities",
@@ -7,7 +8,8 @@ export const getVulnerabilitiesTool = {
7
8
  inputSchema: {
8
9
  type: "object",
9
10
  properties: {
10
- appId: { type: "string", description: "App ID (defaults to the current app)" },
11
+ app: APP_NAME_PROPERTY,
12
+ appId: { type: "string", description: "App ID (alternative to app; defaults to the current app)" },
11
13
  search: { type: "string", description: "Case-insensitive keyword search" },
12
14
  page: { type: "number", description: "Page number (default 1)" },
13
15
  pageSize: { type: "number", description: "Results per page, 1-100 (default 20)" },
@@ -16,11 +18,11 @@ export const getVulnerabilitiesTool = {
16
18
  },
17
19
  };
18
20
  export async function handleGetVulnerabilities(auth, args) {
19
- const appId = args?.appId ?? auth.currentAppId;
20
- if (!appId) {
21
- return { content: [{ type: "text", text: "❌ No app selected. Run register_app or select_app first." }] };
22
- }
23
21
  try {
22
+ const resolved = await resolveApp(auth, args);
23
+ if (!resolved.ok)
24
+ return { content: [{ type: "text", text: resolved.message }] };
25
+ const { appId } = resolved.app;
24
26
  const result = await getVulnerabilities(auth, appId, {
25
27
  page: args?.page,
26
28
  pageSize: args?.pageSize,
@@ -1,7 +1,7 @@
1
1
  import { AuthManager } from "../../client/authManager.js";
2
2
  export declare const listAppsTool: {
3
3
  readonly name: "list_apps";
4
- readonly description: "📋 List previously registered apps (GET /v1/apps). Supports search + pagination.";
4
+ readonly description: string;
5
5
  readonly inputSchema: {
6
6
  readonly type: "object";
7
7
  readonly properties: {
@@ -1 +1 @@
1
- {"version":3,"file":"listApps.d.ts","sourceRoot":"","sources":["../../../src/tools/protected/listApps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAI1D,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;CAYf,CAAC;AAEX,wBAAsB,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAe/E"}
1
+ {"version":3,"file":"listApps.d.ts","sourceRoot":"","sources":["../../../src/tools/protected/listApps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAI1D,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;CAcf,CAAC;AAEX,wBAAsB,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAe/E"}