@arvyx/mcp 0.0.0-stage → 0.4.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 +77 -2
- package/cli.js +87 -0
- package/index.js +303 -0
- package/package.json +30 -4
- package/rules/arvyx.yml +393 -0
- package/scan.js +571 -0
package/README.md
CHANGED
|
@@ -1,3 +1,78 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Arvyx MCP & scanner — `@arvyx/mcp`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Security for the apps you build with AI, inside Claude Code, Codex and CI.
|
|
4
|
+
|
|
5
|
+
**The loop:** your agent builds → Arvyx scans (code + live site) → the agent fixes → Arvyx verifies.
|
|
6
|
+
|
|
7
|
+
## What it scans
|
|
8
|
+
|
|
9
|
+
| Engine | Finds | Install |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| Arvyx checks (built in) | Supabase tables without RLS and policies that let anyone change data (`using (true)` on insert/update/delete), open Firebase rules, committed / un-ignored `.env` files, secrets in `NEXT_PUBLIC_` / `VITE_` / `EXPO_PUBLIC_` variables, missing security headers | nothing |
|
|
12
|
+
| [Trivy](https://github.com/aquasecurity/trivy) | Vulnerable dependencies (grouped per package, with the upgrade target), Dockerfile / Terraform / Kubernetes misconfig, dependency inventory | `brew install trivy` |
|
|
13
|
+
| [Gitleaks](https://github.com/gitleaks/gitleaks) | Secrets in files **and in git history** | `brew install gitleaks` |
|
|
14
|
+
| [zizmor](https://github.com/zizmorcore/zizmor) | GitHub Actions risks: untrusted input in `run:` steps (template injection), `pull_request_target` misuse, over-broad `permissions:`; unpinned actions are reported as low | `brew install zizmor` |
|
|
15
|
+
| [Opengrep](https://github.com/opengrep/opengrep) | Insecure code (Arvyx's own rules in `rules/arvyx.yml`): request input flowing into SQL, shell commands, eval or deserialization (taint tracking, JS/TS + Python), unsafe HTML, open redirects, hard-coded / unverified JWTs, Supabase service key in client code, CORS, weak hashes | see Opengrep's install script |
|
|
16
|
+
|
|
17
|
+
Scanning runs **on your machine or CI runner**. Only results are uploaded — tool, rule, file, line, package
|
|
18
|
+
and versions. Never your code, never a secret value, never commit author details. A missing engine is
|
|
19
|
+
reported as "not installed" and its existing issues are left open (never silently passed).
|
|
20
|
+
|
|
21
|
+
Results become **issues** in Arvyx. An issue keeps its history, closes automatically when a scan of the
|
|
22
|
+
default branch no longer sees it, and reopens if it returns. Scans of other branches (PRs, feature
|
|
23
|
+
branches) are **previews**: they report what would be new or fixed without changing anything.
|
|
24
|
+
|
|
25
|
+
**Change-aware:** on a branch, `--changed` (and the MCP tool by default) runs only the engines the branch's
|
|
26
|
+
changes can affect — a lockfile change runs Trivy, a workflow change runs zizmor, code runs Opengrep;
|
|
27
|
+
Gitleaks and Arvyx's checks always run. An engine that did not run never closes an issue.
|
|
28
|
+
|
|
29
|
+
**Lifecycle:** open → in progress (`arvyx_start_fix`) → pending verification (`arvyx_mark_fix_submitted`,
|
|
30
|
+
with the commit / PR) → **verified fixed**, set only by a scan that no longer sees it. If it ever comes
|
|
31
|
+
back it reopens as a **regression**.
|
|
32
|
+
|
|
33
|
+
## Setup
|
|
34
|
+
|
|
35
|
+
Create an API key in Arvyx → **Settings → API keys** (shown once).
|
|
36
|
+
|
|
37
|
+
**Claude Code**
|
|
38
|
+
```bash
|
|
39
|
+
claude mcp add arvyx --env ARVYX_API_KEY=YOUR_KEY -- npx -y @arvyx/mcp
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Codex** (`~/.codex/config.toml`)
|
|
43
|
+
```toml
|
|
44
|
+
[mcp_servers.arvyx]
|
|
45
|
+
command = "npx"
|
|
46
|
+
args = ["-y", "@arvyx/mcp"]
|
|
47
|
+
env = { ARVYX_API_KEY = "YOUR_KEY" }
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Terminal / any CI**
|
|
51
|
+
```bash
|
|
52
|
+
ARVYX_API_KEY=YOUR_KEY npx -y -p @arvyx/mcp arvyx-scan [path] [--changed] [--fail-on high] [--json] [--no-upload]
|
|
53
|
+
```
|
|
54
|
+
Exit codes: `0` ok · `1` new issues at/above `--fail-on` · `2` error.
|
|
55
|
+
|
|
56
|
+
**GitHub Actions:** copy the workflow from Arvyx → Settings → Connect → CI. It installs pinned,
|
|
57
|
+
checksum-verified scanners; pushes to the default branch update issues, pull requests get one Arvyx
|
|
58
|
+
comment (updated on every push) showing what they add, fix or bring back, and fail only on new or
|
|
59
|
+
regressed high/critical issues. A weekly run catches newly published CVEs. Pull requests from forks get no
|
|
60
|
+
secrets, so they are scanned without uploading.
|
|
61
|
+
|
|
62
|
+
## Tools
|
|
63
|
+
|
|
64
|
+
| Tool | What it does |
|
|
65
|
+
|---|---|
|
|
66
|
+
| `arvyx_code_scan` | Scan this repo (dependencies, secrets incl. history, code, config) and update issues |
|
|
67
|
+
| `arvyx_issues` | Open issues for this repo — code plus the live domains linked to its project |
|
|
68
|
+
| `arvyx_issue` | One issue in full: evidence, impact, exact fix |
|
|
69
|
+
| `arvyx_start_fix` | Mark an issue in progress before working on it |
|
|
70
|
+
| `arvyx_mark_fix_submitted` | Tell Arvyx you fixed it (commit / PR); pending until a scan verifies it |
|
|
71
|
+
| `arvyx_scan` / `arvyx_verify` | Scan / re-scan a verified live domain (add `active_testing` for SQLi probes) |
|
|
72
|
+
| `arvyx_findings` / `arvyx_fix` | Findings of a live scan and their detail |
|
|
73
|
+
| `arvyx_report_events` | Send app security events for abuse detection |
|
|
74
|
+
| `arvyx_deepconfirm` | Sandbox exploit confirmation of a connected repo |
|
|
75
|
+
|
|
76
|
+
Env: `ARVYX_API_KEY` (required), `ARVYX_API_URL` (default: hosted API),
|
|
77
|
+
`ARVYX_TRIVY` / `ARVYX_GITLEAKS` / `ARVYX_OPENGREP` / `ARVYX_ZIZMOR` (binary paths), `ARVYX_REPO`,
|
|
78
|
+
`ARVYX_BRANCH`, `ARVYX_DEFAULT_BRANCH` (overrides for unusual setups). The pre-rename `SENTINEL_*` names are still read. Node 18+.
|
package/cli.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// arvyx-scan: scan a repository on this machine and upload the results to Arvyx.
|
|
3
|
+
// npx -y -p @arvyx/mcp arvyx-scan [path] [--changed] [--fail-on high] [--trigger ci] [--json] [--no-upload]
|
|
4
|
+
// Exit codes: 0 ok · 1 new issues at/above --fail-on · 2 error.
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import { envOf, report, scan, shouldFail, upload } from "./scan.js";
|
|
7
|
+
|
|
8
|
+
const args = process.argv.slice(2);
|
|
9
|
+
const flag = (name) => args.includes(`--${name}`);
|
|
10
|
+
const opt = (name, dflt) => { const i = args.indexOf(`--${name}`); return i >= 0 && args[i + 1] ? args[i + 1] : dflt; };
|
|
11
|
+
const valued = new Set(["--fail-on", "--trigger"]);
|
|
12
|
+
const dir = args.find((a, i) => !a.startsWith("--") && !valued.has(args[i - 1])) || process.cwd();
|
|
13
|
+
|
|
14
|
+
if (flag("help")) {
|
|
15
|
+
console.log(`arvyx-scan [path] [options]
|
|
16
|
+
|
|
17
|
+
Scans dependencies (trivy), secrets incl. git history (gitleaks), code patterns (opengrep) and
|
|
18
|
+
GitHub Actions workflows (zizmor) and Arvyx's own checks (Supabase RLS, Firebase rules, .env
|
|
19
|
+
hygiene, public env secrets, headers), then uploads results (never code or secret values) to your
|
|
20
|
+
Arvyx organization.
|
|
21
|
+
|
|
22
|
+
--changed on a branch: run only the engines the branch's changes can affect (vs its base)
|
|
23
|
+
--fail-on <sev> exit 1 if the scan finds NEW issues at or above: critical|high|medium|low|none (default none)
|
|
24
|
+
--trigger <t> cli | ci | mcp (default cli)
|
|
25
|
+
--json print the raw JSON response
|
|
26
|
+
--no-upload scan only, print the local results as JSON
|
|
27
|
+
|
|
28
|
+
Env: ARVYX_API_KEY (required to upload), ARVYX_API_URL, ARVYX_TRIVY/GITLEAKS/OPENGREP/ZIZMOR (binary
|
|
29
|
+
paths). In GitHub Actions, with GITHUB_TOKEN set (permission pull-requests: write), the result is
|
|
30
|
+
posted as one pull-request comment that is updated on every push, and written to the job summary.`);
|
|
31
|
+
process.exit(0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const log = (m) => console.error(`[arvyx] ${m}`);
|
|
35
|
+
|
|
36
|
+
// Returns the exit code. The caller sets process.exitCode (never process.exit), so piped stdout is
|
|
37
|
+
// fully flushed before Node exits.
|
|
38
|
+
async function main() {
|
|
39
|
+
const payload = await scan(dir, { trigger: opt("trigger", process.env.CI ? "ci" : "cli"), log, changed: flag("changed") });
|
|
40
|
+
if (flag("no-upload")) {
|
|
41
|
+
console.log(JSON.stringify(payload, null, 2));
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
const key = envOf("API_KEY");
|
|
45
|
+
if (!key && (process.env.GITHUB_EVENT_NAME || "").startsWith("pull_request")) {
|
|
46
|
+
// Pull requests from forks get no repository secrets: nothing to upload to, and not the author's fault.
|
|
47
|
+
log(`ARVYX_API_KEY is not available (a pull request from a fork?). Scanned ${payload.findings.length} result(s) locally; nothing uploaded.`);
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
if (!key) {
|
|
51
|
+
log("ARVYX_API_KEY is not set. Create one in Arvyx (Settings → API keys), or use --no-upload.");
|
|
52
|
+
return 2;
|
|
53
|
+
}
|
|
54
|
+
const base = envOf("API_URL") || "https://api.arvyx.site";
|
|
55
|
+
log(`uploading ${payload.findings.length} result(s) for ${payload.repo}…`);
|
|
56
|
+
const result = await upload(payload, { base, key, log });
|
|
57
|
+
console.log(flag("json") ? JSON.stringify(result, null, 2) : report(result, payload));
|
|
58
|
+
if (result.comment_markdown) await publish(result.comment_markdown, payload.pr_number);
|
|
59
|
+
const failOn = opt("fail-on", "none");
|
|
60
|
+
if (shouldFail(result, failOn)) {
|
|
61
|
+
log(`failing: new issue(s) at or above "${failOn}".`);
|
|
62
|
+
return 1;
|
|
63
|
+
}
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Job summary + one sticky pull-request comment (found again by its hidden marker). Best-effort: a
|
|
68
|
+
// comment that cannot be posted never changes the exit code.
|
|
69
|
+
async function publish(markdown, pr) {
|
|
70
|
+
if (process.env.GITHUB_STEP_SUMMARY) {
|
|
71
|
+
try { fs.appendFileSync(process.env.GITHUB_STEP_SUMMARY, markdown + "\n"); } catch { /* not fatal */ }
|
|
72
|
+
}
|
|
73
|
+
const token = process.env.GITHUB_TOKEN, repo = process.env.GITHUB_REPOSITORY;
|
|
74
|
+
if (!pr || !token || !repo) return;
|
|
75
|
+
const api = (process.env.GITHUB_API_URL || "https://api.github.com") + `/repos/${repo}/issues`;
|
|
76
|
+
const headers = { Authorization: `Bearer ${token}`, Accept: "application/vnd.github+json", "Content-Type": "application/json" };
|
|
77
|
+
const marker = markdown.split("\n")[0];
|
|
78
|
+
try {
|
|
79
|
+
const list = await fetch(`${api}/${pr}/comments?per_page=100`, { headers }).then((r) => (r.ok ? r.json() : []));
|
|
80
|
+
const mine = list.find((c) => typeof c.body === "string" && c.body.startsWith(marker));
|
|
81
|
+
const res = await fetch(mine ? `${api}/comments/${mine.id}` : `${api}/${pr}/comments`,
|
|
82
|
+
{ method: mine ? "PATCH" : "POST", headers, body: JSON.stringify({ body: markdown }) });
|
|
83
|
+
if (!res.ok) log(`could not post the pull-request comment (${res.status}); is "pull-requests: write" granted?`);
|
|
84
|
+
} catch (e) { log(`could not post the pull-request comment: ${e.message}`); }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
process.exitCode = await main().catch((e) => { log(`error: ${e.message}`); return 2; });
|
package/index.js
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Arvyx MCP server. Gives Claude Code / Codex tools to scan the code they are working on
|
|
3
|
+
// (dependencies, secrets, code patterns, config — scanned locally, only results uploaded), scan
|
|
4
|
+
// the live domains the user has verified, read persistent issues with their fixes, and verify.
|
|
5
|
+
// Auth is a single per-organization API key (ARVYX_API_KEY); it can reach only the
|
|
6
|
+
// /api/mcp/* endpoints, and only the caller's own organization.
|
|
7
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { envOf, repoFromRemote, report, scan, upload } from "./scan.js";
|
|
11
|
+
import { execFileSync } from "node:child_process";
|
|
12
|
+
|
|
13
|
+
const BASE = (envOf("API_URL") || "https://api.arvyx.site").replace(/\/$/, "");
|
|
14
|
+
const KEY = envOf("API_KEY");
|
|
15
|
+
if (!KEY) {
|
|
16
|
+
console.error("ARVYX_API_KEY is not set. Create one in the Arvyx dashboard (Settings → API keys) and pass it as an environment variable.");
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function call(method, path, body) {
|
|
21
|
+
const res = await fetch(BASE + path, {
|
|
22
|
+
method,
|
|
23
|
+
headers: { Authorization: `Bearer ${KEY}`, ...(body ? { "Content-Type": "application/json" } : {}) },
|
|
24
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
25
|
+
});
|
|
26
|
+
const text = await res.text();
|
|
27
|
+
let data;
|
|
28
|
+
try { data = text ? JSON.parse(text) : {}; } catch { data = { detail: text }; }
|
|
29
|
+
if (!res.ok) {
|
|
30
|
+
const d = data.detail;
|
|
31
|
+
throw new Error(typeof d === "string" ? d : d ? JSON.stringify(d) : `Request failed (${res.status})`);
|
|
32
|
+
}
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
37
|
+
|
|
38
|
+
// Start a scan (or verify), then poll until the assessment finishes.
|
|
39
|
+
async function runScan(path, target, active = false) {
|
|
40
|
+
const { scan_id } = await call("POST", path, { target, active_testing: active });
|
|
41
|
+
const deadline = Date.now() + (active ? 300000 : 120000); // active scans crawl + probe inputs
|
|
42
|
+
while (Date.now() < deadline) {
|
|
43
|
+
const s = await call("GET", `/api/mcp/scan/${scan_id}`);
|
|
44
|
+
if (s.status === "completed") {
|
|
45
|
+
return { scan_id, summary: s.summary, findings: await call("GET", `/api/mcp/scan/${scan_id}/findings`) };
|
|
46
|
+
}
|
|
47
|
+
if (s.status === "failed") throw new Error(s.error || "The scan failed.");
|
|
48
|
+
await sleep(2500);
|
|
49
|
+
}
|
|
50
|
+
throw new Error(`Scan ${scan_id} is still running. Call arvyx_findings with this scan_id in a moment.`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function summarize({ scan_id, summary, findings }) {
|
|
54
|
+
const sev = summary?.findings_by_severity || {};
|
|
55
|
+
const head =
|
|
56
|
+
`Scan ${scan_id} — grade ${summary?.grade ?? "?"} (${summary?.score ?? "?"}/100). ` +
|
|
57
|
+
`${summary?.total_findings ?? findings.length} findings ` +
|
|
58
|
+
`[critical ${sev.critical || 0}, high ${sev.high || 0}, medium ${sev.medium || 0}, low ${sev.low || 0}].`;
|
|
59
|
+
const lines = findings.map((f) => `- [${f.severity}] ${f.title} (id ${f.id})\n Fix: ${f.remediation}`);
|
|
60
|
+
return head + (lines.length ? "\n\n" + lines.join("\n") : "\n\nNo findings.");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const ok = (text) => ({ content: [{ type: "text", text }] });
|
|
64
|
+
const err = (text) => ({ content: [{ type: "text", text }], isError: true });
|
|
65
|
+
|
|
66
|
+
const server = new McpServer({ name: "arvyx", version: "0.4.0" }, {
|
|
67
|
+
instructions: "Arvyx finds security problems in the app you are building. Workflow: run arvyx_code_scan " +
|
|
68
|
+
"after changing dependencies, auth, database migrations, env/config files or API routes, and before finishing a " +
|
|
69
|
+
"task. Fix the issues it reports (arvyx_issue gives the evidence and the fix), call " +
|
|
70
|
+
"arvyx_start_fix before working on an issue and arvyx_mark_fix_submitted (with the commit / PR) after, then " +
|
|
71
|
+
"run arvyx_code_scan again: only a scan marks an issue fixed — never tell the user an issue is fixed before that. " +
|
|
72
|
+
"For the deployed site use arvyx_scan / arvyx_verify on the verified domain. Never print or commit secret values.",
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const LABELS = { fix_submitted: "pending verification", in_progress: "in progress", fixed: "verified fixed",
|
|
76
|
+
accepted_risk: "accepted risk", false_positive: "false positive" };
|
|
77
|
+
const label = (s) => LABELS[s] || s;
|
|
78
|
+
|
|
79
|
+
const where = (i) => {
|
|
80
|
+
const l = i.location || {};
|
|
81
|
+
return l.path ? l.path + (l.line ? `:${l.line}` : "") : (i.domain || l.domain || "");
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
function currentRepo() {
|
|
85
|
+
try {
|
|
86
|
+
const url = execFileSync("git", ["remote", "get-url", "origin"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
87
|
+
return repoFromRemote(url);
|
|
88
|
+
} catch { return null; }
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
server.registerTool(
|
|
92
|
+
"arvyx_scan",
|
|
93
|
+
{
|
|
94
|
+
description: "Run a Arvyx security assessment of a domain or URL your organization has verified. Returns a letter grade and findings with concrete fixes. Set active_testing to also run active checks (e.g. SQL injection probes that send crafted input) — non-destructive, proof-of-exposure only.",
|
|
95
|
+
inputSchema: {
|
|
96
|
+
target: z.string().describe("A domain or URL you have verified in Arvyx, e.g. example.com"),
|
|
97
|
+
active_testing: z.boolean().optional().describe("Also run active checks such as SQL injection detection (sends crafted input). Default false."),
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
async ({ target, active_testing }) => {
|
|
101
|
+
try { return ok(summarize(await runScan("/api/mcp/scan", target, !!active_testing))); }
|
|
102
|
+
catch (e) { return err(`Arvyx scan failed: ${e.message}`); }
|
|
103
|
+
},
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
server.registerTool(
|
|
107
|
+
"arvyx_findings",
|
|
108
|
+
{
|
|
109
|
+
description: "List the findings (with fixes) for a previous Arvyx scan id.",
|
|
110
|
+
inputSchema: { scan_id: z.string() },
|
|
111
|
+
},
|
|
112
|
+
async ({ scan_id }) => {
|
|
113
|
+
try {
|
|
114
|
+
const f = await call("GET", `/api/mcp/scan/${scan_id}/findings`);
|
|
115
|
+
return ok(f.length ? f.map((x) => `- [${x.severity}] ${x.title} (id ${x.id})\n Fix: ${x.remediation}`).join("\n") : "No findings for this scan.");
|
|
116
|
+
} catch (e) { return err(`Could not read findings: ${e.message}`); }
|
|
117
|
+
},
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
server.registerTool(
|
|
121
|
+
"arvyx_fix",
|
|
122
|
+
{
|
|
123
|
+
description: "Get the full detail, evidence and remediation for one Arvyx finding so you can fix it in the codebase.",
|
|
124
|
+
inputSchema: { finding_id: z.string() },
|
|
125
|
+
},
|
|
126
|
+
async ({ finding_id }) => {
|
|
127
|
+
try {
|
|
128
|
+
const f = await call("GET", `/api/mcp/findings/${finding_id}`);
|
|
129
|
+
return ok(`[${f.severity}] ${f.title}\n\nWhat it is: ${f.description}\n\nWhy it matters: ${f.business_impact}\n\nFix: ${f.remediation}\n\nEvidence: ${JSON.stringify(f.evidence)}`);
|
|
130
|
+
} catch (e) { return err(`Could not read finding: ${e.message}`); }
|
|
131
|
+
},
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
server.registerTool(
|
|
135
|
+
"arvyx_verify",
|
|
136
|
+
{
|
|
137
|
+
description: "Re-scan a verified domain to confirm that fixes landed. Returns the new grade and any remaining findings. Set active_testing to re-run active checks (e.g. to confirm a SQL injection fix).",
|
|
138
|
+
inputSchema: {
|
|
139
|
+
target: z.string().describe("A domain or URL you have verified in Arvyx"),
|
|
140
|
+
active_testing: z.boolean().optional().describe("Also re-run active checks such as SQL injection detection. Default false."),
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
async ({ target, active_testing }) => {
|
|
144
|
+
try { return ok(summarize(await runScan("/api/mcp/verify", target, !!active_testing))); }
|
|
145
|
+
catch (e) { return err(`Arvyx verify failed: ${e.message}`); }
|
|
146
|
+
},
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
server.registerTool(
|
|
150
|
+
"arvyx_report_events",
|
|
151
|
+
{
|
|
152
|
+
description: "Report security events from your app (failed logins, requests) so Arvyx can detect abuse — credential stuffing and abnormal request volume from one source — and alert you. Source IPs are hashed; no request bodies or secrets are stored.",
|
|
153
|
+
inputSchema: {
|
|
154
|
+
target: z.string().describe("A domain you have verified in Arvyx"),
|
|
155
|
+
events: z.array(z.object({
|
|
156
|
+
type: z.string().describe("Event type: failed_login, request, error, …"),
|
|
157
|
+
ip: z.string().optional().describe("Source IP (stored only as a hash)"),
|
|
158
|
+
endpoint: z.string().optional().describe("Request path"),
|
|
159
|
+
status: z.number().optional().describe("HTTP status code"),
|
|
160
|
+
at: z.string().optional().describe("ISO timestamp; defaults to now"),
|
|
161
|
+
})).describe("A batch of events (max 500)"),
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
async ({ target, events }) => {
|
|
165
|
+
try {
|
|
166
|
+
const r = await call("POST", "/api/mcp/events", { target, events });
|
|
167
|
+
return ok(`Reported ${r.ingested} event(s); ${r.alerts} new alert(s) raised.`);
|
|
168
|
+
} catch (e) { return err(`Could not report events: ${e.message}`); }
|
|
169
|
+
},
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
server.registerTool(
|
|
173
|
+
"arvyx_deepconfirm",
|
|
174
|
+
{
|
|
175
|
+
description: "PROVE what an attacker can do to this Supabase app's data. Arvyx applies the repo's supabase/migrations to a throwaway official Supabase database inside an isolated VM, creates two fake users, and actually tries: reading every user's rows without logging in, and reading, changing, deleting or impersonating another user's rows while logged in. Synthetic data only, every write rolled back, VM destroyed. Proven holes become Arvyx issues with the exact fix. Needs the repo's GitHub connected in Arvyx (Settings → Integrations). Takes about a minute.",
|
|
176
|
+
inputSchema: { repo: z.string().optional().describe("owner/name. Default: this repository's git remote.") },
|
|
177
|
+
},
|
|
178
|
+
async ({ repo }) => {
|
|
179
|
+
try {
|
|
180
|
+
const r = repo || currentRepo();
|
|
181
|
+
if (!r) return err("Could not tell which GitHub repository this is. Pass repo as owner/name.");
|
|
182
|
+
const { run_id } = await call("POST", "/api/mcp/deepconfirm", { repo: r });
|
|
183
|
+
const deadline = Date.now() + 300000;
|
|
184
|
+
while (Date.now() < deadline) {
|
|
185
|
+
const s = await call("GET", `/api/mcp/deepconfirm/${run_id}`);
|
|
186
|
+
if (s.status === "completed") {
|
|
187
|
+
const v = s.verdict || {};
|
|
188
|
+
const lines = [v.confirmed
|
|
189
|
+
? `PROVEN in a sandbox copy of ${r}'s database (${v.findings.length} hole${v.findings.length === 1 ? "" : "s"}):`
|
|
190
|
+
: `No data exposure proven in ${r}: every table tested behaved safely.`];
|
|
191
|
+
for (const f of v.findings || []) lines.push(`- ${f.detail}`);
|
|
192
|
+
const safe = (v.tables || []).filter((t) => t.safe).map((t) => t.table);
|
|
193
|
+
const skipped = (v.tables || []).filter((t) => !t.assessed);
|
|
194
|
+
if (safe.length) lines.push(`Safe: ${safe.join(", ")}.`);
|
|
195
|
+
if (skipped.length) lines.push(`Not assessed: ${skipped.map((t) => `${t.table} (${t.reason})`).join(", ")}.`);
|
|
196
|
+
if (v.migrations_failed) lines.push(`Note: ${v.migrations_failed} of ${v.migrations} migrations could not be applied in the sandbox, so some tables may be missing.`);
|
|
197
|
+
if (v.confirmed) lines.push("", "Each hole is now a Arvyx issue: use arvyx_issues to list them and arvyx_issue <id> for the exact fix, then run arvyx_deepconfirm again to verify.");
|
|
198
|
+
return ok(lines.join("\n"));
|
|
199
|
+
}
|
|
200
|
+
if (s.status === "failed") throw new Error(s.error || "the deep-confirm run failed");
|
|
201
|
+
await sleep(5000);
|
|
202
|
+
}
|
|
203
|
+
return ok(`Deep-confirm ${run_id} is still running; ask again in a minute.`);
|
|
204
|
+
} catch (e) { return err(`Deep-confirm failed: ${e.message}`); }
|
|
205
|
+
},
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
server.registerTool(
|
|
209
|
+
"arvyx_code_scan",
|
|
210
|
+
{
|
|
211
|
+
description: "Scan the code in this repository for security issues: vulnerable dependencies (trivy), secrets in files and git history (gitleaks), insecure code patterns (opengrep), GitHub Actions workflow risks (zizmor), and Arvyx's checks for AI-built stacks (Supabase tables without RLS, open Firebase rules, committed .env files, secrets in NEXT_PUBLIC_/VITE_ variables, missing security headers). Runs locally; only results (never code or secret values) are sent to Arvyx, which tracks them as issues. Re-run after fixing to verify — issues close only when a scan no longer sees them. Scans of a non-default branch are previews.",
|
|
212
|
+
inputSchema: {
|
|
213
|
+
path: z.string().optional().describe("Repository directory. Default: the current project."),
|
|
214
|
+
changed: z.boolean().optional().describe("On a feature branch, run only the engines this branch's changes can affect (faster). Default true; ignored on the default branch, which is always scanned in full."),
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
async ({ path, changed }) => {
|
|
218
|
+
try {
|
|
219
|
+
const payload = await scan(path || process.cwd(), { trigger: "mcp", changed: changed !== false });
|
|
220
|
+
const result = await upload(payload, { base: BASE, key: KEY });
|
|
221
|
+
return ok(report(result, payload) + "\n\nUse arvyx_issue <id> for evidence and the exact fix.");
|
|
222
|
+
} catch (e) { return err(`Arvyx code scan failed: ${e.message}`); }
|
|
223
|
+
},
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
server.registerTool(
|
|
227
|
+
"arvyx_issues",
|
|
228
|
+
{
|
|
229
|
+
description: "List the open Arvyx issues for this repository — code issues plus live-site issues of the domains linked to its project — most severe first.",
|
|
230
|
+
inputSchema: {
|
|
231
|
+
repo: z.string().optional().describe("owner/name. Default: this repository's git remote."),
|
|
232
|
+
status: z.string().optional().describe("Comma-separated: open, in_progress, fix_submitted, fixed, accepted_risk, false_positive. Default open,in_progress,fix_submitted."),
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
async ({ repo, status }) => {
|
|
236
|
+
try {
|
|
237
|
+
const r = repo || currentRepo();
|
|
238
|
+
const q = new URLSearchParams({ ...(r ? { repo: r } : {}), ...(status ? { status } : {}) });
|
|
239
|
+
const list = await call("GET", `/api/mcp/issues?${q}`);
|
|
240
|
+
if (!list.length) return ok(`No ${status || "open"} issues${r ? ` for ${r}` : ""}.`);
|
|
241
|
+
return ok(list.map((i) => `- [${i.severity}] ${i.title} ${where(i)} (${label(i.status)}, id ${i.id})` +
|
|
242
|
+
(i.linear_issue_url ? ` Linear ${i.linear_issue_url}` : "")).join("\n"));
|
|
243
|
+
} catch (e) { return err(`Could not list issues: ${e.message}`); }
|
|
244
|
+
},
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
server.registerTool(
|
|
248
|
+
"arvyx_issue",
|
|
249
|
+
{
|
|
250
|
+
description: "Get one Arvyx issue in full — what it is, why it matters, the evidence and exactly how to fix it — so you can fix it in the codebase.",
|
|
251
|
+
inputSchema: { issue_id: z.string() },
|
|
252
|
+
},
|
|
253
|
+
async ({ issue_id }) => {
|
|
254
|
+
try {
|
|
255
|
+
const i = await call("GET", `/api/mcp/issues/${issue_id}`);
|
|
256
|
+
const fix = i.fix_ref?.commit || i.fix_ref?.pr_url ? `\nFix submitted: ${[i.fix_ref.commit, i.fix_ref.pr_url].filter(Boolean).join(" ")}` : "";
|
|
257
|
+
const ver = i.status === "fixed" && i.verified_ref?.at
|
|
258
|
+
? `\nVerified fixed ${i.verified_ref.at.slice(0, 10)}${i.verified_ref.commit ? ` at ${i.verified_ref.commit.slice(0, 7)}` : ""}.` : "";
|
|
259
|
+
const hist = (i.history || []).map((h) => ` ${h.at.slice(0, 10)} ${h.from} → ${h.to}` +
|
|
260
|
+
(h.regression ? " (REGRESSION)" : "") + (h.commit ? ` at ${h.commit.slice(0, 7)}` : "") + ` by ${h.by}`).join("\n");
|
|
261
|
+
return ok(`[${i.severity}, ${label(i.status)}] ${i.title}\nWhere: ${where(i)}\n\nWhat it is: ${i.description}\n\n` +
|
|
262
|
+
`Why it matters: ${i.business_impact}\n\nFix: ${i.remediation}\n\nLocation: ${JSON.stringify(i.location)}\n` +
|
|
263
|
+
`Evidence: ${JSON.stringify(i.evidence)}\nFirst seen ${i.first_seen_at}, last seen ${i.last_seen_at}.` +
|
|
264
|
+
(i.reopened_count ? `\nRegressed ${i.reopened_count} time(s) after being fixed.` : "") + fix + ver +
|
|
265
|
+
(i.linear_issue_url ? `\nLinear: ${i.linear_issue_url}` : "") + (hist ? `\n\nHistory:\n${hist}` : ""));
|
|
266
|
+
} catch (e) { return err(`Could not read issue: ${e.message}`); }
|
|
267
|
+
},
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
server.registerTool(
|
|
271
|
+
"arvyx_start_fix",
|
|
272
|
+
{
|
|
273
|
+
description: "Tell Arvyx you are starting work on an open issue. It moves to 'in progress' (and its Linear ticket, if any). Call this before changing code for an issue.",
|
|
274
|
+
inputSchema: { issue_id: z.string() },
|
|
275
|
+
},
|
|
276
|
+
async ({ issue_id }) => {
|
|
277
|
+
try {
|
|
278
|
+
await call("POST", `/api/mcp/issues/${issue_id}/in-progress`);
|
|
279
|
+
return ok(`Issue ${issue_id} is in progress. Use arvyx_issue ${issue_id} for the exact fix.`);
|
|
280
|
+
} catch (e) { return err(`Could not update issue: ${e.message}`); }
|
|
281
|
+
},
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
server.registerTool(
|
|
285
|
+
"arvyx_mark_fix_submitted",
|
|
286
|
+
{
|
|
287
|
+
description: "Tell Arvyx you have fixed an issue. It moves to 'pending verification'; only a later scan of the default branch (or arvyx_verify for a live site) marks it fixed, or reopens it. Only call this after making the change; pass the commit and/or pull request.",
|
|
288
|
+
inputSchema: {
|
|
289
|
+
issue_id: z.string(),
|
|
290
|
+
commit: z.string().optional().describe("Commit SHA containing the fix"),
|
|
291
|
+
pr_url: z.string().optional().describe("Pull request URL, https://github.com/owner/repo/pull/N"),
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
async ({ issue_id, commit, pr_url }) => {
|
|
295
|
+
try {
|
|
296
|
+
await call("POST", `/api/mcp/issues/${issue_id}/fix-submitted`, commit || pr_url ? { commit, pr_url } : undefined);
|
|
297
|
+
return ok(`Issue ${issue_id} is pending verification. It is marked fixed only when a scan no longer sees it: ` +
|
|
298
|
+
"run arvyx_code_scan (code; on a branch it shows 'would fix') or arvyx_verify (live site).");
|
|
299
|
+
} catch (e) { return err(`Could not update issue: ${e.message}`); }
|
|
300
|
+
},
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
await server.connect(new StdioServerTransport());
|
package/package.json
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arvyx/mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Arvyx \u2014 security scanning for the apps you build with AI, inside Claude Code / Codex and CI.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"arvyx-mcp": "index.js",
|
|
9
|
+
"arvyx-scan": "cli.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"index.js",
|
|
13
|
+
"cli.js",
|
|
14
|
+
"scan.js",
|
|
15
|
+
"rules/",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18"
|
|
20
|
+
},
|
|
21
|
+
"license": "UNLICENSED",
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@modelcontextprotocol/sdk": "^1.18.0",
|
|
27
|
+
"zod": "^3.23.8"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test:rules": "node test/score_rules.mjs"
|
|
31
|
+
}
|
|
32
|
+
}
|