perfai-cloud-mcp 0.1.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 +243 -0
- package/dist/auth/oauthFlow.d.ts +23 -0
- package/dist/auth/oauthFlow.d.ts.map +1 -0
- package/dist/auth/oauthFlow.js +174 -0
- package/dist/auth/pkce.d.ts +11 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +17 -0
- package/dist/auth/tokenValidator.d.ts +40 -0
- package/dist/auth/tokenValidator.d.ts.map +1 -0
- package/dist/auth/tokenValidator.js +117 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +387 -0
- package/dist/client/apiClient.d.ts +27 -0
- package/dist/client/apiClient.d.ts.map +1 -0
- package/dist/client/apiClient.js +81 -0
- package/dist/client/authManager.d.ts +42 -0
- package/dist/client/authManager.d.ts.map +1 -0
- package/dist/client/authManager.js +136 -0
- package/dist/client/errors.d.ts +10 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +29 -0
- package/dist/client/types.d.ts +54 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +1 -0
- package/dist/config.d.ts +23 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +50 -0
- package/dist/env.d.ts +2 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +8 -0
- package/dist/log-guard.d.ts +2 -0
- package/dist/log-guard.d.ts.map +1 -0
- package/dist/log-guard.js +17 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +370 -0
- package/dist/tools/index.d.ts +352 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +39 -0
- package/dist/tools/protected/autoFix.d.ts +22 -0
- package/dist/tools/protected/autoFix.d.ts.map +1 -0
- package/dist/tools/protected/autoFix.js +64 -0
- package/dist/tools/protected/autoFixAll.d.ts +26 -0
- package/dist/tools/protected/autoFixAll.d.ts.map +1 -0
- package/dist/tools/protected/autoFixAll.js +79 -0
- package/dist/tools/protected/checkAppStatus.d.ts +21 -0
- package/dist/tools/protected/checkAppStatus.d.ts.map +1 -0
- package/dist/tools/protected/checkAppStatus.js +57 -0
- package/dist/tools/protected/checkTaskStatus.d.ts +21 -0
- package/dist/tools/protected/checkTaskStatus.d.ts.map +1 -0
- package/dist/tools/protected/checkTaskStatus.js +53 -0
- package/dist/tools/protected/getFixSummary.d.ts +17 -0
- package/dist/tools/protected/getFixSummary.d.ts.map +1 -0
- package/dist/tools/protected/getFixSummary.js +90 -0
- package/dist/tools/protected/getVulnerabilities.d.ts +29 -0
- package/dist/tools/protected/getVulnerabilities.d.ts.map +1 -0
- package/dist/tools/protected/getVulnerabilities.js +41 -0
- package/dist/tools/protected/listApps.d.ts +25 -0
- package/dist/tools/protected/listApps.d.ts.map +1 -0
- package/dist/tools/protected/listApps.js +32 -0
- package/dist/tools/protected/logout.d.ts +12 -0
- package/dist/tools/protected/logout.d.ts.map +1 -0
- package/dist/tools/protected/logout.js +9 -0
- package/dist/tools/protected/registerApp.d.ts +33 -0
- package/dist/tools/protected/registerApp.d.ts.map +1 -0
- package/dist/tools/protected/registerApp.js +96 -0
- package/dist/tools/protected/runSecurityTest.d.ts +17 -0
- package/dist/tools/protected/runSecurityTest.d.ts.map +1 -0
- package/dist/tools/protected/runSecurityTest.js +48 -0
- package/dist/tools/protected/selectApp.d.ts +18 -0
- package/dist/tools/protected/selectApp.d.ts.map +1 -0
- package/dist/tools/protected/selectApp.js +29 -0
- package/dist/tools/protected/submitAppCredentials.d.ts +22 -0
- package/dist/tools/protected/submitAppCredentials.d.ts.map +1 -0
- package/dist/tools/protected/submitAppCredentials.js +43 -0
- package/dist/tools/protected/suggestFix.d.ts +22 -0
- package/dist/tools/protected/suggestFix.d.ts.map +1 -0
- package/dist/tools/protected/suggestFix.js +37 -0
- package/dist/tools/protected/vulnerabilityActions.d.ts +62 -0
- package/dist/tools/protected/vulnerabilityActions.d.ts.map +1 -0
- package/dist/tools/protected/vulnerabilityActions.js +69 -0
- package/dist/tools/public/authStatus.d.ts +12 -0
- package/dist/tools/public/authStatus.d.ts.map +1 -0
- package/dist/tools/public/authStatus.js +13 -0
- package/dist/tools/public/login.d.ts +21 -0
- package/dist/tools/public/login.d.ts.map +1 -0
- package/dist/tools/public/login.js +305 -0
- package/dist/utils/formatters.d.ts +7 -0
- package/dist/utils/formatters.d.ts.map +1 -0
- package/dist/utils/formatters.js +47 -0
- package/dist/utils/poll.d.ts +19 -0
- package/dist/utils/poll.d.ts.map +1 -0
- package/dist/utils/poll.js +32 -0
- package/dist/utils/promptBuilder.d.ts +20 -0
- package/dist/utils/promptBuilder.d.ts.map +1 -0
- package/dist/utils/promptBuilder.js +131 -0
- package/package.json +55 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { getApp } from "../../client/apiClient.js";
|
|
2
|
+
import { formatApp } from "../../utils/formatters.js";
|
|
3
|
+
import { pollWithBudget } from "../../utils/poll.js";
|
|
4
|
+
import { APP_TERMINAL_STATES, DEFAULT_TOOL_POLL_BUDGET_MS, MAX_TOOL_POLL_BUDGET_MS, POLL_START_MS, POLL_MAX_INTERVAL_MS } from "../../config.js";
|
|
5
|
+
export const checkAppStatusTool = {
|
|
6
|
+
name: "check_app_status",
|
|
7
|
+
description: "⏳ Poll GET /v1/apps/{appId} for registration status. Polls in-process (5s→60s backoff) for up " +
|
|
8
|
+
"to wait_seconds before returning — call again if it comes back still pending. Stops early on " +
|
|
9
|
+
"COMPLETED, FAILED, or AWAITING_INPUT (needs submit_app_credentials).",
|
|
10
|
+
inputSchema: {
|
|
11
|
+
type: "object",
|
|
12
|
+
properties: {
|
|
13
|
+
appId: { type: "string", description: "App ID (defaults to the most recently registered/selected app)" },
|
|
14
|
+
wait_seconds: {
|
|
15
|
+
type: "number",
|
|
16
|
+
description: "Max seconds to poll before returning current status (default 20, max 240)",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
additionalProperties: false,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export async function handleCheckAppStatus(auth, args) {
|
|
23
|
+
const appId = args?.appId ?? auth.currentAppId;
|
|
24
|
+
if (!appId) {
|
|
25
|
+
return { content: [{ type: "text", text: "❌ No app selected. Run register_app or select_app first." }] };
|
|
26
|
+
}
|
|
27
|
+
const budgetMs = Math.min((args?.wait_seconds ? args.wait_seconds * 1000 : DEFAULT_TOOL_POLL_BUDGET_MS), MAX_TOOL_POLL_BUDGET_MS);
|
|
28
|
+
try {
|
|
29
|
+
const { value: app, terminal } = await pollWithBudget({
|
|
30
|
+
fetch: () => getApp(auth, appId),
|
|
31
|
+
isTerminal: (a) => APP_TERMINAL_STATES.has(a.registrationStatus ?? "") || a.registrationStatus === "AWAITING_INPUT",
|
|
32
|
+
budgetMs,
|
|
33
|
+
startIntervalMs: POLL_START_MS,
|
|
34
|
+
maxIntervalMs: POLL_MAX_INTERVAL_MS,
|
|
35
|
+
});
|
|
36
|
+
auth.setCurrentApp(app.appId, app.appUrl ?? auth.currentAppUrl);
|
|
37
|
+
let hint = "";
|
|
38
|
+
if (app.registrationStatus === "COMPLETED") {
|
|
39
|
+
hint = "\n\n✅ Ready — run run_security_test to start a scan.";
|
|
40
|
+
}
|
|
41
|
+
else if (app.registrationStatus === "AWAITING_INPUT") {
|
|
42
|
+
hint = "\n\n⚠️ Onboarding needs credentials — use submit_app_credentials, then check_app_status again.";
|
|
43
|
+
}
|
|
44
|
+
else if (app.registrationStatus === "FAILED") {
|
|
45
|
+
hint = "\n\n❌ Registration failed — check the app URL and try register_app again.";
|
|
46
|
+
}
|
|
47
|
+
else if (!terminal) {
|
|
48
|
+
hint = `\n\n⏳ Still ${app.registrationStatus ?? "pending"} after ${Math.round(budgetMs / 1000)}s — call check_app_status again.`;
|
|
49
|
+
}
|
|
50
|
+
return { content: [{ type: "text", text: formatApp(app) + hint }] };
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return {
|
|
54
|
+
content: [{ type: "text", text: `❌ Failed to check app status: ${error instanceof Error ? error.message : String(error)}` }],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AuthManager } from "../../client/authManager.js";
|
|
2
|
+
export declare const checkTaskStatusTool: {
|
|
3
|
+
readonly name: "check_task_status";
|
|
4
|
+
readonly description: string;
|
|
5
|
+
readonly inputSchema: {
|
|
6
|
+
readonly type: "object";
|
|
7
|
+
readonly properties: {
|
|
8
|
+
readonly taskId: {
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
readonly description: "Task ID (defaults to the most recently started task)";
|
|
11
|
+
};
|
|
12
|
+
readonly wait_seconds: {
|
|
13
|
+
readonly type: "number";
|
|
14
|
+
readonly description: "Max seconds to poll before returning current status (default 20, max 240)";
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
readonly additionalProperties: false;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function handleCheckTaskStatus(auth: AuthManager, args: any): Promise<any>;
|
|
21
|
+
//# sourceMappingURL=checkTaskStatus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkTaskStatus.d.ts","sourceRoot":"","sources":["../../../src/tools/protected/checkTaskStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAM1D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;CAiBtB,CAAC;AAEX,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAmCtF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { getTask } from "../../client/apiClient.js";
|
|
2
|
+
import { formatTask } from "../../utils/formatters.js";
|
|
3
|
+
import { pollWithBudget } from "../../utils/poll.js";
|
|
4
|
+
import { DEFAULT_TOOL_POLL_BUDGET_MS, MAX_TOOL_POLL_BUDGET_MS, POLL_MAX_INTERVAL_MS, POLL_START_MS, TASK_TERMINAL_STATES } from "../../config.js";
|
|
5
|
+
export const checkTaskStatusTool = {
|
|
6
|
+
name: "check_task_status",
|
|
7
|
+
description: "⏳ Poll GET /v1/tasks/{taskId} (e.g. a security test run). Polls in-process (5s→60s backoff) for " +
|
|
8
|
+
"up to wait_seconds before returning — call again if it's still QUEUED/RUNNING. Terminal states: " +
|
|
9
|
+
"COMPLETED, FAILED, CANCELLED, INTERRUPTED.",
|
|
10
|
+
inputSchema: {
|
|
11
|
+
type: "object",
|
|
12
|
+
properties: {
|
|
13
|
+
taskId: { type: "string", description: "Task ID (defaults to the most recently started task)" },
|
|
14
|
+
wait_seconds: {
|
|
15
|
+
type: "number",
|
|
16
|
+
description: "Max seconds to poll before returning current status (default 20, max 240)",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
additionalProperties: false,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export async function handleCheckTaskStatus(auth, args) {
|
|
23
|
+
const taskId = args?.taskId ?? auth.currentTaskId;
|
|
24
|
+
if (!taskId) {
|
|
25
|
+
return { content: [{ type: "text", text: "❌ No task to check. Run run_security_test first." }] };
|
|
26
|
+
}
|
|
27
|
+
const budgetMs = Math.min(args?.wait_seconds ? args.wait_seconds * 1000 : DEFAULT_TOOL_POLL_BUDGET_MS, MAX_TOOL_POLL_BUDGET_MS);
|
|
28
|
+
try {
|
|
29
|
+
const { value: task, terminal } = await pollWithBudget({
|
|
30
|
+
fetch: () => getTask(auth, taskId),
|
|
31
|
+
isTerminal: (t) => TASK_TERMINAL_STATES.has(t.state ?? ""),
|
|
32
|
+
budgetMs,
|
|
33
|
+
startIntervalMs: POLL_START_MS,
|
|
34
|
+
maxIntervalMs: POLL_MAX_INTERVAL_MS,
|
|
35
|
+
});
|
|
36
|
+
let hint = "";
|
|
37
|
+
if (task.state === "COMPLETED") {
|
|
38
|
+
hint = "\n\n✅ Done — run get_vulnerabilities to see findings.";
|
|
39
|
+
}
|
|
40
|
+
else if (task.state === "FAILED" || task.state === "CANCELLED" || task.state === "INTERRUPTED") {
|
|
41
|
+
hint = `\n\n❌ Run did not complete successfully (${task.state}).`;
|
|
42
|
+
}
|
|
43
|
+
else if (!terminal) {
|
|
44
|
+
hint = `\n\n⏳ Still ${task.state ?? "pending"} after ${Math.round(budgetMs / 1000)}s — call check_task_status again.`;
|
|
45
|
+
}
|
|
46
|
+
return { content: [{ type: "text", text: formatTask(task) + hint }] };
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return {
|
|
50
|
+
content: [{ type: "text", text: `❌ Failed to check task status: ${error instanceof Error ? error.message : String(error)}` }],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AuthManager } from "../../client/authManager.js";
|
|
2
|
+
export declare const getFixSummaryTool: {
|
|
3
|
+
readonly name: "get_fix_summary";
|
|
4
|
+
readonly description: string;
|
|
5
|
+
readonly inputSchema: {
|
|
6
|
+
readonly type: "object";
|
|
7
|
+
readonly properties: {
|
|
8
|
+
readonly appId: {
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
readonly description: "App ID (defaults to the current app)";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
readonly additionalProperties: false;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare function handleGetFixSummary(auth: AuthManager, args: any): Promise<any>;
|
|
17
|
+
//# sourceMappingURL=getFixSummary.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { getVulnerabilities } from "../../client/apiClient.js";
|
|
2
|
+
export const getFixSummaryTool = {
|
|
3
|
+
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.",
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
appId: {
|
|
11
|
+
type: "string",
|
|
12
|
+
description: "App ID (defaults to the current app)",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
additionalProperties: false,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
const SEVERITY_ICON = {
|
|
19
|
+
critical: "🔴",
|
|
20
|
+
high: "🟠",
|
|
21
|
+
medium: "🟡",
|
|
22
|
+
low: "🟢",
|
|
23
|
+
};
|
|
24
|
+
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
|
+
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
|
+
}
|
|
42
|
+
const total = allVulnerabilities.length;
|
|
43
|
+
if (total === 0) {
|
|
44
|
+
return { content: [{ type: "text", text: "No vulnerabilities found for this app." }] };
|
|
45
|
+
}
|
|
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);
|
|
49
|
+
// Breakdown by severity
|
|
50
|
+
const severities = ["critical", "high", "medium", "low"];
|
|
51
|
+
const breakdownRows = severities
|
|
52
|
+
.map(s => {
|
|
53
|
+
const icon = SEVERITY_ICON[s] ?? "⚪";
|
|
54
|
+
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
|
+
if (all.length === 0)
|
|
59
|
+
return null;
|
|
60
|
+
return `| ${icon} ${s.charAt(0).toUpperCase() + s.slice(1)} | ${all.length} | ${f} | ${u} | ${d} |`;
|
|
61
|
+
})
|
|
62
|
+
.filter(Boolean)
|
|
63
|
+
.join("\n");
|
|
64
|
+
const pct = total > 0 ? Math.round((fixed.length / total) * 100) : 0;
|
|
65
|
+
const progressBar = "█".repeat(Math.round(pct / 5)) + "░".repeat(20 - Math.round(pct / 5));
|
|
66
|
+
let summary = `# Fix Progress: ${auth.currentAppUrl ?? appId}\n\n`;
|
|
67
|
+
summary += `\`${progressBar}\` **${pct}%** (${fixed.length}/${total} fixed)\n\n`;
|
|
68
|
+
summary += `| Severity | Total | Fixed | Unfixed | Dismissed |\n`;
|
|
69
|
+
summary += `| --- | --- | --- | --- | --- |\n`;
|
|
70
|
+
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`;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
summary += `✅ **All vulnerabilities are resolved!**\n`;
|
|
77
|
+
}
|
|
78
|
+
return { content: [{ type: "text", text: summary }] };
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
return {
|
|
82
|
+
content: [
|
|
83
|
+
{
|
|
84
|
+
type: "text",
|
|
85
|
+
text: `❌ Failed to fetch vulnerabilities: ${error instanceof Error ? error.message : String(error)}`,
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AuthManager } from "../../client/authManager.js";
|
|
2
|
+
export declare const getVulnerabilitiesTool: {
|
|
3
|
+
readonly name: "get_vulnerabilities";
|
|
4
|
+
readonly description: string;
|
|
5
|
+
readonly inputSchema: {
|
|
6
|
+
readonly type: "object";
|
|
7
|
+
readonly properties: {
|
|
8
|
+
readonly appId: {
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
readonly description: "App ID (defaults to the current app)";
|
|
11
|
+
};
|
|
12
|
+
readonly search: {
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
readonly description: "Case-insensitive keyword search";
|
|
15
|
+
};
|
|
16
|
+
readonly page: {
|
|
17
|
+
readonly type: "number";
|
|
18
|
+
readonly description: "Page number (default 1)";
|
|
19
|
+
};
|
|
20
|
+
readonly pageSize: {
|
|
21
|
+
readonly type: "number";
|
|
22
|
+
readonly description: "Results per page, 1-100 (default 20)";
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
readonly additionalProperties: false;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare function handleGetVulnerabilities(auth: AuthManager, args: any): Promise<any>;
|
|
29
|
+
//# sourceMappingURL=getVulnerabilities.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getVulnerabilities } from "../../client/apiClient.js";
|
|
2
|
+
import { formatVulnerabilityList } from "../../utils/formatters.js";
|
|
3
|
+
export const getVulnerabilitiesTool = {
|
|
4
|
+
name: "get_vulnerabilities",
|
|
5
|
+
description: "🔍 List findings for an app (GET /v1/apps/{appId}/vulnerabilities). Results get sequence numbers " +
|
|
6
|
+
"(#1, #2, ...) you can pass to suggest_fix / dismiss_vulnerability / reopen_vulnerability / mark_vulnerability_fixed.",
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
appId: { type: "string", description: "App ID (defaults to the current app)" },
|
|
11
|
+
search: { type: "string", description: "Case-insensitive keyword search" },
|
|
12
|
+
page: { type: "number", description: "Page number (default 1)" },
|
|
13
|
+
pageSize: { type: "number", description: "Results per page, 1-100 (default 20)" },
|
|
14
|
+
},
|
|
15
|
+
additionalProperties: false,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
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
|
+
try {
|
|
24
|
+
const result = await getVulnerabilities(auth, appId, {
|
|
25
|
+
page: args?.page,
|
|
26
|
+
pageSize: args?.pageSize,
|
|
27
|
+
search: args?.search,
|
|
28
|
+
});
|
|
29
|
+
auth.cacheVulnerabilities(appId, result.data);
|
|
30
|
+
return {
|
|
31
|
+
content: [
|
|
32
|
+
{ type: "text", text: formatVulnerabilityList(result.data, result.total, result.page, result.pageSize) },
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
return {
|
|
38
|
+
content: [{ type: "text", text: `❌ Failed to fetch vulnerabilities: ${error instanceof Error ? error.message : String(error)}` }],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AuthManager } from "../../client/authManager.js";
|
|
2
|
+
export declare const listAppsTool: {
|
|
3
|
+
readonly name: "list_apps";
|
|
4
|
+
readonly description: "📋 List previously registered apps (GET /v1/apps). Supports search + pagination.";
|
|
5
|
+
readonly inputSchema: {
|
|
6
|
+
readonly type: "object";
|
|
7
|
+
readonly properties: {
|
|
8
|
+
readonly search: {
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
readonly description: "Case-insensitive partial match on label/name";
|
|
11
|
+
};
|
|
12
|
+
readonly page: {
|
|
13
|
+
readonly type: "number";
|
|
14
|
+
readonly description: "Page number (default 1)";
|
|
15
|
+
};
|
|
16
|
+
readonly pageSize: {
|
|
17
|
+
readonly type: "number";
|
|
18
|
+
readonly description: "Results per page, 1-100 (default 20)";
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
readonly additionalProperties: false;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare function handleListApps(auth: AuthManager, args: any): Promise<any>;
|
|
25
|
+
//# sourceMappingURL=listApps.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { listApps } from "../../client/apiClient.js";
|
|
2
|
+
import { formatAppList } from "../../utils/formatters.js";
|
|
3
|
+
export const listAppsTool = {
|
|
4
|
+
name: "list_apps",
|
|
5
|
+
description: "📋 List previously registered apps (GET /v1/apps). Supports search + pagination.",
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
search: { type: "string", description: "Case-insensitive partial match on label/name" },
|
|
10
|
+
page: { type: "number", description: "Page number (default 1)" },
|
|
11
|
+
pageSize: { type: "number", description: "Results per page, 1-100 (default 20)" },
|
|
12
|
+
},
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
export async function handleListApps(auth, args) {
|
|
17
|
+
try {
|
|
18
|
+
const result = await listApps(auth, {
|
|
19
|
+
page: args?.page,
|
|
20
|
+
pageSize: args?.pageSize,
|
|
21
|
+
search: args?.search,
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
content: [{ type: "text", text: formatAppList(result.data, result.total, result.page, result.pageSize) }],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
return {
|
|
29
|
+
content: [{ type: "text", text: `❌ Failed to list apps: ${error instanceof Error ? error.message : String(error)}` }],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AuthManager } from "../../client/authManager.js";
|
|
2
|
+
export declare const logoutTool: {
|
|
3
|
+
readonly name: "logout";
|
|
4
|
+
readonly description: "🚪 Clear the current PerfAI session and selected app/task state.";
|
|
5
|
+
readonly inputSchema: {
|
|
6
|
+
readonly type: "object";
|
|
7
|
+
readonly properties: {};
|
|
8
|
+
readonly additionalProperties: false;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare function handleLogout(auth: AuthManager): Promise<any>;
|
|
12
|
+
//# sourceMappingURL=logout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/tools/protected/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,eAAO,MAAM,UAAU;;;;;;;;CAIb,CAAC;AAEX,wBAAsB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAGlE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const logoutTool = {
|
|
2
|
+
name: "logout",
|
|
3
|
+
description: "🚪 Clear the current PerfAI session and selected app/task state.",
|
|
4
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
5
|
+
};
|
|
6
|
+
export async function handleLogout(auth) {
|
|
7
|
+
auth.logout();
|
|
8
|
+
return { content: [{ type: "text", text: "🚪 Logged out." }] };
|
|
9
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AuthManager } from "../../client/authManager.js";
|
|
2
|
+
export declare const registerAppTool: {
|
|
3
|
+
readonly name: "register_app";
|
|
4
|
+
readonly description: string;
|
|
5
|
+
readonly inputSchema: {
|
|
6
|
+
readonly type: "object";
|
|
7
|
+
readonly properties: {
|
|
8
|
+
readonly appUrl: {
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
readonly description: "Fully-qualified URL of the deployed app, e.g. https://app.example.com";
|
|
11
|
+
};
|
|
12
|
+
readonly createTestAccounts: {
|
|
13
|
+
readonly type: "boolean";
|
|
14
|
+
readonly description: "Let PerfAI auto sign-up test accounts during onboarding (default: true)";
|
|
15
|
+
};
|
|
16
|
+
readonly skipEndpoints: {
|
|
17
|
+
readonly type: "array";
|
|
18
|
+
readonly items: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
};
|
|
21
|
+
readonly description: "Optional list of endpoints to exclude from onboarding";
|
|
22
|
+
};
|
|
23
|
+
readonly tenantOneCredentials: {
|
|
24
|
+
readonly type: "object";
|
|
25
|
+
readonly description: "Optional credentials to use instead of auto sign-up";
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
readonly required: readonly ["appUrl"];
|
|
29
|
+
readonly additionalProperties: false;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare function handleRegisterApp(auth: AuthManager, args: any): Promise<any>;
|
|
33
|
+
//# sourceMappingURL=registerApp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerApp.d.ts","sourceRoot":"","sources":["../../../src/tools/protected/registerApp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAK1D,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BlB,CAAC;AAMX,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAoElF"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { registerApp, getApp } from "../../client/apiClient.js";
|
|
2
|
+
import { ApiError } from "../../client/errors.js";
|
|
3
|
+
import { formatApp } from "../../utils/formatters.js";
|
|
4
|
+
export const registerAppTool = {
|
|
5
|
+
name: "register_app",
|
|
6
|
+
description: "📱 Register an app by its deployed URL (POST /v1/apps). PerfAI onboards it autonomously — " +
|
|
7
|
+
"the returned app becomes the 'current app' for subsequent tools. First onboarding can take a " +
|
|
8
|
+
"while; follow up with check_app_status until registrationStatus is COMPLETED.",
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: {
|
|
12
|
+
appUrl: { type: "string", description: "Fully-qualified URL of the deployed app, e.g. https://app.example.com" },
|
|
13
|
+
createTestAccounts: {
|
|
14
|
+
type: "boolean",
|
|
15
|
+
description: "Let PerfAI auto sign-up test accounts during onboarding (default: true)",
|
|
16
|
+
},
|
|
17
|
+
skipEndpoints: {
|
|
18
|
+
type: "array",
|
|
19
|
+
items: { type: "string" },
|
|
20
|
+
description: "Optional list of endpoints to exclude from onboarding",
|
|
21
|
+
},
|
|
22
|
+
tenantOneCredentials: {
|
|
23
|
+
type: "object",
|
|
24
|
+
description: "Optional credentials to use instead of auto sign-up",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
required: ["appUrl"],
|
|
28
|
+
additionalProperties: false,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
function isPlainObject(value) {
|
|
32
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
33
|
+
}
|
|
34
|
+
export async function handleRegisterApp(auth, args) {
|
|
35
|
+
if (!args?.appUrl) {
|
|
36
|
+
return { content: [{ type: "text", text: "❌ appUrl is required." }] };
|
|
37
|
+
}
|
|
38
|
+
// Some MCP clients pre-fill optional object/array fields with placeholder
|
|
39
|
+
// values (e.g. a description string) when a tool is invoked with defaults.
|
|
40
|
+
// Only forward these if they're actually well-formed, so a bad client
|
|
41
|
+
// default can't get misinterpreted by the API's validation.
|
|
42
|
+
const tenantOneCredentials = isPlainObject(args.tenantOneCredentials) && Object.keys(args.tenantOneCredentials).length > 0
|
|
43
|
+
? args.tenantOneCredentials
|
|
44
|
+
: undefined;
|
|
45
|
+
const skipEndpoints = Array.isArray(args.skipEndpoints) && args.skipEndpoints.every((e) => typeof e === "string")
|
|
46
|
+
? args.skipEndpoints
|
|
47
|
+
: undefined;
|
|
48
|
+
const createTestAccounts = typeof args.createTestAccounts === "boolean" ? args.createTestAccounts : undefined;
|
|
49
|
+
try {
|
|
50
|
+
const app = await registerApp(auth, {
|
|
51
|
+
appUrl: args.appUrl,
|
|
52
|
+
createTestAccounts,
|
|
53
|
+
skipEndpoints,
|
|
54
|
+
tenantOneCredentials,
|
|
55
|
+
});
|
|
56
|
+
auth.setCurrentApp(app.appId, args.appUrl);
|
|
57
|
+
return {
|
|
58
|
+
content: [
|
|
59
|
+
{
|
|
60
|
+
type: "text",
|
|
61
|
+
text: `✅ App registered.\n\n${formatApp(app)}\n\n` +
|
|
62
|
+
`Next: check_app_status to poll until registrationStatus is COMPLETED, then run_security_test.`,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
// PerfAI treats appUrl as unique — a 409 here means it's already
|
|
69
|
+
// registered. Rather than just failing, pick up the existing app so the
|
|
70
|
+
// rest of the workflow (check_app_status, run_security_test, ...) keeps
|
|
71
|
+
// working without the caller having to copy the appId out of the error.
|
|
72
|
+
if (error instanceof ApiError && error.status === 409 && typeof error.data?.appId === "string") {
|
|
73
|
+
try {
|
|
74
|
+
const existing = await getApp(auth, error.data.appId);
|
|
75
|
+
auth.setCurrentApp(existing.appId, args.appUrl);
|
|
76
|
+
return {
|
|
77
|
+
content: [
|
|
78
|
+
{
|
|
79
|
+
type: "text",
|
|
80
|
+
text: `ℹ️ This URL is already registered — selected the existing app instead.\n\n${formatApp(existing)}\n\n` +
|
|
81
|
+
(existing.registrationStatus === "COMPLETED"
|
|
82
|
+
? "Ready — run run_security_test to start a scan."
|
|
83
|
+
: "Run check_app_status to check on it."),
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// fall through to the generic error below
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
content: [{ type: "text", text: `❌ Failed to register app: ${error instanceof Error ? error.message : String(error)}` }],
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AuthManager } from "../../client/authManager.js";
|
|
2
|
+
export declare const runSecurityTestTool: {
|
|
3
|
+
readonly name: "run_security_test";
|
|
4
|
+
readonly description: string;
|
|
5
|
+
readonly inputSchema: {
|
|
6
|
+
readonly type: "object";
|
|
7
|
+
readonly properties: {
|
|
8
|
+
readonly appId: {
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
readonly description: "App ID (defaults to the current app)";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
readonly additionalProperties: false;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare function handleRunSecurityTest(auth: AuthManager, args: any): Promise<any>;
|
|
17
|
+
//# sourceMappingURL=runSecurityTest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runSecurityTest.d.ts","sourceRoot":"","sources":["../../../src/tools/protected/runSecurityTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG1D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;CAYtB,CAAC;AAEX,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAoCtF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { getApp, runSecurityAgent } from "../../client/apiClient.js";
|
|
2
|
+
export const runSecurityTestTool = {
|
|
3
|
+
name: "run_security_test",
|
|
4
|
+
description: "🚀 Start a security test run (POST /v1/apps/{appId}/security-agent). Requires registrationStatus " +
|
|
5
|
+
"COMPLETED — run check_app_status first. Returns a taskId; poll it with check_task_status.",
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
appId: { type: "string", description: "App ID (defaults to the current app)" },
|
|
10
|
+
},
|
|
11
|
+
additionalProperties: false,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export async function handleRunSecurityTest(auth, args) {
|
|
15
|
+
const appId = args?.appId ?? auth.currentAppId;
|
|
16
|
+
if (!appId) {
|
|
17
|
+
return { content: [{ type: "text", text: "❌ No app selected. Run register_app or select_app first." }] };
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
// Pre-flight check so we can give a clearer message than the API's bare 400.
|
|
21
|
+
const app = await getApp(auth, appId);
|
|
22
|
+
if (app.registrationStatus !== "COMPLETED") {
|
|
23
|
+
return {
|
|
24
|
+
content: [
|
|
25
|
+
{
|
|
26
|
+
type: "text",
|
|
27
|
+
text: `❌ App is not ready (registrationStatus: ${app.registrationStatus ?? "UNKNOWN"}). Run check_app_status until it's COMPLETED before starting a test.`,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const task = await runSecurityAgent(auth, appId);
|
|
33
|
+
auth.currentTaskId = task.taskId;
|
|
34
|
+
return {
|
|
35
|
+
content: [
|
|
36
|
+
{
|
|
37
|
+
type: "text",
|
|
38
|
+
text: `🚀 Security test started.\n\nTask ID: ${task.taskId}\n\nNext: check_task_status to poll until state is COMPLETED (can take up to ~30 min).`,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
return {
|
|
45
|
+
content: [{ type: "text", text: `❌ Failed to start security test: ${error instanceof Error ? error.message : String(error)}` }],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AuthManager } from "../../client/authManager.js";
|
|
2
|
+
export declare const selectAppTool: {
|
|
3
|
+
readonly name: "select_app";
|
|
4
|
+
readonly description: "🎯 Set the 'current app' for subsequent tools (run_security_test, get_vulnerabilities, etc.) by appId.";
|
|
5
|
+
readonly inputSchema: {
|
|
6
|
+
readonly type: "object";
|
|
7
|
+
readonly properties: {
|
|
8
|
+
readonly appId: {
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
readonly description: "App ID, e.g. from list_apps";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
readonly required: readonly ["appId"];
|
|
14
|
+
readonly additionalProperties: false;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare function handleSelectApp(auth: AuthManager, args: any): Promise<any>;
|
|
18
|
+
//# sourceMappingURL=selectApp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectApp.d.ts","sourceRoot":"","sources":["../../../src/tools/protected/selectApp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAI1D,eAAO,MAAM,aAAa;;;;;;;;;;;;;;CAWhB,CAAC;AAEX,wBAAsB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAahF"}
|