@nyx-intelligence/val-mcp 0.4.0 → 0.5.1
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/dist/index.js +4 -4
- package/dist/report.js +13 -3
- package/dist/session.js +34 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { scanSite, checkPage, screenshot } from "./scanner.js";
|
|
3
|
-
import { formatReport } from "./report.js";
|
|
3
|
+
import { formatReport, topFindings } from "./report.js";
|
|
4
4
|
import { session } from "./session.js";
|
|
5
5
|
function fmtAction(r) {
|
|
6
6
|
const lines = [`${r.ok ? "ok" : "warn"} · ${r.title || "(no title)"} · ${r.url}`];
|
|
@@ -66,7 +66,7 @@ async function runServer() {
|
|
|
66
66
|
const { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
|
|
67
67
|
const { chromium } = await import("playwright");
|
|
68
68
|
const { z } = await import("zod");
|
|
69
|
-
const server = new McpServer({ name: "val", version: "0.
|
|
69
|
+
const server = new McpServer({ name: "val", version: "0.5.0" });
|
|
70
70
|
const text = (t) => ({ content: [{ type: "text", text: t }] });
|
|
71
71
|
// ── Passive crawl ──
|
|
72
72
|
server.registerTool("val_scan", {
|
|
@@ -75,7 +75,7 @@ async function runServer() {
|
|
|
75
75
|
inputSchema: { url: z.string(), maxPages: z.number().int().min(1).max(50).optional(), device: z.string().optional().describe("Emulate a mobile device, e.g. 'iPhone 14' or 'Pixel 7'") },
|
|
76
76
|
}, async ({ url, maxPages, device }) => {
|
|
77
77
|
const { findings, pagesVisited } = await scanSite(url, { maxPages: maxPages ?? 12, device });
|
|
78
|
-
return text(`${formatReport(findings, pagesVisited)}\n\nJSON:\n${JSON.stringify(findings)}`);
|
|
78
|
+
return text(`${formatReport(findings, pagesVisited)}\n\nJSON:\n${JSON.stringify(topFindings(findings))}`);
|
|
79
79
|
});
|
|
80
80
|
server.registerTool("val_check", {
|
|
81
81
|
title: "Re-check one page (verify a fix)",
|
|
@@ -85,7 +85,7 @@ async function runServer() {
|
|
|
85
85
|
const browser = await chromium.launch({ headless: true });
|
|
86
86
|
try {
|
|
87
87
|
const { findings } = await checkPage(browser, url, { device });
|
|
88
|
-
return text(`${formatReport(findings, [url])}\n\nJSON:\n${JSON.stringify(findings)}`);
|
|
88
|
+
return text(`${formatReport(findings, [url])}\n\nJSON:\n${JSON.stringify(topFindings(findings))}`);
|
|
89
89
|
}
|
|
90
90
|
finally {
|
|
91
91
|
await browser.close();
|
package/dist/report.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
const RANK = { high: 0, medium: 1, low: 2 };
|
|
2
|
-
|
|
2
|
+
// Cap how many findings we surface so a very broken site can't blow up the
|
|
3
|
+
// calling agent's token budget. The full count is always reported; only the
|
|
4
|
+
// itemized list (and the JSON the agent parses) is capped to the top N.
|
|
5
|
+
const MAX_REPORT = 50;
|
|
6
|
+
export function topFindings(findings, n = MAX_REPORT) {
|
|
7
|
+
return [...findings].sort((a, b) => RANK[a.severity] - RANK[b.severity]).slice(0, n);
|
|
8
|
+
}
|
|
3
9
|
export function formatReport(findings, pagesVisited) {
|
|
4
10
|
const counts = { high: 0, medium: 0, low: 0 };
|
|
5
11
|
for (const f of findings)
|
|
@@ -12,11 +18,15 @@ export function formatReport(findings, pagesVisited) {
|
|
|
12
18
|
}
|
|
13
19
|
else {
|
|
14
20
|
lines.push("");
|
|
15
|
-
const
|
|
16
|
-
for (const f of
|
|
21
|
+
const shown = topFindings(findings);
|
|
22
|
+
for (const f of shown) {
|
|
17
23
|
lines.push(`[${f.severity.toUpperCase()}] ${f.type} — ${f.page}`);
|
|
18
24
|
lines.push(` ${f.detail}${f.evidence ? ` (${f.evidence})` : ""}`);
|
|
19
25
|
}
|
|
26
|
+
if (findings.length > shown.length) {
|
|
27
|
+
lines.push("");
|
|
28
|
+
lines.push(`… and ${findings.length - shown.length} more (capped to keep this small). Fix the above, then re-scan.`);
|
|
29
|
+
}
|
|
20
30
|
}
|
|
21
31
|
lines.push("");
|
|
22
32
|
lines.push("Pages crawled:");
|
package/dist/session.js
CHANGED
|
@@ -153,9 +153,41 @@ class ValSession {
|
|
|
153
153
|
const r = el.getBoundingClientRect();
|
|
154
154
|
return r.width > 0 && r.height > 0;
|
|
155
155
|
};
|
|
156
|
-
|
|
156
|
+
// Skip buttons that are toggles / segmented-control items / already-active
|
|
157
|
+
// controls — clicking them is a legitimate no-op, not a dead control.
|
|
158
|
+
const TOGGLE_ROLES = ["tab", "switch", "radio", "option", "menuitemradio", "menuitemcheckbox"];
|
|
159
|
+
const CONTAINER_ROLES = ["tablist", "radiogroup", "listbox", "menu", "tabs"];
|
|
160
|
+
const ACTIVE_CLASS = /(^|\s|-)(active|selected|is-active|is-selected|current|is-current)(\s|$|-)/i;
|
|
161
|
+
const isToggleLike = (el) => {
|
|
162
|
+
if (el.hasAttribute("disabled") || el.getAttribute("aria-disabled") === "true")
|
|
163
|
+
return true;
|
|
164
|
+
if (el.hasAttribute("aria-pressed") || el.hasAttribute("aria-selected"))
|
|
165
|
+
return true;
|
|
166
|
+
const ac = el.getAttribute("aria-current");
|
|
167
|
+
if (ac && ac !== "false")
|
|
168
|
+
return true;
|
|
169
|
+
const role = el.getAttribute("role");
|
|
170
|
+
if (role && TOGGLE_ROLES.indexOf(role) >= 0)
|
|
171
|
+
return true;
|
|
172
|
+
if (ACTIVE_CLASS.test(el.getAttribute("class") || ""))
|
|
173
|
+
return true;
|
|
174
|
+
let p = el.parentElement;
|
|
175
|
+
while (p) {
|
|
176
|
+
const r = p.getAttribute("role");
|
|
177
|
+
if (r && CONTAINER_ROLES.indexOf(r) >= 0)
|
|
178
|
+
return true;
|
|
179
|
+
p = p.parentElement;
|
|
180
|
+
}
|
|
181
|
+
return false;
|
|
182
|
+
};
|
|
183
|
+
const els = Array.from(document.querySelectorAll("button, [role=button]"))
|
|
184
|
+
.filter(isVisible)
|
|
185
|
+
.filter((el) => !isToggleLike(el));
|
|
157
186
|
els.forEach((el, i) => el.setAttribute("data-val-ex", `e${i}`));
|
|
158
|
-
return els.map((el, i) => ({
|
|
187
|
+
return els.map((el, i) => ({
|
|
188
|
+
ref: `e${i}`,
|
|
189
|
+
text: (el.innerText || el.getAttribute("aria-label") || "").trim().slice(0, 40),
|
|
190
|
+
}));
|
|
159
191
|
});
|
|
160
192
|
const buttons = await tag();
|
|
161
193
|
const dead = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nyx-intelligence/val-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Val — a 100% MCP QA agent for vibecoders. Drives a real browser to catch UX bugs (broken links, 404s, console errors, broken images) so your coding agent can fix them.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|