@mickey20/codefy 1.0.2 → 1.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/README.md CHANGED
@@ -1,12 +1,13 @@
1
- # Codefy Unified Security CLI (DAST & SAST)
1
+ # Codefy Unified Security CLI & MCP Server (DAST & SAST)
2
2
 
3
- A production-grade, developer-friendly Command-Line Interface and interactive terminal dashboard for the **Codefy DAST** and **Codefy SAST & BugBound V3** security platforms.
3
+ A production-grade, developer-friendly Command-Line Interface, interactive terminal dashboard, and **Model Context Protocol (MCP) Server** for the **Codefy DAST** and **Codefy SAST & BugBound V3** security platforms — built for developers and AI coding agents (**Antigravity**, **Claude Code**, **Cursor**, **Windsurf**, **Cline**, etc.).
4
4
 
5
5
  ---
6
6
 
7
7
  ## Features
8
8
 
9
- - **Dual-Mode Operation**:
9
+ - **Tri-Mode Operation**:
10
+ - **MCP Server (`codefy mcp` / `codefy-mcp`)**: Native stdio MCP server exposing 24 security tools, 3 live resources, and 4 guided prompts for Antigravity, Claude Code, Cursor, and any MCP-compatible agent.
10
11
  - **Headless / CI-CD Mode**: Unix-friendly commands with `--json`, `--output <file>`, `--format sarif`, and `--fail-on <severities>` exit code policies.
11
12
  - **Interactive TUI Dashboard**: Real-time terminal UI powered by React and Ink with animated SSE progress bars, active engine indicators, and live vulnerability badges.
12
13
  - **Unified Scanner (`codefy scan`)**: Automatically runs DAST against target URLs and SAST against local directories or remote repositories.
@@ -53,10 +54,83 @@ npm run dev -- --help
53
54
  npm run build
54
55
  npm link
55
56
  codefy --help
57
+ codefy-mcp --help
56
58
  ```
57
59
 
58
60
  ---
59
61
 
62
+ ## MCP Server (Antigravity, Claude Code, Cursor & Other Coding Agents)
63
+
64
+ Codefy ships with a native **stdio MCP server** so AI coding agents can directly run SAST/DAST scans, inspect vulnerabilities, apply autofix patches, triage canonical issues, and audit security posture.
65
+
66
+ You can launch it either via `codefy mcp` or the standalone lightweight binary `codefy-mcp`.
67
+
68
+ ### Antigravity (`~/.gemini/config/mcp_config.json`)
69
+ Add to `~/.gemini/config/mcp_config.json`:
70
+ ```json
71
+ {
72
+ "mcpServers": {
73
+ "codefy": {
74
+ "command": "npx",
75
+ "args": ["-y", "@mickey20/codefy", "mcp"],
76
+ "env": {
77
+ "CODEFY_API_TOKEN": "optional-jwt-token"
78
+ }
79
+ }
80
+ }
81
+ }
82
+ ```
83
+ > **Local development build**: If testing from this repository before publishing to npm, use `"command": "node"` and `"args": ["/absolute/path/to/CLI/dist/mcp/index.js"]`.
84
+
85
+ ### Claude Code
86
+ ```bash
87
+ claude mcp add codefy -- npx -y @mickey20/codefy mcp
88
+ ```
89
+ Or with an explicit API token:
90
+ ```bash
91
+ claude mcp add codefy -e CODEFY_API_TOKEN=your_jwt_token -- npx -y @mickey20/codefy mcp
92
+ ```
93
+
94
+ ### Cursor / Windsurf / Generic MCP Clients (`mcp.json`)
95
+ ```json
96
+ {
97
+ "mcpServers": {
98
+ "codefy": {
99
+ "command": "npx",
100
+ "args": ["-y", "@mickey20/codefy", "mcp"]
101
+ }
102
+ }
103
+ }
104
+ ```
105
+
106
+ ### Authentication in MCP Mode
107
+ Codefy resolves credentials automatically in the following order:
108
+ 1. `CODEFY_API_TOKEN` environment variable in your MCP client config
109
+ 2. Saved session token in `~/.codefy/credentials.json` (created by running `codefy auth login` once in your terminal)
110
+ 3. Guest / Tester mode (works out-of-the-box for basic scans without login)
111
+
112
+ ### Exposed MCP Tools (24)
113
+
114
+ | Category | Tools |
115
+ |---|---|
116
+ | **SAST** | `codefy_sast_scan_directory`, `codefy_sast_scan_diff`, `codefy_sast_scan_repo`, `codefy_sast_get_job`, `codefy_sast_list_scans`, `codefy_sast_get_patch`, `codefy_sast_apply_patch`, `codefy_sast_export`, `codefy_sast_cancel_job` |
117
+ | **DAST** | `codefy_dast_validate_target`, `codefy_dast_scan`, `codefy_dast_get_job`, `codefy_dast_list_scans`, `codefy_dast_export`, `codefy_dast_cancel_job` |
118
+ | **Canonical Issues** | `codefy_issues_list`, `codefy_issues_get`, `codefy_issues_transition`, `codefy_issues_accept_risk`, `codefy_issues_metrics`, `codefy_issues_delete` |
119
+ | **Platform** | `codefy_list_tools`, `codefy_audit_events`, `codefy_auth_status` |
120
+
121
+ ### Exposed MCP Resources (3)
122
+ - `codefy://tools/sast` — Catalog of all 25 integrated SAST/SCA/Secrets/IaC engines
123
+ - `codefy://tools/dast` — Catalog of all 30 integrated DAST passive & active engines
124
+ - `codefy://config/status` — Active gateway URLs, timeout, and redacted auth status
125
+
126
+ ### Exposed MCP Prompts (4)
127
+ - `security-audit-repo` — Run SAST on a local repository, verify findings in code, and propose fixes
128
+ - `security-review-pr` — Incremental git-diff SAST scan against a base branch
129
+ - `dast-recon` — Pre-flight SSRF validation + passive DAST recon summary
130
+ - `triage-issues` — Posture metrics + prioritized triage of open Critical/High issues
131
+
132
+ ---
133
+
60
134
  ## Command Reference
