mcp-web-validator 1.3.56 → 1.3.58
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/CHANGELOG.md +25 -0
- package/README.md +19 -1
- package/SECURITY.md +10 -0
- package/dist/audit-history.js +2 -0
- package/dist/audit-history.js.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/language-subtags.js +2 -0
- package/dist/language-subtags.js.map +1 -1
- package/dist/mcp-bounds.js.map +1 -1
- package/dist/modules/browser-ux/axe-review.js +2 -0
- package/dist/modules/browser-ux/axe-review.js.map +1 -1
- package/dist/modules/browser-ux/lighthouse-lab-probe.js +2 -0
- package/dist/modules/browser-ux/lighthouse-lab-probe.js.map +1 -1
- package/dist/modules/browser-ux/lighthouse-lab.js +2 -0
- package/dist/modules/browser-ux/lighthouse-lab.js.map +1 -1
- package/dist/modules/browser-ux/media-diagnostics.js +2 -0
- package/dist/modules/browser-ux/media-diagnostics.js.map +1 -1
- package/dist/modules/browser-ux/raw-rendered-diff.js +90 -40
- package/dist/modules/browser-ux/raw-rendered-diff.js.map +1 -1
- package/dist/modules/browser-ux/raw-rendered-probe.js +18 -0
- package/dist/modules/browser-ux/raw-rendered-probe.js.map +1 -1
- package/dist/modules/browser-ux/resource-failures-probe.js +2 -0
- package/dist/modules/browser-ux/resource-failures-probe.js.map +1 -1
- package/dist/modules/browser-ux/resource-failures.js +2 -0
- package/dist/modules/browser-ux/resource-failures.js.map +1 -1
- package/dist/modules/browser-ux/viewport-parity-probe.js +2 -0
- package/dist/modules/browser-ux/viewport-parity-probe.js.map +1 -1
- package/dist/modules/browser-ux/viewport-parity.js +2 -0
- package/dist/modules/browser-ux/viewport-parity.js.map +1 -1
- package/dist/modules/browser-ux/wcag-interactions.js +2 -0
- package/dist/modules/browser-ux/wcag-interactions.js.map +1 -1
- package/dist/modules/change-regression/availability-history-store.js +2 -0
- package/dist/modules/change-regression/availability-history-store.js.map +1 -1
- package/dist/modules/change-regression/crawler-log-correlation.js +2 -0
- package/dist/modules/change-regression/crawler-log-correlation.js.map +1 -1
- package/dist/modules/change-regression/google-common-crawler-ip.js +2 -0
- package/dist/modules/change-regression/google-common-crawler-ip.js.map +1 -1
- package/dist/modules/change-regression/historical-comparisons.js +2 -0
- package/dist/modules/change-regression/historical-comparisons.js.map +1 -1
- package/dist/modules/change-regression/production-change-comparison.js +2 -0
- package/dist/modules/change-regression/production-change-comparison.js.map +1 -1
- package/dist/modules/change-regression/regression-alerts.js.map +1 -1
- package/dist/modules/change-regression/strict-observation-time.js +2 -0
- package/dist/modules/change-regression/strict-observation-time.js.map +1 -1
- package/dist/modules/content-schema/citation-methodology-consistency.js +2 -0
- package/dist/modules/content-schema/citation-methodology-consistency.js.map +1 -1
- package/dist/modules/content-schema/competitor-intent-comparison.js.map +1 -1
- package/dist/modules/content-schema/empty-boilerplate-content.js +2 -0
- package/dist/modules/content-schema/empty-boilerplate-content.js.map +1 -1
- package/dist/modules/content-schema/extract-citation-methodology.js +2 -0
- package/dist/modules/content-schema/extract-citation-methodology.js.map +1 -1
- package/dist/modules/content-schema/extract-competitor-intent.js +2 -0
- package/dist/modules/content-schema/extract-competitor-intent.js.map +1 -1
- package/dist/modules/content-schema/extract-main-content.js +2 -0
- package/dist/modules/content-schema/extract-main-content.js.map +1 -1
- package/dist/modules/content-schema/extract-metadata-consistency.js +2 -0
- package/dist/modules/content-schema/extract-metadata-consistency.js.map +1 -1
- package/dist/modules/content-schema/extract-product-claims.js +4 -1
- package/dist/modules/content-schema/extract-product-claims.js.map +1 -1
- package/dist/modules/content-schema/extract-structured-data.js +2 -0
- package/dist/modules/content-schema/extract-structured-data.js.map +1 -1
- package/dist/modules/content-schema/metadata-consistency.js +2 -0
- package/dist/modules/content-schema/metadata-consistency.js.map +1 -1
- package/dist/modules/content-schema/product-claims.js.map +1 -1
- package/dist/modules/content-schema/same-language-duplicates.js.map +1 -1
- package/dist/modules/content-schema/structured-data-validation.js +2 -0
- package/dist/modules/content-schema/structured-data-validation.js.map +1 -1
- package/dist/modules/external-metrics/crux-field-probe.js +2 -0
- package/dist/modules/external-metrics/crux-field-probe.js.map +1 -1
- package/dist/modules/external-metrics/crux-field.js +2 -0
- package/dist/modules/external-metrics/crux-field.js.map +1 -1
- package/dist/modules/http-crawl/availability-observations.d.ts +0 -5
- package/dist/modules/http-crawl/availability-observations.js +8 -17
- package/dist/modules/http-crawl/availability-observations.js.map +1 -1
- package/dist/modules/http-crawl/availability-probe.js.map +1 -1
- package/dist/modules/http-crawl/crawler-access-probe.js +2 -0
- package/dist/modules/http-crawl/crawler-access-probe.js.map +1 -1
- package/dist/modules/http-crawl/crawler-access.js +2 -0
- package/dist/modules/http-crawl/crawler-access.js.map +1 -1
- package/dist/modules/http-crawl/http-delivery-probe.js +2 -0
- package/dist/modules/http-crawl/http-delivery-probe.js.map +1 -1
- package/dist/modules/http-crawl/http-delivery.js +4 -1
- package/dist/modules/http-crawl/http-delivery.js.map +1 -1
- package/dist/modules/http-crawl/https-security.js +2 -0
- package/dist/modules/http-crawl/https-security.js.map +1 -1
- package/dist/modules/http-crawl/non-html-directives.js +44 -14
- package/dist/modules/http-crawl/non-html-directives.js.map +1 -1
- package/dist/modules/http-crawl/redirect-canonical-chains.js +2 -0
- package/dist/modules/http-crawl/redirect-canonical-chains.js.map +1 -1
- package/dist/modules/http-crawl/redirect-canonical-probe.js +2 -0
- package/dist/modules/http-crawl/redirect-canonical-probe.js.map +1 -1
- package/dist/modules/http-crawl/sitemap-inventory-probe.js +2 -0
- package/dist/modules/http-crawl/sitemap-inventory-probe.js.map +1 -1
- package/dist/modules/http-crawl/sitemap-inventory.js +21 -2
- package/dist/modules/http-crawl/sitemap-inventory.js.map +1 -1
- package/dist/modules/http-crawl/url-variants.js +2 -0
- package/dist/modules/http-crawl/url-variants.js.map +1 -1
- package/dist/modules/site-architecture/extract-internal-links.js +38 -4
- package/dist/modules/site-architecture/extract-internal-links.js.map +1 -1
- package/dist/modules/site-architecture/extract-multilingual-page.js +2 -0
- package/dist/modules/site-architecture/extract-multilingual-page.js.map +1 -1
- package/dist/modules/site-architecture/internal-link-graph-probe.js +2 -0
- package/dist/modules/site-architecture/internal-link-graph-probe.js.map +1 -1
- package/dist/modules/site-architecture/internal-link-graph.js +2 -0
- package/dist/modules/site-architecture/internal-link-graph.js.map +1 -1
- package/dist/modules/site-architecture/internal-link-quality.js +2 -0
- package/dist/modules/site-architecture/internal-link-quality.js.map +1 -1
- package/dist/modules/site-architecture/multilingual-clusters.js +2 -0
- package/dist/modules/site-architecture/multilingual-clusters.js.map +1 -1
- package/dist/network-protocol.d.ts +3 -0
- package/dist/network-protocol.js +9 -0
- package/dist/network-protocol.js.map +1 -0
- package/dist/network.js +12 -0
- package/dist/network.js.map +1 -1
- package/dist/nu-ephemeral.d.ts +2 -0
- package/dist/nu-ephemeral.js +126 -0
- package/dist/nu-ephemeral.js.map +1 -0
- package/dist/presentation.js +3 -1
- package/dist/presentation.js.map +1 -1
- package/dist/report.js +4 -2
- package/dist/report.js.map +1 -1
- package/dist/screenshot-proxy.js +2 -0
- package/dist/screenshot-proxy.js.map +1 -1
- package/dist/screenshot.d.ts +1 -1
- package/dist/screenshot.js +3 -1
- package/dist/screenshot.js.map +1 -1
- package/dist/seo-auditor.js +20 -10
- package/dist/seo-auditor.js.map +1 -1
- package/dist/stylelint-validator.js +2 -0
- package/dist/stylelint-validator.js.map +1 -1
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -1
- package/dist/visual-diff.js +9 -1
- package/dist/visual-diff.js.map +1 -1
- package/dist/w3c-validator.js +20 -5
- package/dist/w3c-validator.js.map +1 -1
- package/docs/reliability-engines-20261123.md +156 -0
- package/package.json +8 -4
- package/scripts/deep-audit-optional.mjs +198 -0
package/dist/visual-diff.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Copyright (c) 2026 AKzar1el and Web Validator contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import * as fs from "node:fs/promises";
|
|
2
4
|
import * as path from "node:path";
|
|
3
5
|
import { resolveLocalFileWithinWorkspaceRoot } from "./network.js";
|
|
@@ -38,8 +40,14 @@ export async function compareScreenshotWithBaseline(capture, referenceDirectory)
|
|
|
38
40
|
const scoped = await resolveLocalFileWithinWorkspaceRoot(reference);
|
|
39
41
|
const [baselineBytes, freshBytes] = await Promise.all([
|
|
40
42
|
boundedPng(scoped),
|
|
41
|
-
boundedPng(capture.outputPath)
|
|
43
|
+
boundedPng(capture.outputPath).catch((cause) => {
|
|
44
|
+
if (cause.code === "ENOENT")
|
|
45
|
+
return null;
|
|
46
|
+
throw cause;
|
|
47
|
+
}),
|
|
42
48
|
]);
|
|
49
|
+
if (!freshBytes)
|
|
50
|
+
return { status: "unavailable" };
|
|
43
51
|
const original = pngDimensions(baselineBytes);
|
|
44
52
|
const actual = pngDimensions(freshBytes);
|
|
45
53
|
if (original.width !== actual.width || original.height !== actual.height
|
package/dist/visual-diff.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visual-diff.js","sourceRoot":"","sources":["../src/visual-diff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,mCAAmC,EAAE,MAAM,cAAc,CAAC;AAGnE,mFAAmF;AACnF,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAChD,MAAM,CAAC,MAAM,yBAAyB,GAAG,UAAU,CAAC;AAiBpD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AAElE,SAAS,aAAa,CAAC,MAAc;IACnC,IAAI,MAAM,CAAC,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM,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,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IAClD,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// Copyright (c) 2026 AKzar1el and Web Validator contributors\n// SPDX-License-Identifier: MIT\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { resolveLocalFileWithinWorkspaceRoot } from \"./network.js\";\nimport type { ScreenshotResult } from \"./screenshot.js\";\n\n/** Avoid decoding images larger than a normal 1080p viewport on an 8 GB laptop. */\nexport const MAX_VISUAL_DIFF_PIXELS = 2_073_600;\nexport const MAX_VISUAL_DIFF_PNG_BYTES = 12_000_000;\n\nexport type VisualDiffStatus =\n | \"compared\"\n | \"missing_baseline\"\n | \"dimension_mismatch\"\n | \"over_budget\"\n | \"incomplete_capture\"\n | \"unavailable\";\n\nexport interface VisualDiffResult {\n status: VisualDiffStatus;\n changed_pixels?: number;\n changed_percent?: number;\n pixels_compared?: number;\n}\n\nconst PNG_HEADER = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);\n\nfunction pngDimensions(buffer: Buffer): { width: number; height: number } {\n if (buffer.length < 24 || !buffer.subarray(0, 8).equals(PNG_HEADER)\n || buffer.toString(\"ascii\", 12, 16) !== \"IHDR\") {\n throw new Error(\"Invalid PNG baseline\");\n }\n const width = buffer.readUInt32BE(16);\n const height = buffer.readUInt32BE(20);\n if (!width || !height || width * height > MAX_VISUAL_DIFF_PIXELS) {\n throw new Error(\"PNG pixel dimensions exceed visual diff safety budget\");\n }\n return { width, height };\n}\n\nasync function boundedPng(pathname: string): Promise<Buffer> {\n const info = await fs.lstat(pathname);\n if (!info.isFile() || info.isSymbolicLink()\n || info.size < 24 || info.size > MAX_VISUAL_DIFF_PNG_BYTES) {\n throw new Error(\"PNG is not a bounded regular file\");\n }\n return fs.readFile(pathname);\n}\n\n/** Compare one screenshot with a same-named baseline; no image bytes or DOM values escape. */\nexport async function compareScreenshotWithBaseline(\n capture: ScreenshotResult,\n referenceDirectory: string,\n): Promise<VisualDiffResult> {\n if (capture.incompleteAssetCount) return { status: \"incomplete_capture\" };\n if (capture.width * capture.height > MAX_VISUAL_DIFF_PIXELS) {\n return { status: \"over_budget\" };\n }\n const reference = path.join(referenceDirectory, path.basename(capture.outputPath));\n try {\n // This also enforces an opt-in workspace root after resolving symlinks.\n const scoped = await resolveLocalFileWithinWorkspaceRoot(reference);\n const [baselineBytes, freshBytes] = await Promise.all([\n boundedPng(scoped),\n boundedPng(capture.outputPath).catch((cause: unknown) => {\n if ((cause as NodeJS.ErrnoException).code === \"ENOENT\") return null;\n throw cause;\n }),\n ]);\n if (!freshBytes) return { status: \"unavailable\" };\n const original = pngDimensions(baselineBytes);\n const actual = pngDimensions(freshBytes);\n if (original.width !== actual.width || original.height !== actual.height\n || actual.width !== capture.width || actual.height !== capture.height) {\n return { status: \"dimension_mismatch\" };\n }\n const [{ PNG }, { default: pixelmatch }] = await Promise.all([\n import(\"pngjs\"),\n import(\"pixelmatch\"),\n ]);\n const before = PNG.sync.read(baselineBytes);\n const after = PNG.sync.read(freshBytes);\n if (before.width !== original.width || before.height !== original.height\n || after.width !== actual.width || after.height !== actual.height) {\n return { status: \"unavailable\" };\n }\n const changed = pixelmatch(before.data, after.data, null, actual.width, actual.height, {\n threshold: 0.1,\n includeAA: false,\n });\n const pixels = actual.width * actual.height;\n return {\n status: \"compared\",\n changed_pixels: changed,\n pixels_compared: pixels,\n changed_percent: Math.round(changed * 10000 / pixels) / 100,\n };\n } catch (cause) {\n if ((cause as NodeJS.ErrnoException).code === \"ENOENT\") {\n return { status: \"missing_baseline\" };\n }\n return { status: \"unavailable\" };\n }\n}\n\n/** Validate baseline location before rendering, so a baseline cannot be overwritten accidentally. */\nexport async function resolveVisualReferenceDirectory(\n baselineDirectory: string,\n outputDirectory: string,\n): Promise<string> {\n const directory = await resolveLocalFileWithinWorkspaceRoot(baselineDirectory);\n const real = await fs.realpath(directory);\n if (!(await fs.stat(real)).isDirectory()) {\n throw new Error(\"Visual baseline must be an existing directory\");\n }\n const output = await fs.realpath(outputDirectory);\n if (real === output) {\n throw new Error(\"Visual baseline directory must differ from screenshot output directory\");\n }\n return real;\n}\n"]}
|
package/dist/w3c-validator.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
// Copyright (c) 2026 AKzar1el and Web Validator contributors
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import { cancelResponseBody, getErrorMessage, readResponseText, } from "./network.js";
|
|
2
4
|
import { PACKAGE_VERSION } from "./version.js";
|
|
5
|
+
import { withEphemeralNuChecker } from "./nu-ephemeral.js";
|
|
3
6
|
export function getW3CMessageSeverity(message) {
|
|
4
7
|
const type = message.type.trim().toLowerCase();
|
|
5
8
|
if (type === "error" || type === "non-document-error")
|
|
@@ -135,16 +138,28 @@ async function validateHtmlAtLocalNu(html, mediaType, url) {
|
|
|
135
138
|
checker: "nu_local",
|
|
136
139
|
};
|
|
137
140
|
}
|
|
141
|
+
function configuredLocalNuJava() {
|
|
142
|
+
const java = process.env.MCP_WEB_VALIDATOR_NU_JAVA_PATH?.trim();
|
|
143
|
+
return java || undefined;
|
|
144
|
+
}
|
|
145
|
+
async function validateHtmlAtAvailableLocalNu(html, mediaType, httpUrl, javaExecutable) {
|
|
146
|
+
if (httpUrl)
|
|
147
|
+
return validateHtmlAtLocalNu(html, mediaType, httpUrl);
|
|
148
|
+
if (javaExecutable) {
|
|
149
|
+
return withEphemeralNuChecker(javaExecutable, (url) => validateHtmlAtLocalNu(html, mediaType, url));
|
|
150
|
+
}
|
|
151
|
+
throw new Error("Local Nu requires MCP_WEB_VALIDATOR_NU_JAVA_PATH (on-demand Java 17+ runtime) " +
|
|
152
|
+
"or MCP_WEB_VALIDATOR_NU_LOCAL_URL (loopback service)");
|
|
153
|
+
}
|
|
138
154
|
/** Validates HTML/XHTML using the W3C Nu HTML Checker API and retains bounded-output metadata. */
|
|
139
155
|
export async function validateHtmlContentDetailed(htmlContent, mediaType = "text/html", checker = "auto") {
|
|
140
156
|
const url = "https://validator.w3.org/nu/?out=json";
|
|
141
157
|
try {
|
|
142
158
|
assertContentSize(htmlContent, MAX_HTML_BYTES, "HTML content");
|
|
143
159
|
const local = checker !== "remote" ? configuredLocalNuUrl() : undefined;
|
|
160
|
+
const localJava = checker !== "remote" ? configuredLocalNuJava() : undefined;
|
|
144
161
|
if (checker === "local") {
|
|
145
|
-
|
|
146
|
-
throw new Error("Local Nu validation requires MCP_WEB_VALIDATOR_NU_LOCAL_URL");
|
|
147
|
-
return await validateHtmlAtLocalNu(htmlContent, mediaType, local);
|
|
162
|
+
return await validateHtmlAtAvailableLocalNu(htmlContent, mediaType, local, localJava);
|
|
148
163
|
}
|
|
149
164
|
try {
|
|
150
165
|
const response = await fetch(url, {
|
|
@@ -165,9 +180,9 @@ export async function validateHtmlContentDetailed(htmlContent, mediaType = "text
|
|
|
165
180
|
return normalizeNuHtmlPayload(await readResponseText(response, MAX_VALIDATOR_RESPONSE_BYTES));
|
|
166
181
|
}
|
|
167
182
|
catch (cause) {
|
|
168
|
-
if (checker !== "auto" || !local || !isTransientNuFailure(cause))
|
|
183
|
+
if (checker !== "auto" || !(local || localJava) || !isTransientNuFailure(cause))
|
|
169
184
|
throw cause;
|
|
170
|
-
return await
|
|
185
|
+
return await validateHtmlAtAvailableLocalNu(htmlContent, mediaType, local, localJava);
|
|
171
186
|
}
|
|
172
187
|
}
|
|
173
188
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"w3c-validator.js","sourceRoot":"","sources":["../src/w3c-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAA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K,CAAC,0BAA0B,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACtE,CAAC;AACH,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,UAAkB;IACzD,OAAO,CAAC,MAAM,0BAA0B,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC;AACjE,CAAC","sourcesContent":["import {\n cancelResponseBody,\n getErrorMessage,\n readResponseText,\n} from \"./network.js\";\nimport { PACKAGE_VERSION } from \"./version.js\";\n\nexport interface W3CMessage {\n type: string;\n subType?: string;\n lastLine?: number;\n lastColumn?: number;\n firstLine?: number;\n firstColumn?: number;\n message: string;\n extract?: string;\n}\n\nexport type W3CMessageSeverity = \"error\" | \"warning\" | \"info\";\nexport type HtmlValidationMediaType = \"text/html\" | \"application/xhtml+xml\";\n\nexport interface HtmlValidationResult {\n messages: W3CMessage[];\n total: number;\n truncated: boolean;\n counts: Record<W3CMessageSeverity, number>;\n checker?: \"w3c_remote\" | \"nu_local\";\n}\nexport type HtmlCheckerMode = \"auto\" | \"remote\" | \"local\";\n\nexport function getW3CMessageSeverity(\n message: Pick<W3CMessage, \"type\" | \"subType\">,\n): W3CMessageSeverity {\n const type = message.type.trim().toLowerCase();\n if (type === \"error\" || type === \"non-document-error\") return \"error\";\n if (type === \"warning\" || (type === \"info\" && message.subType?.trim().toLowerCase() === \"warning\")) {\n return \"warning\";\n }\n return \"info\";\n}\n\nexport interface CSSMessage {\n line: number;\n type: string;\n message: string;\n context?: string;\n compatibility?: \"known-validator-limitation\";\n}\n\nexport interface CssValidationResult {\n messages: CSSMessage[];\n total: number;\n truncated: boolean;\n counts: {\n error: number;\n warning?: number;\n compatibilityLimitation: number;\n };\n}\n\nconst VALIDATOR_TIMEOUT_MS = 20_000;\nconst MAX_HTML_BYTES = 2_000_000;\nexport const MAX_CSS_VALIDATION_BYTES = 128_000;\nconst MAX_VALIDATOR_RESPONSE_BYTES = 5_000_000;\nconst USER_AGENT = `mcp-web-validator/${PACKAGE_VERSION} (+https://digestseo.com/validator-mcp/)`;\nexport const MAX_VALIDATION_MESSAGES = 200;\nconst MAX_HTML_EXTRACT_CHARS = 500;\nconst MAX_DIAGNOSTIC_MESSAGE_CHARS = 1_000;\nconst MAX_CSS_CONTEXT_CHARS = 500;\nconst MAX_DIAGNOSTIC_SUBTYPE_CHARS = 64;\n\nfunction boundDiagnosticText(text: string, maxChars: number): string {\n return text.length > maxChars ? `${text.slice(0, maxChars - 3)}...` : text;\n}\n\nfunction isKnownCssValidatorLimitation(type: string | undefined, message: string): boolean {\n if (type?.trim().toLowerCase() !== \"at-rule\") return false;\n const normalized = message.trim().toLowerCase().replace(/[“”\"'‘’]/g, \"\");\n return normalized === \"unrecognized at-rule @container\";\n}\n\nfunction normalizeCssDiagnosticMessage(value: unknown, fallback: string): string {\n const message = typeof value === \"string\" ? value.trim() : \"\";\n return boundDiagnosticText(message || fallback, MAX_DIAGNOSTIC_MESSAGE_CHARS);\n}\n\nfunction normalizeCssDiagnosticLine(value: unknown): number {\n return typeof value === \"number\" && Number.isSafeInteger(value) && value >= 0 ? value : 0;\n}\n\nfunction assertContentSize(content: string, maxBytes: number, label: string): void {\n const size = Buffer.byteLength(content, \"utf8\");\n if (size > maxBytes) {\n throw new Error(`${label} exceeds the ${maxBytes}-byte validation limit`);\n }\n}\n\nfunction normalizeW3CMessage(message: unknown): W3CMessage {\n if (typeof message !== \"object\" || message === null) {\n throw new Error(\"W3C HTML validator returned a malformed message\");\n }\n\n const candidate = message as Record<string, unknown>;\n if (typeof candidate.type !== \"string\" || typeof candidate.message !== \"string\" || !candidate.message.trim()) {\n throw new Error(\"W3C HTML validator returned a malformed message\");\n }\n const type = candidate.type.trim().toLowerCase();\n if (![\"error\", \"warning\", \"info\", \"non-document-error\"].includes(type)) {\n throw new Error(\"W3C HTML validator returned a malformed message\");\n }\n\n const normalized: W3CMessage = {\n type,\n message: boundDiagnosticText(candidate.message, MAX_DIAGNOSTIC_MESSAGE_CHARS),\n };\n\n for (const field of [\"lastLine\", \"lastColumn\", \"firstLine\", \"firstColumn\"] as const) {\n if (typeof candidate[field] === \"number\" && Number.isSafeInteger(candidate[field]) && candidate[field] >= 0) {\n normalized[field] = candidate[field];\n }\n }\n\n if (typeof candidate.extract === \"string\") {\n normalized.extract = boundDiagnosticText(candidate.extract, MAX_HTML_EXTRACT_CHARS);\n }\n\n if (typeof candidate.subType === \"string\") {\n normalized.subType = boundDiagnosticText(candidate.subType.trim(), MAX_DIAGNOSTIC_SUBTYPE_CHARS);\n }\n\n return normalized;\n}\n\nfunction normalizeNuHtmlPayload(text: string): HtmlValidationResult {\n const data: unknown = JSON.parse(text);\n if (!data || typeof data !== \"object\" || !(\"messages\" in data)\n || !Array.isArray(data.messages)) {\n throw new Error(\"W3C HTML validator returned an invalid response shape\");\n }\n const normalized = data.messages.map(normalizeW3CMessage);\n if (normalized.some((item) => item.type === \"non-document-error\")) {\n throw new Error(\"W3C HTML validator could not complete validation (non-document-error)\");\n }\n const counts: HtmlValidationResult[\"counts\"] = { error: 0, warning: 0, info: 0 };\n for (const item of normalized) counts[getW3CMessageSeverity(item)] += 1;\n return {\n messages: normalized.slice(0, MAX_VALIDATION_MESSAGES),\n total: normalized.length,\n truncated: normalized.length > MAX_VALIDATION_MESSAGES,\n counts,\n };\n}\n\n/** Only a user-configured loopback Nu HTTP service may receive local fallback markup. */\nfunction configuredLocalNuUrl(): string | undefined {\n const setting = process.env.MCP_WEB_VALIDATOR_NU_LOCAL_URL?.trim();\n if (!setting) return undefined;\n let url: URL;\n try {\n url = new URL(setting);\n } catch {\n throw new Error(\"MCP_WEB_VALIDATOR_NU_LOCAL_URL is not a valid URL\");\n }\n if (url.protocol !== \"http:\" || ![\"127.0.0.1\", \"[::1]\"].includes(url.hostname)\n || url.username || url.password || url.hash\n || ![\"/\", \"/nu/\"].includes(url.pathname)\n || [...url.searchParams.keys()].some((key) => key !== \"out\")) {\n throw new Error(\"MCP_WEB_VALIDATOR_NU_LOCAL_URL must be an HTTP loopback-only Nu endpoint\");\n }\n url.search = \"?out=json\";\n return url.href;\n}\n\nfunction isTransientNuFailure(error: unknown): boolean {\n if (error instanceof TypeError) return true;\n if (!(error instanceof Error)) return false;\n return /(?:timeout|timed out|abort|fetch failed|HTTP status (?:206|408|429|5\\d\\d))/i.test(error.message);\n}\n\nasync function validateHtmlAtLocalNu(\n html: string,\n mediaType: HtmlValidationMediaType,\n url: string,\n): Promise<HtmlValidationResult> {\n const response = await fetch(url, {\n method: \"POST\",\n headers: { \"Content-Type\": mediaType + \"; charset=utf-8\", \"User-Agent\": USER_AGENT },\n body: html,\n redirect: \"error\",\n signal: AbortSignal.timeout(12_000),\n });\n if (!response.ok || response.status === 206) {\n await cancelResponseBody(response);\n throw new Error(\"Local Nu HTML checker returned HTTP status \" + response.status);\n }\n return {\n ...normalizeNuHtmlPayload(await readResponseText(response, MAX_VALIDATOR_RESPONSE_BYTES)),\n checker: \"nu_local\",\n };\n}\n\n/** Validates HTML/XHTML using the W3C Nu HTML Checker API and retains bounded-output metadata. */\nexport async function validateHtmlContentDetailed(\n htmlContent: string,\n mediaType: HtmlValidationMediaType = \"text/html\",\n checker: HtmlCheckerMode = \"auto\",\n): Promise<HtmlValidationResult> {\n const url = \"https://validator.w3.org/nu/?out=json\";\n\n try {\n assertContentSize(htmlContent, MAX_HTML_BYTES, \"HTML content\");\n const local = checker !== \"remote\" ? configuredLocalNuUrl() : undefined;\n if (checker === \"local\") {\n if (!local) throw new Error(\"Local Nu validation requires MCP_WEB_VALIDATOR_NU_LOCAL_URL\");\n return await validateHtmlAtLocalNu(htmlContent, mediaType, local);\n }\n try {\n const response = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": `${mediaType}; charset=utf-8`,\n \"User-Agent\": USER_AGENT,\n },\n body: htmlContent,\n redirect: \"error\",\n signal: AbortSignal.timeout(VALIDATOR_TIMEOUT_MS),\n });\n\n // A partial JSON payload can look clean while omitting validator diagnostics.\n if (!response.ok || response.status === 206) {\n await cancelResponseBody(response);\n throw new Error(`W3C HTML validator returned HTTP status ${response.status}`);\n }\n\n return normalizeNuHtmlPayload(await readResponseText(response, MAX_VALIDATOR_RESPONSE_BYTES));\n } catch (cause) {\n if (checker !== \"auto\" || !local || !isTransientNuFailure(cause)) throw cause;\n return await validateHtmlAtLocalNu(htmlContent, mediaType, local);\n }\n } catch (error: unknown) {\n throw new Error(`HTML validation failed: ${getErrorMessage(error)}`);\n }\n}\n\n/** Backwards-compatible convenience API returning capped diagnostics only. */\nexport async function validateHtmlContent(\n htmlContent: string,\n mediaType: HtmlValidationMediaType = \"text/html\",\n checker: HtmlCheckerMode = \"auto\",\n): Promise<W3CMessage[]> {\n return (await validateHtmlContentDetailed(htmlContent, mediaType, checker)).messages;\n}\n\n/** Validates CSS using the W3C Jigsaw CSS Validator API and retains bounded-output metadata. */\nexport async function validateCssContentDetailed(cssContent: string): Promise<CssValidationResult> {\n const url = \"https://jigsaw.w3.org/css-validator/validator\";\n\n try {\n assertContentSize(cssContent, MAX_CSS_VALIDATION_BYTES, \"CSS content\");\n const form = new FormData();\n form.set(\"text\", cssContent);\n form.set(\"output\", \"json\");\n form.set(\"warning\", \"2\");\n form.set(\"profile\", \"css3svg\");\n\n const response = await fetch(url, {\n method: \"POST\",\n headers: {\n \"User-Agent\": USER_AGENT,\n },\n body: form,\n redirect: \"error\",\n signal: AbortSignal.timeout(VALIDATOR_TIMEOUT_MS),\n });\n\n // Incomplete upstream diagnostics cannot establish a valid CSS verdict.\n if (!response.ok || response.status === 206) {\n await cancelResponseBody(response);\n throw new Error(`W3C CSS validator returned HTTP status ${response.status}`);\n }\n\n const text = await readResponseText(response, MAX_VALIDATOR_RESPONSE_BYTES);\n\n // An empty upstream response is indeterminate and must never be presented as a clean result.\n if (!text || text.trim() === \"\") {\n throw new Error(\"W3C CSS validator returned an empty response\");\n }\n\n const data = JSON.parse(text) as {\n cssvalidation?: {\n validity?: boolean;\n errors?: Array<{\n line?: unknown;\n message: string;\n context?: string;\n type?: string;\n }>;\n warnings?: Array<{\n line?: unknown;\n message: string;\n context?: string;\n type?: string;\n }>;\n };\n };\n\n if (!data.cssvalidation || typeof data.cssvalidation !== \"object\") {\n throw new Error(\"W3C CSS validator returned an invalid response shape\");\n }\n if (typeof data.cssvalidation.validity !== \"boolean\") {\n throw new Error(\"W3C CSS validator returned an invalid response shape\");\n }\n if ((\"errors\" in data.cssvalidation && !Array.isArray(data.cssvalidation.errors))\n || (\"warnings\" in data.cssvalidation && !Array.isArray(data.cssvalidation.warnings))) {\n throw new Error(\"W3C CSS validator returned an invalid response shape\");\n }\n\n const errors = data.cssvalidation.errors || [];\n const warnings = data.cssvalidation.warnings || [];\n if (data.cssvalidation.validity === false && errors.length === 0) {\n throw new Error(\"W3C CSS validator reported invalid CSS without error diagnostics\");\n }\n const normalizedErrors = errors.map((err) => {\n const message = normalizeCssDiagnosticMessage(err.message, \"Unknown CSS validation error\");\n return {\n line: normalizeCssDiagnosticLine(err.line),\n type: \"error\",\n message,\n context: typeof err.context === \"string\" && err.context\n ? boundDiagnosticText(err.context, MAX_CSS_CONTEXT_CHARS) : undefined,\n ...(isKnownCssValidatorLimitation(err.type, message)\n ? { compatibility: \"known-validator-limitation\" as const }\n : {}),\n };\n });\n const normalizedWarnings = warnings.map((warning) => ({\n line: normalizeCssDiagnosticLine(warning.line),\n type: \"warning\",\n message: normalizeCssDiagnosticMessage(warning.message, \"Unknown CSS validation warning\"),\n context: typeof warning.context === \"string\" && warning.context\n ? boundDiagnosticText(warning.context, MAX_CSS_CONTEXT_CHARS) : undefined,\n }));\n const normalized = [...normalizedErrors, ...normalizedWarnings];\n const compatibilityLimitation = normalizedErrors.filter(\n (message) => message.compatibility === \"known-validator-limitation\",\n ).length;\n return {\n messages: normalized.slice(0, MAX_VALIDATION_MESSAGES),\n total: normalized.length,\n truncated: normalized.length > MAX_VALIDATION_MESSAGES,\n counts: {\n error: normalizedErrors.length - compatibilityLimitation,\n warning: normalizedWarnings.length,\n compatibilityLimitation,\n },\n };\n } catch (error: unknown) {\n throw new Error(`CSS validation failed: ${getErrorMessage(error)}`);\n }\n}\n\n/** Backwards-compatible convenience API returning capped CSS diagnostics only. */\nexport async function validateCssContent(cssContent: string): Promise<CSSMessage[]> {\n return (await validateCssContentDetailed(cssContent)).messages;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"w3c-validator.js","sourceRoot":"","sources":["../src/w3c-validator.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,+BAA+B;AAC/B,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAyB3D,MAAM,UAAU,qBAAqB,CACnC,OAA6C;IAE7C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC/C,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,oBAAoB;QAAE,OAAO,OAAO,CAAC;IACtE,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,EAAE,CAAC;QACnG,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAqBD,MAAM,oBAAoB,GAAG,MAAM,CAAC;AACpC,MAAM,cAAc,GAAG,SAAS,CAAC;AACjC,MAAM,CAAC,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAChD,MAAM,4BAA4B,GAAG,SAAS,CAAC;AAC/C,MAAM,UAAU,GAAG,qBAAqB,eAAe,0CAA0C,CAAC;AAClG,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,sBAAsB,GAAG,GAAG,CA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AAC,CAAC,CAAC,QAAQ,CAAC;AACjE,CAAC","sourcesContent":["// Copyright (c) 2026 AKzar1el and Web Validator contributors\n// SPDX-License-Identifier: MIT\nimport {\n cancelResponseBody,\n getErrorMessage,\n readResponseText,\n} from \"./network.js\";\nimport { PACKAGE_VERSION } from \"./version.js\";\nimport { withEphemeralNuChecker } from \"./nu-ephemeral.js\";\n\nexport interface W3CMessage {\n type: string;\n subType?: string;\n lastLine?: number;\n lastColumn?: number;\n firstLine?: number;\n firstColumn?: number;\n message: string;\n extract?: string;\n}\n\nexport type W3CMessageSeverity = \"error\" | \"warning\" | \"info\";\nexport type HtmlValidationMediaType = \"text/html\" | \"application/xhtml+xml\";\n\nexport interface HtmlValidationResult {\n messages: W3CMessage[];\n total: number;\n truncated: boolean;\n counts: Record<W3CMessageSeverity, number>;\n checker?: \"w3c_remote\" | \"nu_local\";\n}\nexport type HtmlCheckerMode = \"auto\" | \"remote\" | \"local\";\n\nexport function getW3CMessageSeverity(\n message: Pick<W3CMessage, \"type\" | \"subType\">,\n): W3CMessageSeverity {\n const type = message.type.trim().toLowerCase();\n if (type === \"error\" || type === \"non-document-error\") return \"error\";\n if (type === \"warning\" || (type === \"info\" && message.subType?.trim().toLowerCase() === \"warning\")) {\n return \"warning\";\n }\n return \"info\";\n}\n\nexport interface CSSMessage {\n line: number;\n type: string;\n message: string;\n context?: string;\n compatibility?: \"known-validator-limitation\";\n}\n\nexport interface CssValidationResult {\n messages: CSSMessage[];\n total: number;\n truncated: boolean;\n counts: {\n error: number;\n warning?: number;\n compatibilityLimitation: number;\n };\n}\n\nconst VALIDATOR_TIMEOUT_MS = 20_000;\nconst MAX_HTML_BYTES = 2_000_000;\nexport const MAX_CSS_VALIDATION_BYTES = 128_000;\nconst MAX_VALIDATOR_RESPONSE_BYTES = 5_000_000;\nconst USER_AGENT = `mcp-web-validator/${PACKAGE_VERSION} (+https://digestseo.com/validator-mcp/)`;\nexport const MAX_VALIDATION_MESSAGES = 200;\nconst MAX_HTML_EXTRACT_CHARS = 500;\nconst MAX_DIAGNOSTIC_MESSAGE_CHARS = 1_000;\nconst MAX_CSS_CONTEXT_CHARS = 500;\nconst MAX_DIAGNOSTIC_SUBTYPE_CHARS = 64;\n\nfunction boundDiagnosticText(text: string, maxChars: number): string {\n return text.length > maxChars ? `${text.slice(0, maxChars - 3)}...` : text;\n}\n\nfunction isKnownCssValidatorLimitation(type: string | undefined, message: string): boolean {\n if (type?.trim().toLowerCase() !== \"at-rule\") return false;\n const normalized = message.trim().toLowerCase().replace(/[“”\"'‘’]/g, \"\");\n return normalized === \"unrecognized at-rule @container\";\n}\n\nfunction normalizeCssDiagnosticMessage(value: unknown, fallback: string): string {\n const message = typeof value === \"string\" ? value.trim() : \"\";\n return boundDiagnosticText(message || fallback, MAX_DIAGNOSTIC_MESSAGE_CHARS);\n}\n\nfunction normalizeCssDiagnosticLine(value: unknown): number {\n return typeof value === \"number\" && Number.isSafeInteger(value) && value >= 0 ? value : 0;\n}\n\nfunction assertContentSize(content: string, maxBytes: number, label: string): void {\n const size = Buffer.byteLength(content, \"utf8\");\n if (size > maxBytes) {\n throw new Error(`${label} exceeds the ${maxBytes}-byte validation limit`);\n }\n}\n\nfunction normalizeW3CMessage(message: unknown): W3CMessage {\n if (typeof message !== \"object\" || message === null) {\n throw new Error(\"W3C HTML validator returned a malformed message\");\n }\n\n const candidate = message as Record<string, unknown>;\n if (typeof candidate.type !== \"string\" || typeof candidate.message !== \"string\" || !candidate.message.trim()) {\n throw new Error(\"W3C HTML validator returned a malformed message\");\n }\n const type = candidate.type.trim().toLowerCase();\n if (![\"error\", \"warning\", \"info\", \"non-document-error\"].includes(type)) {\n throw new Error(\"W3C HTML validator returned a malformed message\");\n }\n\n const normalized: W3CMessage = {\n type,\n message: boundDiagnosticText(candidate.message, MAX_DIAGNOSTIC_MESSAGE_CHARS),\n };\n\n for (const field of [\"lastLine\", \"lastColumn\", \"firstLine\", \"firstColumn\"] as const) {\n if (typeof candidate[field] === \"number\" && Number.isSafeInteger(candidate[field]) && candidate[field] >= 0) {\n normalized[field] = candidate[field];\n }\n }\n\n if (typeof candidate.extract === \"string\") {\n normalized.extract = boundDiagnosticText(candidate.extract, MAX_HTML_EXTRACT_CHARS);\n }\n\n if (typeof candidate.subType === \"string\") {\n normalized.subType = boundDiagnosticText(candidate.subType.trim(), MAX_DIAGNOSTIC_SUBTYPE_CHARS);\n }\n\n return normalized;\n}\n\nfunction normalizeNuHtmlPayload(text: string): HtmlValidationResult {\n const data: unknown = JSON.parse(text);\n if (!data || typeof data !== \"object\" || !(\"messages\" in data)\n || !Array.isArray(data.messages)) {\n throw new Error(\"W3C HTML validator returned an invalid response shape\");\n }\n const normalized = data.messages.map(normalizeW3CMessage);\n if (normalized.some((item) => item.type === \"non-document-error\")) {\n throw new Error(\"W3C HTML validator could not complete validation (non-document-error)\");\n }\n const counts: HtmlValidationResult[\"counts\"] = { error: 0, warning: 0, info: 0 };\n for (const item of normalized) counts[getW3CMessageSeverity(item)] += 1;\n return {\n messages: normalized.slice(0, MAX_VALIDATION_MESSAGES),\n total: normalized.length,\n truncated: normalized.length > MAX_VALIDATION_MESSAGES,\n counts,\n };\n}\n\n/** Only a user-configured loopback Nu HTTP service may receive local fallback markup. */\nfunction configuredLocalNuUrl(): string | undefined {\n const setting = process.env.MCP_WEB_VALIDATOR_NU_LOCAL_URL?.trim();\n if (!setting) return undefined;\n let url: URL;\n try {\n url = new URL(setting);\n } catch {\n throw new Error(\"MCP_WEB_VALIDATOR_NU_LOCAL_URL is not a valid URL\");\n }\n if (url.protocol !== \"http:\" || ![\"127.0.0.1\", \"[::1]\"].includes(url.hostname)\n || url.username || url.password || url.hash\n || ![\"/\", \"/nu/\"].includes(url.pathname)\n || [...url.searchParams.keys()].some((key) => key !== \"out\")) {\n throw new Error(\"MCP_WEB_VALIDATOR_NU_LOCAL_URL must be an HTTP loopback-only Nu endpoint\");\n }\n url.search = \"?out=json\";\n return url.href;\n}\n\nfunction isTransientNuFailure(error: unknown): boolean {\n if (error instanceof TypeError) return true;\n if (!(error instanceof Error)) return false;\n return /(?:timeout|timed out|abort|fetch failed|HTTP status (?:206|408|429|5\\d\\d))/i.test(error.message);\n}\n\nasync function validateHtmlAtLocalNu(\n html: string,\n mediaType: HtmlValidationMediaType,\n url: string,\n): Promise<HtmlValidationResult> {\n const response = await fetch(url, {\n method: \"POST\",\n headers: { \"Content-Type\": mediaType + \"; charset=utf-8\", \"User-Agent\": USER_AGENT },\n body: html,\n redirect: \"error\",\n signal: AbortSignal.timeout(12_000),\n });\n if (!response.ok || response.status === 206) {\n await cancelResponseBody(response);\n throw new Error(\"Local Nu HTML checker returned HTTP status \" + response.status);\n }\n return {\n ...normalizeNuHtmlPayload(await readResponseText(response, MAX_VALIDATOR_RESPONSE_BYTES)),\n checker: \"nu_local\",\n };\n}\n\nfunction configuredLocalNuJava(): string | undefined {\n const java = process.env.MCP_WEB_VALIDATOR_NU_JAVA_PATH?.trim();\n return java || undefined;\n}\n\nasync function validateHtmlAtAvailableLocalNu(\n html: string,\n mediaType: HtmlValidationMediaType,\n httpUrl?: string,\n javaExecutable?: string,\n): Promise<HtmlValidationResult> {\n if (httpUrl) return validateHtmlAtLocalNu(html, mediaType, httpUrl);\n if (javaExecutable) {\n return withEphemeralNuChecker(javaExecutable,\n (url) => validateHtmlAtLocalNu(html, mediaType, url));\n }\n throw new Error(\n \"Local Nu requires MCP_WEB_VALIDATOR_NU_JAVA_PATH (on-demand Java 17+ runtime) \" +\n \"or MCP_WEB_VALIDATOR_NU_LOCAL_URL (loopback service)\",\n );\n}\n\n/** Validates HTML/XHTML using the W3C Nu HTML Checker API and retains bounded-output metadata. */\nexport async function validateHtmlContentDetailed(\n htmlContent: string,\n mediaType: HtmlValidationMediaType = \"text/html\",\n checker: HtmlCheckerMode = \"auto\",\n): Promise<HtmlValidationResult> {\n const url = \"https://validator.w3.org/nu/?out=json\";\n\n try {\n assertContentSize(htmlContent, MAX_HTML_BYTES, \"HTML content\");\n const local = checker !== \"remote\" ? configuredLocalNuUrl() : undefined;\n const localJava = checker !== \"remote\" ? configuredLocalNuJava() : undefined;\n if (checker === \"local\") {\n return await validateHtmlAtAvailableLocalNu(htmlContent, mediaType, local, localJava);\n }\n try {\n const response = await fetch(url, {\n method: \"POST\",\n headers: {\n \"Content-Type\": `${mediaType}; charset=utf-8`,\n \"User-Agent\": USER_AGENT,\n },\n body: htmlContent,\n redirect: \"error\",\n signal: AbortSignal.timeout(VALIDATOR_TIMEOUT_MS),\n });\n\n // A partial JSON payload can look clean while omitting validator diagnostics.\n if (!response.ok || response.status === 206) {\n await cancelResponseBody(response);\n throw new Error(`W3C HTML validator returned HTTP status ${response.status}`);\n }\n\n return normalizeNuHtmlPayload(await readResponseText(response, MAX_VALIDATOR_RESPONSE_BYTES));\n } catch (cause) {\n if (checker !== \"auto\" || !(local || localJava) || !isTransientNuFailure(cause)) throw cause;\n return await validateHtmlAtAvailableLocalNu(htmlContent, mediaType, local, localJava);\n }\n } catch (error: unknown) {\n throw new Error(`HTML validation failed: ${getErrorMessage(error)}`);\n }\n}\n\n/** Backwards-compatible convenience API returning capped diagnostics only. */\nexport async function validateHtmlContent(\n htmlContent: string,\n mediaType: HtmlValidationMediaType = \"text/html\",\n checker: HtmlCheckerMode = \"auto\",\n): Promise<W3CMessage[]> {\n return (await validateHtmlContentDetailed(htmlContent, mediaType, checker)).messages;\n}\n\n/** Validates CSS using the W3C Jigsaw CSS Validator API and retains bounded-output metadata. */\nexport async function validateCssContentDetailed(cssContent: string): Promise<CssValidationResult> {\n const url = \"https://jigsaw.w3.org/css-validator/validator\";\n\n try {\n assertContentSize(cssContent, MAX_CSS_VALIDATION_BYTES, \"CSS content\");\n const form = new FormData();\n form.set(\"text\", cssContent);\n form.set(\"output\", \"json\");\n form.set(\"warning\", \"2\");\n form.set(\"profile\", \"css3svg\");\n\n const response = await fetch(url, {\n method: \"POST\",\n headers: {\n \"User-Agent\": USER_AGENT,\n },\n body: form,\n redirect: \"error\",\n signal: AbortSignal.timeout(VALIDATOR_TIMEOUT_MS),\n });\n\n // Incomplete upstream diagnostics cannot establish a valid CSS verdict.\n if (!response.ok || response.status === 206) {\n await cancelResponseBody(response);\n throw new Error(`W3C CSS validator returned HTTP status ${response.status}`);\n }\n\n const text = await readResponseText(response, MAX_VALIDATOR_RESPONSE_BYTES);\n\n // An empty upstream response is indeterminate and must never be presented as a clean result.\n if (!text || text.trim() === \"\") {\n throw new Error(\"W3C CSS validator returned an empty response\");\n }\n\n const data = JSON.parse(text) as {\n cssvalidation?: {\n validity?: boolean;\n errors?: Array<{\n line?: unknown;\n message: string;\n context?: string;\n type?: string;\n }>;\n warnings?: Array<{\n line?: unknown;\n message: string;\n context?: string;\n type?: string;\n }>;\n };\n };\n\n if (!data.cssvalidation || typeof data.cssvalidation !== \"object\") {\n throw new Error(\"W3C CSS validator returned an invalid response shape\");\n }\n if (typeof data.cssvalidation.validity !== \"boolean\") {\n throw new Error(\"W3C CSS validator returned an invalid response shape\");\n }\n if ((\"errors\" in data.cssvalidation && !Array.isArray(data.cssvalidation.errors))\n || (\"warnings\" in data.cssvalidation && !Array.isArray(data.cssvalidation.warnings))) {\n throw new Error(\"W3C CSS validator returned an invalid response shape\");\n }\n\n const errors = data.cssvalidation.errors || [];\n const warnings = data.cssvalidation.warnings || [];\n if (data.cssvalidation.validity === false && errors.length === 0) {\n throw new Error(\"W3C CSS validator reported invalid CSS without error diagnostics\");\n }\n const normalizedErrors = errors.map((err) => {\n const message = normalizeCssDiagnosticMessage(err.message, \"Unknown CSS validation error\");\n return {\n line: normalizeCssDiagnosticLine(err.line),\n type: \"error\",\n message,\n context: typeof err.context === \"string\" && err.context\n ? boundDiagnosticText(err.context, MAX_CSS_CONTEXT_CHARS) : undefined,\n ...(isKnownCssValidatorLimitation(err.type, message)\n ? { compatibility: \"known-validator-limitation\" as const }\n : {}),\n };\n });\n const normalizedWarnings = warnings.map((warning) => ({\n line: normalizeCssDiagnosticLine(warning.line),\n type: \"warning\",\n message: normalizeCssDiagnosticMessage(warning.message, \"Unknown CSS validation warning\"),\n context: typeof warning.context === \"string\" && warning.context\n ? boundDiagnosticText(warning.context, MAX_CSS_CONTEXT_CHARS) : undefined,\n }));\n const normalized = [...normalizedErrors, ...normalizedWarnings];\n const compatibilityLimitation = normalizedErrors.filter(\n (message) => message.compatibility === \"known-validator-limitation\",\n ).length;\n return {\n messages: normalized.slice(0, MAX_VALIDATION_MESSAGES),\n total: normalized.length,\n truncated: normalized.length > MAX_VALIDATION_MESSAGES,\n counts: {\n error: normalizedErrors.length - compatibilityLimitation,\n warning: normalizedWarnings.length,\n compatibilityLimitation,\n },\n };\n } catch (error: unknown) {\n throw new Error(`CSS validation failed: ${getErrorMessage(error)}`);\n }\n}\n\n/** Backwards-compatible convenience API returning capped CSS diagnostics only. */\nexport async function validateCssContent(cssContent: string): Promise<CSSMessage[]> {\n return (await validateCssContentDetailed(cssContent)).messages;\n}\n"]}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Web Validator reliability engines — 23 November 2026
|
|
2
|
+
|
|
3
|
+
This change **extends existing tools only**: 39 local MCP tools and 27 hosted
|
|
4
|
+
tools remain. Optional engines are off by default for an 8 GB Windows laptop.
|
|
5
|
+
SiteOne is a standalone opt-in CLI check, not a background job.
|
|
6
|
+
The earlier Unlighthouse adapter was removed: it was not executed end-to-end,
|
|
7
|
+
requires a separate Node 24.13.1+ runtime, and overlaps existing Lighthouse
|
|
8
|
+
checks. It must not be advertised as a supported or verified integration.
|
|
9
|
+
|
|
10
|
+
## HTML: local Nu Checker fallback
|
|
11
|
+
|
|
12
|
+
Existing tools html.local, html.url and report.validation accept checker or
|
|
13
|
+
htmlChecker: auto (default), remote, or local.
|
|
14
|
+
|
|
15
|
+
- auto: primary W3C Nu service, with local fallback on transient failures
|
|
16
|
+
only when MCP_WEB_VALIDATOR_NU_LOCAL_URL is configured.
|
|
17
|
+
- remote: only the W3C service.
|
|
18
|
+
- local: require locally operated Nu checker; never upload submitted HTML.
|
|
19
|
+
|
|
20
|
+
Optional local Nu service:
|
|
21
|
+
|
|
22
|
+
docker run --rm -p 127.0.0.1:8888:8888 ghcr.io/validator/validator:latest
|
|
23
|
+
|
|
24
|
+
Environment for only the local stdio MCP process:
|
|
25
|
+
|
|
26
|
+
MCP_WEB_VALIDATOR_NU_LOCAL_URL=http://127.0.0.1:8888/?out=json
|
|
27
|
+
|
|
28
|
+
**Verified Windows alternative (recommended):** install the official Nu
|
|
29
|
+
Checker Windows runtime (which bundles Java 17+), verify its release SHA-256,
|
|
30
|
+
then configure the local MCP process with an absolute path to the bundled
|
|
31
|
+
runtime's java.exe:
|
|
32
|
+
|
|
33
|
+
MCP_WEB_VALIDATOR_NU_JAVA_PATH=C:/path/to/vnu-runtime-image/bin/java.exe
|
|
34
|
+
|
|
35
|
+
With that environment variable, selecting checker="local" starts Nu on
|
|
36
|
+
demand, binds its temporary HTTP listener explicitly to 127.0.0.1, validates
|
|
37
|
+
the supplied HTML or XHTML, and terminates the Java child. Auto mode uses it
|
|
38
|
+
only when remote W3C is temporarily unavailable. At most one temporary
|
|
39
|
+
Nu instance runs per MCP process, with a 256 MB Java heap limit and strict
|
|
40
|
+
startup/response timeouts. No Windows service, Docker daemon, permanent
|
|
41
|
+
listener or system Java upgrade is required. A real 2026-11-23 check observed
|
|
42
|
+
about 350 MB working set during execution; it is **not** always resident.
|
|
43
|
+
The verified official Windows release archive (vnu.windows.zip, 26.11.20)
|
|
44
|
+
had SHA-256:
|
|
45
|
+
34bbc89b6247dfe9fc869fa9900aebcc0dcd102c224f92677b817f61d57e14c0.
|
|
46
|
+
The binary is installed outside the npm package, not vendored.
|
|
47
|
+
|
|
48
|
+
Only HTTP literal loopback hosts 127.0.0.1 or ::1 and fixed checker routes
|
|
49
|
+
are allowed. No executable installation, service startup, credential
|
|
50
|
+
provisioning or hidden network activity is performed by default. The same
|
|
51
|
+
input/response bounds and no-redirect policy apply, and partial or malformed
|
|
52
|
+
checker evidence must not become a clean result. Upstream vnu.jar needs Java
|
|
53
|
+
17+, while the upstream standalone binaries include an embedded Java runtime.
|
|
54
|
+
|
|
55
|
+
Hosted Cloudflare Workers cannot reach this local checker. They instead
|
|
56
|
+
make at most one second request to a fixed alternate public Nu endpoint for
|
|
57
|
+
transient 429/5xx or transport failure, sharing the original 15-second
|
|
58
|
+
deadline. Aborted requests, redirects and malformed diagnostics are not
|
|
59
|
+
retried. Incomplete audits remain explicitly partial.
|
|
60
|
+
|
|
61
|
+
## CSS: Stylelint optional offline rules
|
|
62
|
+
|
|
63
|
+
Existing css.local supports checker: "stylelint"; default is "w3c".
|
|
64
|
+
The local engine checks ten conservative CSS quality rules, does not load
|
|
65
|
+
configuration files, fetch network resources, autofix content or echo CSS.
|
|
66
|
+
Input limit 128 KB; diagnostic cap 200 with complete severity counts.
|
|
67
|
+
Linting does NOT establish W3C CSS conformance. Stylelint 17 preserves the
|
|
68
|
+
original Node 22.12 minimum; Stylelint 18 requires newer Node versions.
|
|
69
|
+
|
|
70
|
+
## Accessibility: axe-core optional
|
|
71
|
+
|
|
72
|
+
Existing browser.wcag accepts includeAxe: true. It first strips page
|
|
73
|
+
scripts, event handlers and frames, blocks all external requests, then
|
|
74
|
+
executes locally installed axe-core rules on sanitized HTML in the existing
|
|
75
|
+
pinned sandboxed Chromium. No original DOM, selectors, user text, URLs,
|
|
76
|
+
form input or document snippets are returned; only bounded static rule IDs,
|
|
77
|
+
impact bands and affected-element counts. The original 180 KB HTML input
|
|
78
|
+
cap and 20-second browser deadline still apply. Unavailable engine or
|
|
79
|
+
runtime is NOT a passing result.
|
|
80
|
+
|
|
81
|
+
The automated rules and limited keyboard checks do not prove WCAG 2.2
|
|
82
|
+
conformance for live/hydrated sites; production scripts and assistive
|
|
83
|
+
technology are not exercised.
|
|
84
|
+
|
|
85
|
+
## Visual regression: pixelmatch optional
|
|
86
|
+
|
|
87
|
+
Existing screenshot.capture accepts baselineDir to compare with previously
|
|
88
|
+
recorded viewport screenshots. It must be an existing directory separate
|
|
89
|
+
from outputDir. PNGs need matching names, e.g. mobile_375x812.png. Each
|
|
90
|
+
image is capped at 12 MB and 2,073,600 pixels. Only numeric changed-pixel
|
|
91
|
+
counts and percentages are returned. No diff PNG or source content is
|
|
92
|
+
stored. Missing, malformed, over-budget or incomplete-asset comparisons
|
|
93
|
+
are inconclusive, never a false clean result.
|
|
94
|
+
|
|
95
|
+
## Independently verified SiteOne: explicit opt-in
|
|
96
|
+
|
|
97
|
+
Run the verified native SiteOne CLI separately:
|
|
98
|
+
|
|
99
|
+
node scripts/deep-audit-optional.mjs --help
|
|
100
|
+
node scripts/deep-audit-optional.mjs --engine=siteone --url=https://digestseo.com/ --allow-host=digestseo.com --max-pages=4
|
|
101
|
+
|
|
102
|
+
Use the installed executable on PATH, or set
|
|
103
|
+
MCP_WEB_VALIDATOR_SITEONE_BIN to its absolute path (e.g. the verified official
|
|
104
|
+
Windows 2.5.1 binary). Add --execute for an actual crawl.
|
|
105
|
+
For an npm installation, call the separate mcp-web-validator-siteone
|
|
106
|
+
executable. Its audited JSON files are written under the **current working
|
|
107
|
+
directory**, never inside the npm installation or npx cache. This adds
|
|
108
|
+
no MCP tools.
|
|
109
|
+
|
|
110
|
+
The default is DRY RUN (plan only). Adding --execute requires an already
|
|
111
|
+
installed SiteOne binary, explicit exact-host ownership confirmation, and
|
|
112
|
+
review of the site's impact. The adapter performs public IPv4 DNS preflight,
|
|
113
|
+
runs in a private working directory with scrubbed credentials/configuration,
|
|
114
|
+
and checks that an actual bounded SiteOne JSON report was produced.
|
|
115
|
+
|
|
116
|
+
- SiteOne: one worker, max one request/sec, 384 MB crawler memory cap,
|
|
117
|
+
max four visited pages, bounded queue/timeout and disabled HTTP cache.
|
|
118
|
+
A fresh isolated HOME/USERPROFILE/APPDATA and working directory avoids
|
|
119
|
+
loading the user's global crawler configuration or credentials.
|
|
120
|
+
- Origins must be public HTTPS, exact-host authorized, without credentials,
|
|
121
|
+
nonstandard ports, queries or fragments. Literal IP, local/test/internal
|
|
122
|
+
domains and unsafe paths are rejected.
|
|
123
|
+
- SiteOne is NOT the MCP DNS-pinned fetch engine: Windows 2.5.1 was tested
|
|
124
|
+
with the --resolve option, which incorrectly mapped the public domain
|
|
125
|
+
to loopback and produced no pages. The adapter therefore does NOT use this
|
|
126
|
+
override and **cannot guarantee resistance to DNS rebinding or unsafe
|
|
127
|
+
redirects**. Run it only for sites you control and trust, never arbitrary
|
|
128
|
+
untrusted URLs. Its output does not silently affect canonical MCP scores.
|
|
129
|
+
- SiteOne is never auto-launched or permanently scheduled.
|
|
130
|
+
|
|
131
|
+
**Real tests on 23 November 2026:** the verified official Windows SiteOne
|
|
132
|
+
v2.5.1 executable crawled one URL on tomiseregi.si and two and four URLs
|
|
133
|
+
in independent digestseo.com tests, wrote bounded JSON reports containing
|
|
134
|
+
corresponding stats.totalUrls values, and exited successfully. The official
|
|
135
|
+
Windows ZIP had SHA-256:
|
|
136
|
+
6b6758daa866df99d9bd7a020b51eaeca2d5f52f3172ec5270f9f96b964c16db.
|
|
137
|
+
DNS pinning remained a
|
|
138
|
+
documented limitation, not a claimed security control. No paid API key
|
|
139
|
+
or heavyweight persistent runner is required.
|
|
140
|
+
|
|
141
|
+
## Licenses and decision
|
|
142
|
+
|
|
143
|
+
Nu Html Checker: MIT (external service); axe-core: MPL-2.0 (optional npm);
|
|
144
|
+
Stylelint: MIT (optional npm); pixelmatch: ISC (optional npm);
|
|
145
|
+
pngjs: MIT (optional npm); SiteOne Crawler: MIT (external CLI).
|
|
146
|
+
|
|
147
|
+
Upstream source is not vendored or modified. Preserve third-party npm
|
|
148
|
+
license notices before distribution. Do not duplicate the existing SEO,
|
|
149
|
+
robots, sitemap and Lighthouse tools.
|
|
150
|
+
|
|
151
|
+
References:
|
|
152
|
+
- https://github.com/validator/validator
|
|
153
|
+
- https://github.com/dequelabs/axe-core
|
|
154
|
+
- https://github.com/stylelint/stylelint
|
|
155
|
+
- https://github.com/mapbox/pixelmatch
|
|
156
|
+
- https://github.com/janreges/siteone-crawler
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-web-validator",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.58",
|
|
4
4
|
"description": "W3C HTML/CSS Validator and Technical SEO Audit MCP Server for AI coding assistants.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"mcp-web-validator": "dist/index.js"
|
|
7
|
+
"mcp-web-validator": "dist/index.js",
|
|
8
|
+
"mcp-web-validator-siteone": "scripts/deep-audit-optional.mjs"
|
|
8
9
|
},
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
@@ -29,6 +30,8 @@
|
|
|
29
30
|
},
|
|
30
31
|
"files": [
|
|
31
32
|
"dist",
|
|
33
|
+
"scripts/deep-audit-optional.mjs",
|
|
34
|
+
"docs/reliability-engines-20261123.md",
|
|
32
35
|
"README.md",
|
|
33
36
|
"SECURITY.md",
|
|
34
37
|
"CHANGELOG.md",
|
|
@@ -55,14 +58,15 @@
|
|
|
55
58
|
"@puppeteer/browsers": "3.2.7",
|
|
56
59
|
"cheerio": "^1.0.0",
|
|
57
60
|
"encoding-sniffer": "1.0.2",
|
|
58
|
-
"puppeteer-core": "25.
|
|
61
|
+
"puppeteer-core": "25.18.1",
|
|
59
62
|
"undici": "^7.30.1",
|
|
60
63
|
"zod": "^4.4.3"
|
|
61
64
|
},
|
|
62
65
|
"devDependencies": {
|
|
63
66
|
"@types/node": "^26.2.0",
|
|
64
67
|
"@types/pngjs": "6.0.5",
|
|
65
|
-
"
|
|
68
|
+
"oxc-parser": "0.152.0",
|
|
69
|
+
"puppeteer": "25.18.1",
|
|
66
70
|
"tsx": "^4.23.0",
|
|
67
71
|
"typescript": "^7.0.2"
|
|
68
72
|
},
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Copyright (c) 2026 AKzar1el and Web Validator contributors
|
|
3
|
+
// SPDX-License-Identifier: MIT
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
import { lookup } from "node:dns/promises";
|
|
6
|
+
import { mkdir, mkdtemp, readFile, realpath, lstat, stat, writeFile } from "node:fs/promises";
|
|
7
|
+
import { isIP } from "node:net";
|
|
8
|
+
import * as path from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
|
|
11
|
+
const help = "Usage: node scripts/deep-audit-optional.mjs --engine=siteone --url=https://your-owned-site.com --allow-host=your-owned-site.com [--max-pages=1..4] [--execute]. Set MCP_WEB_VALIDATOR_SITEONE_BIN to an installed native SiteOne executable when not on PATH.";
|
|
12
|
+
|
|
13
|
+
function safeHttpsSite(value) {
|
|
14
|
+
if (typeof value !== "string" || value.length > 256) throw new Error("Supply a short HTTPS URL");
|
|
15
|
+
let url;
|
|
16
|
+
try { url = new URL(value); } catch { throw new Error("Invalid HTTPS URL"); }
|
|
17
|
+
const host = url.hostname.toLowerCase();
|
|
18
|
+
if (url.protocol !== "https:" || url.username || url.password
|
|
19
|
+
|| url.port || url.search || url.hash || url.pathname !== "/"
|
|
20
|
+
|| !/^[a-z0-9.-]+$/.test(host) || isIP(host)
|
|
21
|
+
|| !host.includes(".") || host.endsWith(".")
|
|
22
|
+
|| /(?:^localhost$|\.localhost$|\.local$|\.internal$|\.test$|\.invalid$|\.example$|\.onion$|\.home\.arpa$)/.test(host)) {
|
|
23
|
+
throw new Error("Deep audit requires an explicitly authorized public HTTPS origin without credentials");
|
|
24
|
+
}
|
|
25
|
+
return url;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function buildDeepAuditPlan(options) {
|
|
29
|
+
const engine = options.engine;
|
|
30
|
+
if (engine !== "siteone") throw new Error(
|
|
31
|
+
"Only independently verified SiteOne is supported; the unverified Unlighthouse adapter was removed. " + help);
|
|
32
|
+
const site = safeHttpsSite(options.url);
|
|
33
|
+
if (options.allowHost !== site.hostname) {
|
|
34
|
+
throw new Error("Specify --allow-host with the exact owned website hostname");
|
|
35
|
+
}
|
|
36
|
+
const maxPages = options.maxPages === undefined ? 1 : Number(options.maxPages);
|
|
37
|
+
if (!Number.isSafeInteger(maxPages) || maxPages < 1 || maxPages > 4) {
|
|
38
|
+
throw new Error("Deep audit max pages must be 1..4");
|
|
39
|
+
}
|
|
40
|
+
if (options.paths !== undefined) {
|
|
41
|
+
throw new Error("SiteOne does not accept explicit paths; use --max-pages only");
|
|
42
|
+
}
|
|
43
|
+
// Never write audit reports inside an installed npm package or npx cache.
|
|
44
|
+
const directory = path.resolve(process.cwd(), ".mcp-validator", "optional-deep-audits", engine);
|
|
45
|
+
const executable = process.env.MCP_WEB_VALIDATOR_SITEONE_BIN || "siteone-crawler";
|
|
46
|
+
const args = [
|
|
47
|
+
"--url=" + site.href,
|
|
48
|
+
...(maxPages === 1 ? ["--single-page"] : []),
|
|
49
|
+
"--workers=1", "--max-reqs-per-sec=1", "--memory-limit=384M",
|
|
50
|
+
"--max-visited-urls=" + maxPages, "--max-queue-length=16",
|
|
51
|
+
"--max-skipped-urls=16", "--max-depth=1", "--timeout=6",
|
|
52
|
+
"--no-cache", "--output=json", "--output-html-report=",
|
|
53
|
+
"--output-text-file=",
|
|
54
|
+
"--output-json-file=" + path.join(directory, "report.json"),
|
|
55
|
+
];
|
|
56
|
+
return { engine, site: site.origin, maxPages,
|
|
57
|
+
executable, args, directory, timeoutMs: 90_000 };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function parseOptions(argv) {
|
|
61
|
+
const options = {};
|
|
62
|
+
for (const argument of argv) {
|
|
63
|
+
if (argument === "--execute") { options.execute = true; continue; }
|
|
64
|
+
if (argument === "--help") { options.help = true; continue; }
|
|
65
|
+
const pair = /^--(engine|url|allow-host|max-pages|paths)=(.+)$/.exec(argument);
|
|
66
|
+
if (!pair) throw new Error("Unknown deep audit argument");
|
|
67
|
+
const names = { engine: "engine", url: "url", "allow-host": "allowHost",
|
|
68
|
+
"max-pages": "maxPages", paths: "paths" };
|
|
69
|
+
if (Object.hasOwn(options, names[pair[1]])) throw new Error("Duplicate audit argument");
|
|
70
|
+
options[names[pair[1]]] = pair[2];
|
|
71
|
+
}
|
|
72
|
+
return options;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function isPublicIPv4(address) {
|
|
76
|
+
if (isIP(address) !== 4) return false;
|
|
77
|
+
const [a, b, c] = address.split(".").map(Number);
|
|
78
|
+
if (a === 0 || a === 10 || a === 127 || a >= 224
|
|
79
|
+
|| (a === 100 && b >= 64 && b <= 127)
|
|
80
|
+
|| (a === 169 && b === 254)
|
|
81
|
+
|| (a === 172 && b >= 16 && b <= 31)
|
|
82
|
+
|| (a === 192 && (b === 168 || (b === 0 && c <= 2) || (b === 88 && c === 99)))
|
|
83
|
+
|| (a === 198 && (b === 18 || b === 19 || (b === 51 && c === 100)))
|
|
84
|
+
|| (a === 203 && b === 0 && c === 113)) return false;
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function siteoneExecutable(name) {
|
|
89
|
+
if (!path.isAbsolute(name)) {
|
|
90
|
+
if (name !== "siteone-crawler") throw new Error("Invalid SiteOne executable name");
|
|
91
|
+
return name;
|
|
92
|
+
}
|
|
93
|
+
if (!["siteone-crawler", "siteone-crawler.exe"].includes(path.basename(name).toLowerCase())) {
|
|
94
|
+
throw new Error("SiteOne executable must be the native siteone-crawler binary");
|
|
95
|
+
}
|
|
96
|
+
const info = await lstat(name);
|
|
97
|
+
if (!info.isFile() || info.isSymbolicLink()) throw new Error("Invalid SiteOne executable file");
|
|
98
|
+
return realpath(name);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function executePlan(plan) {
|
|
102
|
+
// SiteOne controls its own redirect/subresource transports. Until it can be
|
|
103
|
+
// constrained to HTTPS end-to-end, execution requires explicit insecure-HTTP consent.
|
|
104
|
+
if (process.env.MCP_WEB_VALIDATOR_ALLOW_INSECURE_HTTP !== "1") {
|
|
105
|
+
throw new Error("SiteOne may follow insecure HTTP links. Configure MCP_WEB_VALIDATOR_ALLOW_INSECURE_HTTP=1 for explicitly authorized diagnostics, or use dry run.");
|
|
106
|
+
}
|
|
107
|
+
await mkdir(plan.directory, { recursive: true });
|
|
108
|
+
const runDir = await mkdtemp(path.join(plan.directory, "run-"));
|
|
109
|
+
const binary = await siteoneExecutable(plan.executable);
|
|
110
|
+
const host = new URL(plan.site).hostname;
|
|
111
|
+
const addresses = await lookup(host, { all: true });
|
|
112
|
+
// Refuse known private DNS answers before invoking this separate crawler.
|
|
113
|
+
// This is a preflight, not a guarantee against DNS rebinding or redirects.
|
|
114
|
+
if (!addresses.length || addresses.some((item) => item.family === 4
|
|
115
|
+
&& !isPublicIPv4(item.address))) {
|
|
116
|
+
throw new Error("SiteOne target resolves to a forbidden network address");
|
|
117
|
+
}
|
|
118
|
+
const permitted = addresses.find((item) => item.family === 4 && isPublicIPv4(item.address));
|
|
119
|
+
if (!permitted) throw new Error("SiteOne requires a verified public IPv4 address");
|
|
120
|
+
const args = plan.args.map((arg) => arg.startsWith("--output-json-file=")
|
|
121
|
+
? "--output-json-file=" + path.join(runDir, "report.json") : arg);
|
|
122
|
+
// SiteOne 2.5.1 Windows --resolve rewrites valid public IPs to loopback
|
|
123
|
+
// (observed twice as "no working URL"); do not use a broken DNS override.
|
|
124
|
+
// As a result this cannot guarantee DNS pinning. Execute on owned sites only.
|
|
125
|
+
// Do not forward credentials to third-party CLI processes.
|
|
126
|
+
const keys = ["PATH", "Path", "SystemRoot", "ComSpec", "ProgramFiles", "ProgramFiles(x86)"];
|
|
127
|
+
const env = {};
|
|
128
|
+
for (const key of keys) if (process.env[key]) env[key] = process.env[key];
|
|
129
|
+
for (const key of ["HOME", "USERPROFILE", "APPDATA", "LOCALAPPDATA",
|
|
130
|
+
"XDG_CONFIG_HOME", "XDG_CACHE_HOME", "TEMP", "TMP"]) env[key] = runDir;
|
|
131
|
+
let diagnostics = "";
|
|
132
|
+
try {
|
|
133
|
+
await new Promise((resolve, reject) => {
|
|
134
|
+
const child = spawn(binary, args, {
|
|
135
|
+
cwd: runDir, env, stdio: ["ignore", "pipe", "pipe"], windowsHide: true, shell: false,
|
|
136
|
+
});
|
|
137
|
+
for (const pipe of [child.stdout, child.stderr]) {
|
|
138
|
+
pipe.on("data", (chunk) => {
|
|
139
|
+
diagnostics = (diagnostics + String(chunk)).slice(-16_384);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
const timeout = setTimeout(() => child.kill(), plan.timeoutMs);
|
|
143
|
+
child.once("error", (error) => {
|
|
144
|
+
clearTimeout(timeout);
|
|
145
|
+
reject(error.code === "ENOENT"
|
|
146
|
+
? new Error("Optional " + plan.executable + " is not installed on PATH") : error);
|
|
147
|
+
});
|
|
148
|
+
child.once("exit", (code, signal) => {
|
|
149
|
+
clearTimeout(timeout);
|
|
150
|
+
if (code === 0) resolve();
|
|
151
|
+
else reject(new Error(plan.engine + " exited unsuccessfully (code "
|
|
152
|
+
+ String(code) + ", signal " + String(signal) + ")"));
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
} catch (error) {
|
|
156
|
+
// Keep bounded troubleshooting output in the private ignored workdir,
|
|
157
|
+
// never interpolate site URLs/HTML into public MCP responses.
|
|
158
|
+
await writeFile(path.join(runDir, "diagnostics.txt"), diagnostics.slice(-16_384));
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
const report = path.join(runDir, "report.json");
|
|
162
|
+
const meta = await stat(report);
|
|
163
|
+
if (!meta.isFile() || meta.size < 20 || meta.size > 2_000_000) {
|
|
164
|
+
throw new Error("SiteOne completed without a bounded JSON audit report");
|
|
165
|
+
}
|
|
166
|
+
const audit = JSON.parse(await readFile(report, "utf8"));
|
|
167
|
+
if (!audit || typeof audit !== "object" || Array.isArray(audit)
|
|
168
|
+
|| !Number.isSafeInteger(audit.stats?.totalUrls)
|
|
169
|
+
|| audit.stats.totalUrls < 1 || audit.stats.totalUrls > plan.maxPages
|
|
170
|
+
|| (Array.isArray(audit.error) && audit.error.length > 0)) {
|
|
171
|
+
throw new Error("SiteOne returned an empty, partial or out-of-budget audit report");
|
|
172
|
+
}
|
|
173
|
+
return { runDir, reportBytes: meta.size, urlsCrawled: audit.stats.totalUrls };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async function main() {
|
|
177
|
+
const opts = parseOptions(process.argv.slice(2));
|
|
178
|
+
if (opts.help) { console.log(help); return; }
|
|
179
|
+
const plan = buildDeepAuditPlan(opts);
|
|
180
|
+
if (!opts.execute) {
|
|
181
|
+
console.log(JSON.stringify({ status: "dry_run", note:
|
|
182
|
+
"No executable was launched. Execution performs public DNS preflight but cannot pin DNS; use only owned, trusted sites.",
|
|
183
|
+
...plan }, null, 2));
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const finished = await executePlan(plan);
|
|
187
|
+
console.log(JSON.stringify({ status: "completed", engine: plan.engine,
|
|
188
|
+
maxPages: plan.maxPages, urlsCrawled: finished.urlsCrawled,
|
|
189
|
+
reportBytes: finished.reportBytes,
|
|
190
|
+
outputDirectory: finished.runDir }));
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
194
|
+
main().catch((error) => {
|
|
195
|
+
console.error("Deep audit not completed: " + error.message);
|
|
196
|
+
process.exitCode = 1;
|
|
197
|
+
});
|
|
198
|
+
}
|