61
135
 
62
136
  ### Unified Scanner
package/dist/index.js CHANGED
@@ -30,6 +30,14 @@ program
30
30
  .action(() => {
31
31
  render(React.createElement(App), { exitOnCtrlC: true });
32
32
  });
33
+ // Start MCP server over stdio for coding agents (Antigravity, Claude Code, Cursor, etc.)
34
+ program
35
+ .command("mcp")
36
+ .description("Start the Codefy MCP server (stdio) for Antigravity, Claude Code, Cursor, and other AI coding agents")
37
+ .action(async () => {
38
+ const { startMcpServer } = await import("./mcp/server.js");
39
+ await startMcpServer();
40
+ });
33
41
  // Launch interactive AI security assistant (Coming Soon)
34
42
  program
35
43
  .command("chat")
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EA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AC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,208 @@
1
+ import { execFile } from "node:child_process";
2
+ import { promisify } from "node:util";
3
+ import { isWorkerQueueError as isSastWorkerQueueError } from "../services/sast.js";
4
+ import { isWorkerQueueError as isDastWorkerQueueError } from "../services/dast.js";
5
+ import { ApiError } from "../services/http.js";
6
+ const execFileAsync = promisify(execFile);
7
+ export const FAST_SAST_TOOLS = ["semgrep", "gitleaks", "trivy"];
8
+ export const FAST_DAST_TOOLS = ["httpx", "wafw00f", "sslyze"];
9
+ export function jsonResult(payload) {
10
+ return {
11
+ content: [
12
+ {
13
+ type: "text",
14
+ text: JSON.stringify(payload, null, 2),
15
+ },
16
+ ],
17
+ };
18
+ }
19
+ export function textResult(text) {
20
+ return {
21
+ content: [
22
+ {
23
+ type: "text",
24
+ text,
25
+ },
26
+ ],
27
+ };
28
+ }
29
+ export function errorResult(err, context) {
30
+ const isQueueDown = isSastWorkerQueueError(err) ||
31
+ isDastWorkerQueueError(err) ||
32
+ Boolean(err?.data?.isWorkerQueueDown);
33
+ const status = err instanceof ApiError ? err.status : undefined;
34
+ const detail = err instanceof ApiError
35
+ ? err.detail
36
+ : err instanceof Error
37
+ ? err.message
38
+ : String(err);
39
+ const hints = [];
40
+ if (isQueueDown) {
41
+ hints.push("The backend Redis/Celery worker queue appears offline or cold-starting on Render (~30s). Retry shortly or check local Redis.");
42
+ }
43
+ if (status === 401 || status === 403) {
44
+ hints.push("Authentication failed. Set the CODEFY_API_TOKEN environment variable in your MCP server config or run 'codefy auth login' in your terminal.");
45
+ }
46
+ const errorPayload = {
47
+ error: context ? `${context}: ${detail}` : detail,
48
+ ...(status !== undefined ? { status } : {}),
49
+ ...(isQueueDown ? { is_worker_queue_offline: true } : {}),
50
+ ...(hints.length > 0 ? { hints } : {}),
51
+ };
52
+ return {
53
+ isError: true,
54
+ content: [
55
+ {
56
+ type: "text",
57
+ text: JSON.stringify(errorPayload, null, 2),
58
+ },
59
+ ],
60
+ };
61
+ }
62
+ export function cleanFilePath(filePath) {
63
+ if (!filePath)
64
+ return filePath;
65
+ return filePath.replace(/^(?:\/tmp\/[^/]+\/|\/var\/folders\/[^/]+\/[^/]+\/[^/]+\/[^/]+\/|file:\/\/)/, "");
66
+ }
67
+ export function normalizeSastFindings(findings, includeTerminalOutput = false) {
68
+ if (!findings || findings.length === 0)
69
+ return [];
70
+ const deduped = [];
71
+ const seen = new Set();
72
+ for (const f of findings) {
73
+ const cleanedPath = cleanFilePath(f.file_path);
74
+ const key = f.fingerprint ||
75
+ `${cleanedPath || ""}:${f.line_start || 1}:${f.vulnerability_id || f.title || ""}`;
76
+ if (seen.has(key))
77
+ continue;
78
+ seen.add(key);
79
+ const copy = {
80
+ ...f,
81
+ ...(cleanedPath !== undefined ? { file_path: cleanedPath } : {}),
82
+ };
83
+ if (!includeTerminalOutput) {
84
+ delete copy.terminal_output;
85
+ }
86
+ deduped.push(copy);
87
+ }
88
+ return deduped;
89
+ }
90
+ export function formatSastJobForAgent(job, options) {
91
+ const includeTerminalOutput = Boolean(options?.includeTerminalOutput);
92
+ const findings = normalizeSastFindings(job.findings, includeTerminalOutput);
93
+ const hasToolErrors = Object.keys(job.tool_errors ?? {}).length > 0;
94
+ const statusLower = (job.status || "").toLowerCase();
95
+ const result = {
96
+ job_id: job.job_id,
97
+ status: job.status,
98
+ mode: job.mode || "passive",
99
+ target_id: job.target_id,
100
+ cached: job.cached,
101
+ created_at: job.created_at,
102
+ completed_at: job.completed_at,
103
+ duration_ms: job.duration_ms,
104
+ scanned_tools: job.scanned_tools ?? [],
105
+ summary: job.summary ?? { total_findings: findings.length },
106
+ has_autofix_patch: Boolean(job.autofix_patch),
107
+ findings_count: findings.length,
108
+ findings,
109
+ ...(hasToolErrors ? { tool_errors: job.tool_errors } : {}),
110
+ ...(job.error_message ? { error_message: job.error_message } : {}),
111
+ ...(includeTerminalOutput && job.terminal_output
112
+ ? { terminal_output: job.terminal_output }
113
+ : {}),
114
+ };
115
+ if (options?.timedOut) {
116
+ result.timed_out = true;
117
+ result.note = `Job ${job.job_id} is still '${job.status}'. Call codefy_sast_get_job with job_id '${job.job_id}' to check again later.`;
118
+ }
119
+ else if (statusLower !== "completed") {
120
+ result.note = `Job ended with status '${job.status}'. Inspect error_message and tool_errors before treating findings as complete.`;
121
+ }
122
+ return result;
123
+ }
124
+ export async function getGitDiff(baseCommit = "origin/main", cwd = process.cwd()) {
125
+ try {
126
+ const { stdout } = await execFileAsync("git", ["diff", baseCommit, "--"], {
127
+ cwd,
128
+ maxBuffer: 20 * 1024 * 1024,
129
+ });
130
+ return { baseUsed: baseCommit, diff: stdout };
131
+ }
132
+ catch (err) {
133
+ const fallback = baseCommit === "origin/main" ? "main" : "HEAD~1";
134
+ try {
135
+ const { stdout } = await execFileAsync("git", ["diff", fallback, "--"], {
136
+ cwd,
137
+ maxBuffer: 20 * 1024 * 1024,
138
+ });
139
+ return { baseUsed: fallback, diff: stdout };
140
+ }
141
+ catch {
142
+ const msg = err instanceof Error ? err.message : String(err);
143
+ throw new Error(`Failed to generate git diff against '${baseCommit}' (fallback '${fallback}'): ${msg}`);
144
+ }
145
+ }
146
+ }
147
+ function sleep(ms, signal) {
148
+ return new Promise((resolve, reject) => {
149
+ if (signal?.aborted) {
150
+ reject(new Error("Operation cancelled by client."));
151
+ return;
152
+ }
153
+ const timer = setTimeout(() => {
154
+ signal?.removeEventListener("abort", onAbort);
155
+ resolve();
156
+ }, ms);
157
+ const onAbort = () => {
158
+ clearTimeout(timer);
159
+ reject(new Error("Operation cancelled by client."));
160
+ };
161
+ signal?.addEventListener("abort", onAbort, { once: true });
162
+ });
163
+ }
164
+ export async function waitForJob(opts) {
165
+ const pollIntervalMs = opts.pollIntervalMs ?? 2500;
166
+ const deadline = Date.now() + Math.max(5, opts.timeoutSeconds) * 1000;
167
+ let attempt = 0;
168
+ let job = await opts.fetchJob();
169
+ while (["pending", "running", "queued"].includes((job.status || "").toLowerCase())) {
170
+ if (Date.now() >= deadline) {
171
+ return { job, timedOut: true };
172
+ }
173
+ attempt++;
174
+ if (opts.onProgress) {
175
+ const elapsedSec = Math.round((attempt * pollIntervalMs) / 1000);
176
+ const pct = Math.min(95, Math.round((elapsedSec / Math.max(1, opts.timeoutSeconds)) * 100));
177
+ await opts.onProgress(pct, 100, `Scan status: ${job.status} (${elapsedSec}s elapsed)`);
178
+ }
179
+ await sleep(pollIntervalMs, opts.signal);
180
+ job = await opts.fetchJob();
181
+ }
182
+ if (opts.onProgress) {
183
+ await opts.onProgress(100, 100, `Scan finished with status: ${job.status}`);
184
+ }
185
+ return { job, timedOut: false };
186
+ }
187
+ export function createProgressReporter(extra) {
188
+ const progressToken = extra._meta?.progressToken;
189
+ if (progressToken === undefined)
190
+ return undefined;
191
+ return async (progress, total, message) => {
192
+ try {
193
+ await extra.sendNotification({
194
+ method: "notifications/progress",
195
+ params: {
196
+ progressToken,
197
+ progress,
198
+ total,
199
+ message,
200
+ },
201
+ });
202
+ }
203
+ catch {
204
+ // Best-effort progress reporting; never fail the tool call on notification errors.
205
+ }
206
+ };
207
+ }
208
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/mcp/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,OAAO,EAAE,kBAAkB,IAAI,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,kBAAkB,IAAI,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAChE,MAAM,CAA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efy MCP server: ${err instanceof Error ? err.stack || err.message : String(err)}`);
5
+ process.exit(1);
6
+ });
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,cAAc,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC7B,OAAO,CAAC,KAAK,CACX,2CAA2C,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAC3G,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,127 @@
1
+ import { z } from "zod";
2
+ export function registerPrompts(server) {
3
+ server.registerPrompt("security-audit-repo", {
4
+ title: "Security Audit Local Repository",
5
+ description: "Run a SAST security audit on a local codebase, prioritize findings by severity, inspect affected files, and propose concrete remediations.",
6
+ argsSchema: {
7
+ directory: z
8
+ .string()
9
+ .optional()
10
+ .describe("Directory to audit (defaults to current workspace)."),
11
+ deep: z
12
+ .enum(["true", "false"])
13
+ .optional()
14
+ .describe("Set 'true' to run the full 25-tool SAST fleet instead of the fast preset."),
15
+ },
16
+ }, async (args) => {
17
+ const dir = args.directory || ".";
18
+ const fastFlag = args.deep === "true" ? "false" : "true";
19
+ return {
20
+ messages: [
21
+ {
22
+ role: "user",
23
+ content: {
24
+ type: "text",
25
+ text: [
26
+ `Perform a comprehensive SAST security audit on directory "${dir}" using Codefy MCP tools:`,
27
+ `1. Call codefy_sast_scan_directory with directory="${dir}" and fast=${fastFlag}.`,
28
+ `2. Group all findings by severity (CRITICAL -> HIGH -> MEDIUM -> LOW -> INFO) with exact file_path and line numbers.`,
29
+ `3. Inspect the affected source code lines directly to filter out any false positives and verify exploitability.`,
30
+ `4. If has_autofix_patch is true, call codefy_sast_get_patch to review the suggested diff before asking whether to apply it.`,
31
+ `5. Present a prioritized remediation plan with concrete code fixes for all Critical and High findings.`,
32
+ ].join("\n"),
33
+ },
34
+ },
35
+ ],
36
+ };
37
+ });
38
+ server.registerPrompt("security-review-pr", {
39
+ title: "Security Review PR / Git Diff",
40
+ description: "Run an incremental SAST diff scan against a base branch and produce a concise PR security review.",
41
+ argsSchema: {
42
+ base_commit: z
43
+ .string()
44
+ .optional()
45
+ .describe("Base branch or commit (defaults to origin/main)."),
46
+ directory: z
47
+ .string()
48
+ .optional()
49
+ .describe("Local repository path (defaults to current directory)."),
50
+ },
51
+ }, async (args) => {
52
+ const base = args.base_commit || "origin/main";
53
+ const dir = args.directory || ".";
54
+ return {
55
+ messages: [
56
+ {
57
+ role: "user",
58
+ content: {
59
+ type: "text",
60
+ text: [
61
+ `Run an incremental PR security review on "${dir}" against base "${base}":`,
62
+ `1. Call codefy_sast_scan_diff with directory="${dir}" and base_commit="${base}".`,
63
+ `2. Review every finding introduced in the diff, referencing exact files and line numbers.`,
64
+ `3. Provide a clear Ship / Block recommendation along with minimal patch suggestions for any High or Critical vulnerabilities.`,
65
+ ].join("\n"),
66
+ },
67
+ },
68
+ ],
69
+ };
70
+ });
71
+ server.registerPrompt("dast-recon", {
72
+ title: "DAST Recon & Security Assessment",
73
+ description: "Validate a target URL against SSRF guardrails, run a passive DAST recon scan, and summarize headers, TLS posture, and exposed attack surface.",
74
+ argsSchema: {
75
+ target_url: z.string().describe("Authorized target HTTP/HTTPS URL to assess."),
76
+ mode: z
77
+ .enum(["passive", "active"])
78
+ .optional()
79
+ .describe("Scan mode ('passive' recommended unless explicitly authorized for active fuzzing)."),
80
+ },
81
+ }, async (args) => {
82
+ const mode = args.mode || "passive";
83
+ return {
84
+ messages: [
85
+ {
86
+ role: "user",
87
+ content: {
88
+ type: "text",
89
+ text: [
90
+ `Run a Codefy DAST security assessment against "${args.target_url}" (mode: ${mode}):`,
91
+ `1. First call codefy_dast_validate_target on "${args.target_url}" to verify DNS and SSRF guardrails.`,
92
+ `2. If valid, call codefy_dast_scan with target_url="${args.target_url}", mode="${mode}", fast=true.`,
93
+ `3. Summarize discovered technologies, TLS/header weaknesses, and prioritized findings with concrete server/application remediation steps.`,
94
+ ].join("\n"),
95
+ },
96
+ },
97
+ ],
98
+ };
99
+ });
100
+ server.registerPrompt("triage-issues", {
101
+ title: "Triage Open Security Issues",
102
+ description: "Review Codefy security posture metrics and open Critical/High canonical issues, then recommend triage or fix actions.",
103
+ argsSchema: {
104
+ repo_id: z.string().optional().describe("Optional repository ID to scope triage."),
105
+ },
106
+ }, async (args) => {
107
+ const repoFilter = args.repo_id ? ` for repo_id="${args.repo_id}"` : "";
108
+ return {
109
+ messages: [
110
+ {
111
+ role: "user",
112
+ content: {
113
+ type: "text",
114
+ text: [
115
+ `Triage open security issues${repoFilter}:`,
116
+ `1. Call codefy_issues_metrics${args.repo_id ? ` with repo_id="${args.repo_id}"` : ""} to get overall security posture and SLA breaches.`,
117
+ `2. Call codefy_issues_list for severity="critical" and severity="high" (status="open" or "discovered").`,
118
+ `3. For the top issues, call codefy_issues_get to inspect code/URL anchors, evidence, and remediation advice.`,
119
+ `4. Recommend which issues to fix immediately, transition to triaged/verified, or evaluate for formal risk acceptance.`,
120
+ ].join("\n"),
121
+ },
122
+ },
123
+ ],
124
+ };
125
+ });
126
+ }
127
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/mcp/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,UAAU,eAAe,CAAC,MAAiB;IAC/C,MAAM,CAAC,cAAc,CACnB,qBAAqB,EACrB;QACE,KAAK,EAAE,iCAAiC;QACxC,WAAW,EACT,4IAA4I;QAC9I,UAAU,EAAE;YACV,SAAS,EAAE,CAAC;iBAC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EAAE;YACV,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yCAAyC,CAAC;SACnF;KACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACxE,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,MAAM;oBACZ,OAAO,EAAE;wBACP,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE;4BACJ,8BAA8B,UAAU,GAAG;4BAC3C,gCAAgC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,oDAAoD;4BACzI,yGAAyG;4BACzG,8GAA8G;4BAC9G,uHAAuH;yBACxH,CAAC,IAAI,CAAC,IAAI,CAAC;qBACb;iBACF;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { getConfig } from "../config/index.js";
2
+ import { listTools } from "../services/issues.js";
3
+ export function registerResources(server) {
4
+ server.registerResource("codefy-sast-tools", "codefy://tools/sast", {
5
+ title: "Codefy SAST Scanner Fleet",
6
+ description: "Catalog of all 25 integrated Static Application Security Testing (SAST), SCA, Secrets, and IaC engines.",
7
+ mimeType: "application/json",
8
+ }, async (uri) => {
9
+ const res = await listTools("sast");
10
+ return {
11
+ contents: [
12
+ {
13
+ uri: uri.href,
14
+ mimeType: "application/json",
15
+ text: JSON.stringify(res, null, 2),
16
+ },
17
+ ],
18
+ };
19
+ });
20
+ server.registerResource("codefy-dast-tools", "codefy://tools/dast", {
21
+ title: "Codefy DAST Scanner Fleet",
22
+ description: "Catalog of all 30 integrated Dynamic Application Security Testing (DAST) passive recon and active fuzzing engines.",
23
+ mimeType: "application/json",
24
+ }, async (uri) => {
25
+ const res = await listTools("dast");
26
+ return {
27
+ contents: [
28
+ {
29
+ uri: uri.href,
30
+ mimeType: "application/json",
31
+ text: JSON.stringify(res, null, 2),
32
+ },
33
+ ],
34
+ };
35
+ });
36
+ server.registerResource("codefy-config-status", "codefy://config/status", {
37
+ title: "Codefy Gateway Configuration",
38
+ description: "Active Codefy SAST/DAST gateway URLs, timeout settings, and whether a session token is configured (redacted).",
39
+ mimeType: "application/json",
40
+ }, async (uri) => {
41
+ const cfg = getConfig();
42
+ return {
43
+ contents: [
44
+ {
45
+ uri: uri.href,
46
+ mimeType: "application/json",
47
+ text: JSON.stringify({
48
+ sast_base_url: cfg.sastBaseUrl,
49
+ dast_base_url: cfg.dastBaseUrl,
50
+ timeout_ms: cfg.timeoutMs,
51
+ token_configured: Boolean(cfg.token),
52
+ }, null, 2),
53
+ },
54
+ ],
55
+ };
56
+ });
57
+ }
58
+ //# sourceMappingURL=resources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/mcp/resources.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,MAAM,UAAU,iBAAiB,CAAC,MAAiB;IACjD,MAAM,CAAC,gBAAgB,CACrB,mBAAmB,EACnB,qBAAqB,EACrB;QACE,KAAK,EAAE,2BAA2B;QAClC,WAAW,EAAE,yGAAyG;QACtH,QAAQ,EAAE,kBAAkB;KAC7B,EACD,KAAK,EAAE,GAAG,EAAE,EAAE;QACZ,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,CAAC;QACpC,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,GAAG,EAAE,GAAG,CAAC,IAAI;oBACb,QAAQ,EAAE,kBAAkB;oBAC5B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAA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/server/mcp.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { registerSastTools } from "./tools/sast.js";
5
+ import { registerDastTools } from "./tools/dast.js";
6
+ import { registerIssuesTools } from "./tools/issues.js";
7
+ import { registerPlatformTools } from "./tools/platform.js";
8
+ import { registerResources } from "./resources.js";
9
+ import { registerPrompts } from "./prompts.js";
10
+ const require = createRequire(import.meta.url);
11
+ function getPackageVersion() {
12
+ try {
13
+ const pkg = require("../../package.json");
14
+ return pkg.version || "1.0.2";
15
+ }
16
+ catch {
17
+ return "1.0.2";
18
+ }
19
+ }
20
+ const SERVER_INSTRUCTIONS = [
21
+ "Codefy Unified Security MCP Server (SAST, DAST, Autofix Remediation, Canonical Issue Graph, and Security Audit Trail).",
22
+ "- For quick local source scans (~10s), call codefy_sast_scan_directory with fast=true (semgrep, gitleaks, trivy). Set fast=false or pass custom tools from codefy_list_tools for deeper scans.",
23
+ "- For PR or branch reviews, call codefy_sast_scan_diff against the base branch.",
24
+ "- Before running DAST against a URL, call codefy_dast_validate_target to verify DNS/SSRF guardrails. Only scan targets the user owns or is authorized to test.",
25
+ "- When autofix patches are available, inspect them with codefy_sast_get_patch before calling codefy_sast_apply_patch (use dry_run=true first when unsure).",
26
+ "- Authentication uses CODEFY_API_TOKEN env var, ~/.codefy/credentials.json (from `codefy auth login`), or guest/tester mode. Check status with codefy_auth_status.",
27
+ ].join("\n");
28
+ export function createMcpServer() {
29
+ const server = new McpServer({
30
+ name: "codefy",
31
+ version: getPackageVersion(),
32
+ }, {
33
+ instructions: SERVER_INSTRUCTIONS,
34
+ });
35
+ registerSastTools(server);
36
+ registerDastTools(server);
37
+ registerIssuesTools(server);
38
+ registerPlatformTools(server);
39
+ registerResources(server);
40
+ registerPrompts(server);
41
+ return server;
42
+ }
43
+ export async function startMcpServer() {
44
+ const server = createMcpServer();
45
+ const transport = new StdioServerTransport();
46
+ const shutdown = async () => {
47
+ try {
48
+ await server.close();
49
+ }
50
+ catch {
51
+ // Ignore close errors during exit
52
+ }
53
+ process.exit(0);
54
+ };
55
+ process.once("SIGINT", shutdown);
56
+ process.once("SIGTERM", shutdown);
57
+ await server.connect(transport);
58
+ console.error(`Codefy MCP server v${getPackageVersion()} running on stdio`);
59
+ return server;
60
+ }
61
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,SAAS,iBAAiB;IACxB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,OAAO,CAAC,oBAAoB,CAAyB,CAAC;QAClE,OAAO,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC;AAED,MAAM,mBAAmB,GAAG;IAC1B,wHAAwH;IACxH,gMAAgM;IAChM,iFAAiF;IACjF,gKAAgK;IAChK,4JAA4J;IAC5J,oKAAoK;CACrK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,UAAU,eAAe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