mcp-web-validator 1.3.51 → 1.3.53
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 +41 -0
- package/README.md +64 -4
- package/dist/audit-history.d.ts +9 -0
- package/dist/audit-history.js +27 -0
- package/dist/audit-history.js.map +1 -1
- package/dist/index.js +2508 -2
- package/dist/index.js.map +1 -1
- package/dist/modules/browser-ux/lighthouse-lab-probe.d.ts +21 -0
- package/dist/modules/browser-ux/lighthouse-lab-probe.js +190 -0
- package/dist/modules/browser-ux/lighthouse-lab-probe.js.map +1 -0
- package/dist/modules/browser-ux/lighthouse-lab.d.ts +61 -0
- package/dist/modules/browser-ux/lighthouse-lab.js +98 -0
- package/dist/modules/browser-ux/lighthouse-lab.js.map +1 -0
- package/dist/modules/browser-ux/media-diagnostics.d.ts +41 -0
- package/dist/modules/browser-ux/media-diagnostics.js +183 -0
- package/dist/modules/browser-ux/media-diagnostics.js.map +1 -0
- package/dist/modules/browser-ux/raw-rendered-diff.d.ts +70 -0
- package/dist/modules/browser-ux/raw-rendered-diff.js +262 -0
- package/dist/modules/browser-ux/raw-rendered-diff.js.map +1 -0
- package/dist/modules/browser-ux/raw-rendered-probe.d.ts +17 -0
- package/dist/modules/browser-ux/raw-rendered-probe.js +163 -0
- package/dist/modules/browser-ux/raw-rendered-probe.js.map +1 -0
- package/dist/modules/browser-ux/resource-failures-probe.d.ts +11 -0
- package/dist/modules/browser-ux/resource-failures-probe.js +231 -0
- package/dist/modules/browser-ux/resource-failures-probe.js.map +1 -0
- package/dist/modules/browser-ux/resource-failures.d.ts +79 -0
- package/dist/modules/browser-ux/resource-failures.js +178 -0
- package/dist/modules/browser-ux/resource-failures.js.map +1 -0
- package/dist/modules/browser-ux/viewport-parity-probe.d.ts +5 -0
- package/dist/modules/browser-ux/viewport-parity-probe.js +307 -0
- package/dist/modules/browser-ux/viewport-parity-probe.js.map +1 -0
- package/dist/modules/browser-ux/viewport-parity.d.ts +112 -0
- package/dist/modules/browser-ux/viewport-parity.js +224 -0
- package/dist/modules/browser-ux/viewport-parity.js.map +1 -0
- package/dist/modules/browser-ux/wcag-interactions.d.ts +95 -0
- package/dist/modules/browser-ux/wcag-interactions.js +360 -0
- package/dist/modules/browser-ux/wcag-interactions.js.map +1 -0
- package/dist/modules/change-regression/availability-history-store.d.ts +18 -0
- package/dist/modules/change-regression/availability-history-store.js +168 -0
- package/dist/modules/change-regression/availability-history-store.js.map +1 -0
- package/dist/modules/change-regression/crawler-log-correlation.d.ts +111 -0
- package/dist/modules/change-regression/crawler-log-correlation.js +374 -0
- package/dist/modules/change-regression/crawler-log-correlation.js.map +1 -0
- package/dist/modules/change-regression/google-common-crawler-ip.d.ts +15 -0
- package/dist/modules/change-regression/google-common-crawler-ip.js +129 -0
- package/dist/modules/change-regression/google-common-crawler-ip.js.map +1 -0
- package/dist/modules/change-regression/historical-comparisons.d.ts +120 -0
- package/dist/modules/change-regression/historical-comparisons.js +330 -0
- package/dist/modules/change-regression/historical-comparisons.js.map +1 -0
- package/dist/modules/change-regression/production-change-comparison.d.ts +68 -0
- package/dist/modules/change-regression/production-change-comparison.js +214 -0
- package/dist/modules/change-regression/production-change-comparison.js.map +1 -0
- package/dist/modules/change-regression/regression-alerts.d.ts +73 -0
- package/dist/modules/change-regression/regression-alerts.js +183 -0
- package/dist/modules/change-regression/regression-alerts.js.map +1 -0
- package/dist/modules/change-regression/strict-observation-time.d.ts +7 -0
- package/dist/modules/change-regression/strict-observation-time.js +31 -0
- package/dist/modules/change-regression/strict-observation-time.js.map +1 -0
- package/dist/modules/content-schema/citation-methodology-consistency.d.ts +108 -0
- package/dist/modules/content-schema/citation-methodology-consistency.js +360 -0
- package/dist/modules/content-schema/citation-methodology-consistency.js.map +1 -0
- package/dist/modules/content-schema/competitor-intent-comparison.d.ts +74 -0
- package/dist/modules/content-schema/competitor-intent-comparison.js +185 -0
- package/dist/modules/content-schema/competitor-intent-comparison.js.map +1 -0
- package/dist/modules/content-schema/empty-boilerplate-content.d.ts +36 -0
- package/dist/modules/content-schema/empty-boilerplate-content.js +225 -0
- package/dist/modules/content-schema/empty-boilerplate-content.js.map +1 -0
- package/dist/modules/content-schema/extract-citation-methodology.d.ts +6 -0
- package/dist/modules/content-schema/extract-citation-methodology.js +201 -0
- package/dist/modules/content-schema/extract-citation-methodology.js.map +1 -0
- package/dist/modules/content-schema/extract-competitor-intent.d.ts +2 -0
- package/dist/modules/content-schema/extract-competitor-intent.js +140 -0
- package/dist/modules/content-schema/extract-competitor-intent.js.map +1 -0
- package/dist/modules/content-schema/extract-main-content.d.ts +6 -0
- package/dist/modules/content-schema/extract-main-content.js +33 -0
- package/dist/modules/content-schema/extract-main-content.js.map +1 -0
- package/dist/modules/content-schema/extract-metadata-consistency.d.ts +3 -0
- package/dist/modules/content-schema/extract-metadata-consistency.js +62 -0
- package/dist/modules/content-schema/extract-metadata-consistency.js.map +1 -0
- package/dist/modules/content-schema/extract-product-claims.d.ts +3 -0
- package/dist/modules/content-schema/extract-product-claims.js +58 -0
- package/dist/modules/content-schema/extract-product-claims.js.map +1 -0
- package/dist/modules/content-schema/extract-structured-data.d.ts +3 -0
- package/dist/modules/content-schema/extract-structured-data.js +25 -0
- package/dist/modules/content-schema/extract-structured-data.js.map +1 -0
- package/dist/modules/content-schema/metadata-consistency.d.ts +66 -0
- package/dist/modules/content-schema/metadata-consistency.js +282 -0
- package/dist/modules/content-schema/metadata-consistency.js.map +1 -0
- package/dist/modules/content-schema/product-claims.d.ts +73 -0
- package/dist/modules/content-schema/product-claims.js +195 -0
- package/dist/modules/content-schema/product-claims.js.map +1 -0
- package/dist/modules/content-schema/same-language-duplicates.d.ts +52 -0
- package/dist/modules/content-schema/same-language-duplicates.js +158 -0
- package/dist/modules/content-schema/same-language-duplicates.js.map +1 -0
- package/dist/modules/content-schema/structured-data-validation.d.ts +37 -0
- package/dist/modules/content-schema/structured-data-validation.js +385 -0
- package/dist/modules/content-schema/structured-data-validation.js.map +1 -0
- package/dist/modules/external-metrics/crux-field-probe.d.ts +10 -0
- package/dist/modules/external-metrics/crux-field-probe.js +113 -0
- package/dist/modules/external-metrics/crux-field-probe.js.map +1 -0
- package/dist/modules/external-metrics/crux-field.d.ts +61 -0
- package/dist/modules/external-metrics/crux-field.js +231 -0
- package/dist/modules/external-metrics/crux-field.js.map +1 -0
- package/dist/modules/http-crawl/availability-observations.d.ts +68 -0
- package/dist/modules/http-crawl/availability-observations.js +206 -0
- package/dist/modules/http-crawl/availability-observations.js.map +1 -0
- package/dist/modules/http-crawl/availability-probe.d.ts +8 -0
- package/dist/modules/http-crawl/availability-probe.js +46 -0
- package/dist/modules/http-crawl/availability-probe.js.map +1 -0
- package/dist/modules/http-crawl/crawler-access-probe.d.ts +6 -0
- package/dist/modules/http-crawl/crawler-access-probe.js +79 -0
- package/dist/modules/http-crawl/crawler-access-probe.js.map +1 -0
- package/dist/modules/http-crawl/crawler-access.d.ts +75 -0
- package/dist/modules/http-crawl/crawler-access.js +404 -0
- package/dist/modules/http-crawl/crawler-access.js.map +1 -0
- package/dist/modules/http-crawl/http-delivery-probe.d.ts +3 -0
- package/dist/modules/http-crawl/http-delivery-probe.js +44 -0
- package/dist/modules/http-crawl/http-delivery-probe.js.map +1 -0
- package/dist/modules/http-crawl/http-delivery.d.ts +64 -0
- package/dist/modules/http-crawl/http-delivery.js +269 -0
- package/dist/modules/http-crawl/http-delivery.js.map +1 -0
- package/dist/modules/http-crawl/https-security.d.ts +84 -0
- package/dist/modules/http-crawl/https-security.js +441 -0
- package/dist/modules/http-crawl/https-security.js.map +1 -0
- package/dist/modules/http-crawl/non-html-directives.d.ts +74 -0
- package/dist/modules/http-crawl/non-html-directives.js +353 -0
- package/dist/modules/http-crawl/non-html-directives.js.map +1 -0
- package/dist/modules/http-crawl/redirect-canonical-chains.d.ts +80 -0
- package/dist/modules/http-crawl/redirect-canonical-chains.js +459 -0
- package/dist/modules/http-crawl/redirect-canonical-chains.js.map +1 -0
- package/dist/modules/http-crawl/redirect-canonical-probe.d.ts +6 -0
- package/dist/modules/http-crawl/redirect-canonical-probe.js +83 -0
- package/dist/modules/http-crawl/redirect-canonical-probe.js.map +1 -0
- package/dist/modules/http-crawl/sitemap-inventory-probe.d.ts +8 -0
- package/dist/modules/http-crawl/sitemap-inventory-probe.js +155 -0
- package/dist/modules/http-crawl/sitemap-inventory-probe.js.map +1 -0
- package/dist/modules/http-crawl/sitemap-inventory.d.ts +107 -0
- package/dist/modules/http-crawl/sitemap-inventory.js +557 -0
- package/dist/modules/http-crawl/sitemap-inventory.js.map +1 -0
- package/dist/modules/http-crawl/url-variants.d.ts +86 -0
- package/dist/modules/http-crawl/url-variants.js +379 -0
- package/dist/modules/http-crawl/url-variants.js.map +1 -0
- package/dist/modules/site-architecture/extract-internal-links.d.ts +3 -0
- package/dist/modules/site-architecture/extract-internal-links.js +88 -0
- package/dist/modules/site-architecture/extract-internal-links.js.map +1 -0
- package/dist/modules/site-architecture/extract-multilingual-page.d.ts +2 -0
- package/dist/modules/site-architecture/extract-multilingual-page.js +29 -0
- package/dist/modules/site-architecture/extract-multilingual-page.js.map +1 -0
- package/dist/modules/site-architecture/internal-link-graph-probe.d.ts +7 -0
- package/dist/modules/site-architecture/internal-link-graph-probe.js +116 -0
- package/dist/modules/site-architecture/internal-link-graph-probe.js.map +1 -0
- package/dist/modules/site-architecture/internal-link-graph.d.ts +113 -0
- package/dist/modules/site-architecture/internal-link-graph.js +414 -0
- package/dist/modules/site-architecture/internal-link-graph.js.map +1 -0
- package/dist/modules/site-architecture/internal-link-quality.d.ts +77 -0
- package/dist/modules/site-architecture/internal-link-quality.js +260 -0
- package/dist/modules/site-architecture/internal-link-quality.js.map +1 -0
- package/dist/modules/site-architecture/multilingual-clusters.d.ts +82 -0
- package/dist/modules/site-architecture/multilingual-clusters.js +363 -0
- package/dist/modules/site-architecture/multilingual-clusters.js.map +1 -0
- package/dist/network.d.ts +4 -0
- package/dist/network.js +18 -2
- package/dist/network.js.map +1 -1
- package/dist/presentation.d.ts +53 -0
- package/dist/presentation.js +526 -0
- package/dist/presentation.js.map +1 -1
- package/dist/screenshot.d.ts +2 -1
- package/dist/screenshot.js +4 -2
- package/dist/screenshot.js.map +1 -1
- package/dist/seo-auditor.js +16 -6
- package/dist/seo-auditor.js.map +1 -1
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,47 @@ All notable changes to this project are documented here. The project follows [Se
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
### Hosted app
|
|
8
|
+
|
|
9
|
+
- Accept public webpage URLs in `validate_html` (including legacy URL-as-HTML input) via the existing safe page fetch, avoiding misleading Nu diagnostics for URL text.
|
|
10
|
+
- Fix Nu HTML validation in the Cloudflare Worker by using supported manual redirect handling and rejecting non-success responses without forwarding submitted markup.
|
|
11
|
+
|
|
12
|
+
## [1.3.53] - 2026-11-21
|
|
13
|
+
|
|
14
|
+
### Release engineering
|
|
15
|
+
|
|
16
|
+
- Provision the pinned Chrome Headless Shell and its narrowly scoped AppArmor
|
|
17
|
+
user-namespace allowance in npm publishing CI before running the complete
|
|
18
|
+
MCP integration test suite. The v1.3.52 tag failed its release gate before
|
|
19
|
+
publication because this setup was missing; v1.3.53 supersedes that tag
|
|
20
|
+
without rewriting its history or bypassing the validation gate.
|
|
21
|
+
|
|
22
|
+
## [1.3.52] - 2026-11-21
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- Expand local stdio MCP to 39 tools with evidence-bounded technical SEO and
|
|
27
|
+
incident diagnostics: HTTP delivery, availability, redirects, crawler access,
|
|
28
|
+
sitemaps, browser resource failures, viewport checks, production changes,
|
|
29
|
+
Lighthouse offline laboratory, CrUX field data, and crawler log correlation.
|
|
30
|
+
- Add optional, local GitHub-main update-on-activation launcher for trusted
|
|
31
|
+
development environments. Each new revision is isolated, built, and checked
|
|
32
|
+
with a real offline MCP canary before promotion. Offline, lock, or failed-build
|
|
33
|
+
cases preserve the last known-good revision; public npm clients are unchanged.
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- Validate calendar dates strictly in production-change and historical audits;
|
|
38
|
+
impossible timestamps no longer count as comparable evidence.
|
|
39
|
+
- Give six high-use incident tools prioritized, bounded remediation suggestions
|
|
40
|
+
without weakening privacy or their structured MCP contracts.
|
|
41
|
+
- Harden redirect, URL-variant, sitemap, and Cache-Control parsing against
|
|
42
|
+
misleading edge cases found in follow-up testing.
|
|
43
|
+
|
|
44
|
+
### Security
|
|
45
|
+
|
|
46
|
+
- Refresh the local MCP's locked transitive Hono dependency to 4.13.19 to address npm-audited middleware and input-validation advisories without changing the runtime dependency declarations.
|
|
47
|
+
|
|
7
48
|
## [1.3.51] - 2026-11-18
|
|
8
49
|
|
|
9
50
|
### Fixed
|
package/README.md
CHANGED
|
@@ -53,14 +53,46 @@ The npm package exposes these exact runtime tool names:
|
|
|
53
53
|
| --- | --- | --- |
|
|
54
54
|
| `html.local` | Validate a local HTML or XHTML file. | Reads the selected file and submits its markup to the external W3C Nu HTML Checker at `validator.w3.org/nu/`; `.xhtml` paths use `application/xhtml+xml` parsing semantics. |
|
|
55
55
|
| `html.url` | Validate the markup returned by a public URL. | Fetches the URL, then submits the returned markup to the external Nu checker. |
|
|
56
|
+
| `site.sitemaps` | Review 1–8 XML/text sitemap documents, nested child coverage, duplicates, malformed URLs, lastmod consistency and independently observed page indexability/canonical conflicts, or fetch up to 3 safe sitemap documents live. | Bounded inventory, not a complete crawl or Google indexing verdict. No raw URLs, XML or headers returned. See [V05](docs/v05-sitemap-inventory.md). |
|
|
57
|
+
| `site.link_graph` | Compute shortest observed internal-link paths, sampled incoming-link counts, potential orphan leads and linked HTTP/robots/noindex/canonical conflicts from 1–8 supplied pages, or a guarded three-page live sample. | Static anchor links including navigation. Unsampled pages and sitemap URLs are never called confirmed orphans/broken; no source URLs or HTML echoed. See [V06](docs/v06-internal-link-graph.md). |
|
|
58
|
+
| `http.redirect_chain` | Compare up to eight supplied HTTP response redirects and canonical declarations, or probe a bounded public same-origin redirect chain. Flags loops, mismatches against a specified expected target, conflicting/cyclic canonicals, final HTTP errors and declared noindex. | Bounded static evidence; live mode stays same-origin and query-free. No raw URL/HTML/header echo, Google-selected canonical claim or indexing verdict. See [V04](docs/v04-redirect-canonical-chains.md). |
|
|
59
|
+
| `crawler.access` | Evaluate 1–8 static pages against robots.txt per Googlebot desktop/smartphone/news/image, Bingbot and GPTBot, with independent robots meta/X-Robots-Tag indexing observations; optional bounded live public page probe. | Offline or service-user-agent live mode. Does not impersonate real crawlers, execute JS, decide actual index status or echo raw URLs/headers. See [V03](docs/v03-crawler-access.md). |
|
|
60
|
+
| `http.availability` | Compare 2–48 timestamped HTTP or transport observations, or sample an authorized public URL with 2–3 GETs to detect intermittent failures, 429/5xx, status changes and challenges. | Bounded offline or live read-only mode. Sample success ratios are **not continuous uptime** and do not establish Googlebot outcomes. See [V02](docs/v02-availability-history.md). |
|
|
61
|
+
| `availability.history` | Explicitly capture one live public GET observation into local history, list existing outcomes or compare at least two previously captured outcomes for one exact URL. | Local-only guarded atomic JSON archive of at most 10 observations (24 KB), oldest evicted automatically; capture writes local state, never schedules checks. Hosted app remains stateless. See [V02](docs/v02-availability-history.md). |
|
|
62
|
+
| `http.delivery` | Diagnose HTTP 403, 429, 5xx, same-origin redirects, caching and explicit Cloudflare challenge signals from one live URL or up to four supplied response hops. | A live call makes a bounded DNS-pinned public GET without reading the response body; supplied mode is fully offline. Output is redacted, bounded, and **not** a Googlebot or historical availability verdict. See [V01](docs/v01-http-delivery.md). |
|
|
63
|
+
| `http.directives` | Review 1-8 caller-supplied same-origin HTTP response observations for non-HTML document MIME types, X-Robots-Tag noindex/agent scopes and conflicts, HTTP Link canonical declarations, attachment dispositions and status. | **Offline; no HTTP requests or binary downloads.** Returns only bounded resource numbers/counts and fixed review messages, not original URLs, headers, files or Google indexing verdicts. |
|
|
64
|
+
| `http.security` | Review 1–8 caller-supplied, same-host HTTP/HTTPS status and response-header records plus optional static HTML for declared HTTPS redirects, HSTS, enforcing/report-only CSP, Referrer-Policy, nosniff, framing, potentially blockable/upgradable mixed content and insecure form submissions. | **Fully offline** with no TLS connection, redirect following, JS/CSS execution, file writes, browser use or website fetching. Returns numeric counts and fixed redacted review messages, **not** a certificate/security audit or proof of actual browser enforcement. |
|
|
65
|
+
| `http.variants` | Compare an explicit query-free reference against 1–12 supplied same-path HTTP/HTTPS, apex/www, trailing slash, path case and query response observations; analyze declared one-step redirects, canonical hints and optional SHA-256 body fingerprints for HTTP 200 responses. | **Fully offline** with no requests or redirects followed. Host/path families are only **candidate variants**; query or case differences may serve different content. Returns counts and fixed redacted findings, no URL paths, queries, raw response targets, hashes or Google-selected canonical verdicts. |
|
|
56
66
|
| `css.local` | Validate a local CSS file. | Reads the selected file and submits its CSS to the external W3C Jigsaw CSS Validator. |
|
|
57
67
|
| `seo.metadata` | Audit titles, descriptions, canonical tags, robots noindex directives, headings, viewport metadata, image alt attributes, and Open Graph metadata. | Processes supplied HTML locally. |
|
|
58
|
-
| `
|
|
68
|
+
| `content.duplicates` | Compare exact and conservative near-duplicate main content within the same language across up to eight supplied HTML pages. | Fully offline, with no network, browser execution or storage; returns only evidence pairs and coverage, never main text. |
|
|
69
|
+
| `content.quality` | Review empty or short static main content, repeated substantive boilerplate within sampled same-language URL families, and possible low unique value. | Offline analysis of up to eight supplied HTML pages; results are review signals, **not** proof that a short page lacks value or that Google penalized it. |
|
|
70
|
+
| `content.metadata` | Compare repeated, conflicting and mismatched title, description, canonical, Open Graph, Twitter and explicit robots metadata across 1-8 supplied same-origin HTML pages. | Fully offline; no page fetch, canonical selection, ranking or indexing verdict. Identical duplicate fields and social-title differences are advisory, not automatic SEO errors. |
|
|
71
|
+
| `content.provenance` | Compare explicit citations, dataset releases/snapshot dates, publication chronology, and methodology links with optional supplied source evidence and opt-in freshness windows. | Fully offline for up to eight supplied HTML pages; no citation/dataset fetching, external fact checks, browser, storage or claim of scientific truth. Missing source evidence remains unverified. |
|
|
72
|
+
| `content.competitors` | Compare static search-intent signals between one primary page and up to six user-supplied competitor pages. Optional caller-chosen intent and query-heading word overlap identify review leads, never ranking winners. | Fully offline; **does not fetch competitor sites, scrape SERPs, use GSC, run a semantic classifier or claim Google intent alignment**. |
|
|
73
|
+
| `product.claims` | Compare explicit local MCP capability promises in supplied or fetched landing-page HTML against the local runtime's **actually registered** tools and metadata. | Processes supplied HTML offline or fetches exactly one authorized public page using SSRF-safe network rules; registration consistency is **not** successful execution or a full marketing truth verdict. |
|
|
74
|
+
| `site.hreflang` | Compare up to 16 supplied localized HTML pages for hreflang return links, self references, locale conflicts, `x-default` and canonical target clusters. | Fully offline and cross-domain aware; no crawling, private credentials, local-file access or storage. Unseen targets are unverified, not broken. |
|
|
75
|
+
| `site.links` | Review contextual same-origin internal links, accessible anchor labels, generic link text, internal nofollow, repeated labels and lexical overlap with supplied destination headings. | Fully offline across 1-8 user-supplied same-origin HTML pages; **does not fetch linked pages, claim broken destinations, infer semantic relevance or Google rankings**. Navigation links and unsupplied targets are excluded/unverified. |
|
|
76
|
+
| `links.broken` | Check links extracted from supplied HTML. | Sends bounded HTTP requests to eligible public links. Returned link URLs omit queries and embedded credentials; requests still use the original URLs. |
|
|
77
|
+
| `media.diagnostics` | Review supplied static image, picture and video metadata: alt and link-name hints, intrinsic dimensions, loading/decoding/fetch priority, picture fallbacks and caption-track declarations. | Local-only, offline markup inspection with bounded redacted results. Does not fetch media, run Chromium, measure performance, decode files, verify caption contents or certify WCAG compliance. |
|
|
78
|
+
| `browser.wcag` | Sample interactive accessibility evidence in a fresh, sandboxed headless Chromium page: rendered accessible-name hints, positive tabindex, aria-hidden focus, custom role Tab stops, up to 24 real keyboard Tab targets, computed focus indicators and a native disclosure toggle. | Local-only, supplied HTML rendered **without script execution or page network requests**. Active scripts, embeds and refreshes are stripped; no buttons/links clicked or forms submitted, no screenshots or original input returned. Provides bounded **review leads**, never a WCAG certification or full dynamic-interaction test. The pinned browser may be downloaded on first use. |
|
|
79
|
+
| `browser.dom_diff` | Compare caller-supplied source/rendered DOM snapshots, or execute supplied inline scripts in isolated offline Chromium; optionally fetch one robots-allowed public HTML page for the same bounded comparison. Flags source/rendered title, H1, main text, internal links, canonical, noindex and JSON-LD differences. | Local-only; **external JS, network resources and frames are not loaded**. It does not reproduce Google Web Rendering Service, provide a real full-resource site render or determine Google indexing. No source HTML/URLs/text leaked. See [V07](docs/v07-raw-rendered-dom.md). |
|
|
80
|
+
| `browser.resource_failures` | Classify up to 64 caller-observed resource outcomes or perform a short robots-gated public Chromium network sample. Separates HTTP 4xx/5xx, transport failures, validator-policy blocks and pending requests for scripts/CSS/documents/API/images/fonts. | Local-only; public-address-pinned browser proxy, 64-request cap, third-party resources blocked by default. Policy blocks are **not website errors**. No URLs, headers or error text echoed; not Google WRS or a full HAR. See [V08](docs/v08-browser-resource-failures.md). |
|
|
81
|
+
| `browser.viewport_parity` | Compare one authorized HTML document in fixed 375px mobile/touch and 1440px desktop Chromium viewports: DOM versus CSS-visible text, metadata and structured data counts, navigation, overflow, keyboard and one safe native disclosure interaction. Optional single robots-gated public HTML fetch. | Local-only, scripts disabled, browser network denied. CSS-hidden navigation does **not** mean absent DOM links. Not full-resource hydration, Google WRS, WCAG certification or indexing evidence; no raw text/URLs echoed. See [V09](docs/v09-mobile-desktop-parity.md). |
|
|
82
|
+
| `browser.lighthouse_lab` | V11-LAB: run the genuine Lighthouse performance engine once in sandboxed Chromium against bounded supplied static HTML; report score, FCP, LCP, TBT, Speed Index and CLS with controlled redacted findings. | **Local-only isolated lab; requires Node >=22.19**, other tools retain >=22.12 support. Scripts/frames stripped; all external network blocked by a single-origin proxy, 75-second deadline, 180 KB HTML cap. Not a CrUX/INP field audit, full production performance or ranking verdict. See [V11-LAB](docs/v11-lighthouse-lab.md). |
|
|
83
|
+
| `performance.crux_field` | V11-FIELD: analyze real-user Google Chrome UX Report p75 LCP/INP/CLS/FCP/TTFB, by origin versus page and phone/desktop/tablet. Supports daily rolling-28-day evidence and up to 40 historical weekly periods, returning 8 recent excerpts. | **Local-only**; use previously obtained CrUX JSON offline or explicitly opt into **one free Google CrUX API POST** using existing local `CRUX_API_KEY` (not passed through chat/MCP). No target page fetch, credentials in output, GSC/GA4, paid service, background monitoring or Google-ranking attribution. See [V11-FIELD](docs/v11-crux-field.md). |
|
|
84
|
+
| `crawler.logs` | V12 + V13: compare supplied HTTP access-log requests around a cutover for 1–16 important URLs, including 401/403, 429, 404/410, 5xx and claimed crawler UAs. **Optional:** compare recorded Googlebot source IPs to Google's current official common-crawler IP ranges. | **Local-only**, 500 structured/Apache-Nginx combined entries; fully offline unless `verify_googlebot_ip_ranges: true` explicitly requests one bounded fixed Google JSON download. No log IPs, URLs, queries, timestamps or user agents returned/transmitted; range matches are not DNS/historical identity proof. No live log retrieval, indexing, rankings, storage or alerts. See [V12](docs/v12-crawler-log-correlation.md) and [V13](docs/v13-googlebot-ip-evidence.md). |
|
|
59
85
|
| `schema.markup` | Parse JSON-LD blocks and report JSON syntax errors. | Processes supplied HTML locally. |
|
|
86
|
+
| `schema.supported` | Review explicit JSON-LD structures for a limited set of Article, Product, BreadcrumbList, FAQPage, Organization and WebSite profiles. | Fully offline; checks bounded property shapes and review recommendations, **not** complete Schema.org validity, Google rich-result eligibility, content correctness or external contexts. The original syntax checker remains unchanged. |
|
|
60
87
|
| `report.validation` | Combine HTML/XHTML, optional CSS, SEO, JSON-LD, and bounded link checks in a Markdown report. | Reads selected files, contacts the validators, and checks eligible public links found in the markup; `.xhtml` inputs use XHTML parsing semantics for Nu validation. |
|
|
61
88
|
| `audit.history` | Opt-in local site-audit snapshot history: `save`, `list`, or `get` by ID. | Stores comparison-relevant fields only in one local JSON file, with a hard cap of 10 versions (oldest automatically evicted). No database or network access. |
|
|
89
|
+
| `audit.trends` | Compare 2–10 existing `audit.history` saved version IDs (oldest first): adjacent changes, first-to-last checks, completed all-version page-cohort error/warning/health trends and carefully gated issue-group counts. | **Read-only local history** with no saves, evictions, missing-version reconstruction or network fetches. Fixed redacted numeric results only; missing checks are not fixes, and trends never imply website-wide or Google ranking outcomes. |
|
|
90
|
+
| `audit.production_change` | V10: compare two captured HTML versions of the same page, with SHA-256 exact HTML and normalized main-text fingerprints, title/description/H1, canonical/robots/noindex, JSON-LD and same-origin link changes. | **Offline, caller-supplied evidence only**; 180 KB per HTML, oldest-first times, HTTP status failures suppress content conclusions, no storage/fetch/deployment or Google-ranking attribution. Redacted numeric/code findings. See [V10](docs/v10-production-change-comparison.md). |
|
|
91
|
+
| `audit.monitor` | **Manual P2-02 dry-run only:** evaluate configurable regression and net-error/warning thresholds against the latest two of 2–10 existing saved history versions, optionally requiring consecutive comparable regressions. Preview review leads for validator coverage loss and sitemap drift. | **Zero notifications, zero schedules, no alert destinations, no storage changes or network requests.** Incomplete samples suppress defect candidates; all outputs are redacted numeric preview evidence, never live site-wide monitoring. |
|
|
62
92
|
| `screenshot.capture` | Capture desktop, tablet, mobile, or custom viewport screenshots. | Opens a selected local file or eligible public URL and writes PNG files to the selected output directory; existing matching files may be replaced. |
|
|
63
93
|
|
|
94
|
+
Different links that differ only by query parameters may therefore appear under the same displayed URL. Do not submit private tokens in HTML or URL inputs.
|
|
95
|
+
|
|
64
96
|
For direct Node.js integrations, `auditSeoMetadata(html, xRobotsTag)` and
|
|
65
97
|
`auditSeoMetadataDetailed(html, xRobotsTag)` from `dist/seo-auditor.js` accept
|
|
66
98
|
an optional caller-observed `X-Robots-Tag` HTTP response-header value. Separate
|
|
@@ -69,17 +101,29 @@ fetches headers; the MCP `seo.metadata` tool still analyzes supplied HTML only.
|
|
|
69
101
|
|
|
70
102
|
## Hosted app tools
|
|
71
103
|
|
|
72
|
-
The hosted app exposes
|
|
104
|
+
The hosted app exposes the tools below in its proposed source code (deployed catalog may differ):
|
|
73
105
|
|
|
74
106
|
| Tool | Purpose |
|
|
75
107
|
| --- | --- |
|
|
76
108
|
| `audit_public_webpage` | Fetch one authorized public HTML page and run the combined HTML, SEO/accessibility-signal, and JSON-LD syntax audit. Link checks are optional. |
|
|
77
|
-
| `audit_public_site` | Run a bounded sitemap-first audit of up to eight authorized, same-origin public pages. It respects `robots.txt`, returns compact page coverage and deduplicated findings, **plus a sampled cross-page indexability evidence graph**
|
|
109
|
+
| `audit_public_site` | Run a bounded sitemap-first audit of up to eight authorized, same-origin public pages. It respects `robots.txt`, returns compact page coverage and deduplicated findings, **plus a sampled cross-page indexability evidence graph**, **same-language exact/near-duplicate main-content pairs**, **static empty/short/boilerplate content-quality review**, and **hreflang/canonical cluster evidence**. Full 16-page reciprocal coverage requires the local offline tool with supplied page HTML. No site-wide link checks. |
|
|
78
110
|
| `compare_site_audits` | Offline before/after comparison of two saved `audit_public_site` structured results. Flags per-page regressions, coverage loss, and sitemap drift; reports newly observed or no-longer observed grouped findings only for an identical, fully checked page sample; partial sitemap coverage never proves a site-wide fix. No network calls or retained history. |
|
|
79
|
-
| `
|
|
111
|
+
| `compare_historical_audits` | Offline 2–10-version timeline of **caller-supplied timestamped** audit snapshots. Adjacent and first/last comparisons, exact consistently checked page-cohort metrics, and gated issue-group presence counts; no hosted storage, saved-ID access, background checks, requests, raw page/issue text or Google indexing claims. |
|
|
112
|
+
| `compare_production_snapshots` | V10 shared offline two-version HTML baseline comparison: exact HTML and sampled main-text SHA-256 fingerprints, metadata/robots/canonical and link/count changes. HTTP delivery failures are non-comparable, not fixes. No fetch, storage, deployment, private text/URL echo or search-traffic causality. |
|
|
113
|
+
| `preview_regression_alerts` | **Manual, stateless P2-02 alert preview only.** Applies bounded per-call thresholds to the latest comparable adjacent pair of 2–10 supplied timestamped audit snapshots. Coverage loss/sitemap drift yield review-only observations; no notification delivery, schedule, webhook, email, GSC or GA4 integration. |
|
|
114
|
+
| `verify_product_claims` | Check visible explicit hosted tool names, an advertised site batch limit, and selected read-only/screenshot-scope statements against the hosted MCP's registered tool names, schemas and annotations. Accepts supplied static HTML or one authorized public HTML URL; unknown statements remain unverified. |
|
|
115
|
+
| `verify_content_provenance` | Offline comparison of explicit citation URLs, dataset metadata, published/modified dates and methodology references in up to eight caller-supplied HTML pages against optional supplied evidence. No citation URLs are fetched, and unsupported factual/freshness claims remain unverified. |
|
|
116
|
+
| `compare_competitor_intent` | Offline comparison of one primary and up to six user-supplied competitor HTML pages for static informational, commercial, transactional or navigational signals and optional exact query/heading lexical overlap; no competitor crawling, SERP or ranking inference. |
|
|
117
|
+
| `validate_html` | Validate supplied HTML or a public webpage URL (`url` field, or standalone URL in `html`). Uses the same bounded, redirect-checked public fetch as the webpage audit for URL inputs. |
|
|
80
118
|
| `validate_css` | Parse supplied CSS for syntax errors inside the Worker. |
|
|
81
119
|
| `audit_seo_metadata` | Audit supplied HTML for covered on-page SEO, robots noindex, and accessibility signals. |
|
|
82
120
|
| `validate_schema_markup` | Check JSON-LD blocks in supplied HTML for JSON syntax errors. |
|
|
121
|
+
| `validate_supported_schema` | Review supported JSON-LD node types and selected property structures, including Product offer prices, Article dates, breadcrumb positions and FAQ answer text. Unknown types remain unverified; no rich-result eligibility promise. |
|
|
122
|
+
| `review_internal_links` | Review contextual internal links and accessible anchor labels across 1-8 already-supplied same-origin static HTML pages, with limited lexical heading comparison for supplied targets. No network requests, search metrics, destination verification or semantic relevance assertions. |
|
|
123
|
+
| `review_metadata_consistency` | Offline consistency review of duplicate/conflicting title, description and canonical declarations, social metadata and robots directives, and repeated titles/descriptions between supplied same-origin pages. No network, selected-canonical or ranking claims. |
|
|
124
|
+
| `review_http_directives` | Offline review of 1-8 supplied same-origin non-HTML HTTP status, MIME, X-Robots-Tag, HTTP Link canonical and attachment observations. No live document request, indexed-status judgment, raw URL/headers or storage. |
|
|
125
|
+
| `review_https_security` | Offline review of 1–8 same-host supplied HTTP/HTTPS response/Location/HSTS/CSP/referrer/framing/nosniff observations plus optional static HTML mixed-content and insecure-form declarations. Bounded redacted review leads; no TLS probe, network, certificate check or browser enforcement claim. |
|
|
126
|
+
| `review_url_variants` | Offline comparison of 1–12 supplied same-path HTTP/HTTPS, apex/www, slash, case and query URL observations against an explicit reference. Inspects observed one-step Location and canonical declarations, optional HTTP 200 SHA-256 bodies; no network, raw URL/query leakage, crawler verification or Google-selected canonical assertion. |
|
|
83
127
|
| `check_broken_links` | Check up to 20 authorized public links extracted from supplied HTML. |
|
|
84
128
|
| `generate_validation_report` | Combine the checks for supplied markup; `base_url` resolves relative links but does not fetch a page. |
|
|
85
129
|
|
|
@@ -105,6 +149,10 @@ The comparison never fetches pages or keeps audit history. It separately reports
|
|
|
105
149
|
|
|
106
150
|
The hosted app deliberately retains **nothing**. If you use the local npm/stdio MCP, `audit.history` can save the JSON `structuredContent` from `audit_public_site` on your own computer. Choose `action: "save"` and supply `snapshotJson` as a JSON string; use `list` to see saved version IDs and `get` with an ID to retrieve its compact JSON. You can then pass two retrieved snapshots to `compare_site_audits`. Saving is always opt-in; audits do not silently create history.
|
|
107
151
|
|
|
152
|
+
For **multi-version** comparisons use local `audit.trends` with 2–10 existing saved `ids` in oldest-to-newest order. It reads the current local archive once and never changes it. The hosted `compare_historical_audits` accepts 2–10 `{saved_at, snapshot}` objects supplied by the caller instead (the Worker has no persisted history). Both use the same M05 pure analyzer, limit conclusions to identically observed completed pages, and report coverage gaps separately. See `docs/p2-01-historical-comparisons.md`.
|
|
153
|
+
|
|
154
|
+
For **gradual regression-monitor testing**, invoke local `audit.monitor` with the same existing saved `ids` (oldest first) or hosted `preview_regression_alerts` with supplied `versions`. Set `dry_run: true` (the only supported mode) and optionally configure `min_regressed_pages`, `min_net_error_increase`, `min_net_warning_increase`, `consecutive_regressing_steps` and review-only coverage/discovery thresholds. This creates **unsent alert previews** only: no scheduler, background monitoring, notifications, email, webhooks, or external data adapters are present. See `docs/p2-02-manual-regression-alert-preview.md`.
|
|
155
|
+
|
|
108
156
|
One compact `audit-history.json` file lives at `~/.mcp-validator/audit-history.json`; when `MCP_WEB_VALIDATOR_WORKSPACE_ROOT` is configured, the file instead lives in that root's `.mcp-validator/` directory. It stores **up to 10 total versions**, newest first when listed. Saving the eleventh automatically deletes the oldest. Each source snapshot is limited to 60 KB and is reduced to comparison-relevant fields (no raw HTML, browser screenshots, widget state, or full indexability graph). The history file has a 660 KB cap. There are no database services, background processes, or network calls. Files stay on the user's computer and are readable only with local filesystem access.
|
|
109
157
|
|
|
110
158
|
**Security:** Do not save secrets in page diagnostics. URL fields containing query strings, credentials, or fragments are rejected; audit-history file symlinks and oversized or corrupt files fail closed. Concurrent saves from one local process are serialized. Separate concurrently running MCP processes should use separate workspace roots to avoid writing the same file.
|
|
@@ -266,6 +314,18 @@ This installs the local stdio package, preserving its workspace-file and screens
|
|
|
266
314
|
|
|
267
315
|
## Development
|
|
268
316
|
|
|
317
|
+
### Optional safe update-on-activation for local source builds
|
|
318
|
+
|
|
319
|
+
The normal `npx -y mcp-web-validator` setup runs the **published npm version**;
|
|
320
|
+
merging GitHub changes does not publish them or refresh an already-running MCP.
|
|
321
|
+
For a trusted personal development setup that should pick up new `main` commits
|
|
322
|
+
at the **next** start, see [safe activation](https://github.com/AKzar1el/mcp-web-validator/blob/main/docs/activation-and-release.md).
|
|
323
|
+
It uses an isolated cache, rebuilds and smoke-tests each new revision, and
|
|
324
|
+
retains the last verified build when offline or when a new build fails. It does
|
|
325
|
+
not restart running sessions, change other Git worktrees, publish npm, deploy
|
|
326
|
+
the hosted Worker, or submit an OpenAI Platform release.
|
|
327
|
+
|
|
328
|
+
|
|
269
329
|
Clone the repository and install the locked dependencies:
|
|
270
330
|
|
|
271
331
|
```bash
|
package/dist/audit-history.d.ts
CHANGED
|
@@ -109,4 +109,13 @@ export interface AuditHistoryResponse {
|
|
|
109
109
|
export declare function parseCompactAuditSnapshot(snapshotJson: string): CompactAuditSnapshot;
|
|
110
110
|
export declare function listAuditHistory(rootDirectory?: string): Promise<AuditHistoryResponse>;
|
|
111
111
|
export declare function getAuditHistorySnapshot(id: string, rootDirectory?: string): Promise<AuditHistoryResponse>;
|
|
112
|
+
/**
|
|
113
|
+
* P2-01: read selected immutable saved versions in *stored* chronological
|
|
114
|
+
* order. A single guarded history read; no writes, ID discovery or archive
|
|
115
|
+
* mutation. Reject evicted versions rather than silently substituting them.
|
|
116
|
+
*/
|
|
117
|
+
export declare function getAuditHistoryVersions(ids: string[], rootDirectory?: string): Promise<Array<{
|
|
118
|
+
saved_at: string;
|
|
119
|
+
snapshot: CompactAuditSnapshot;
|
|
120
|
+
}>>;
|
|
112
121
|
export declare function saveAuditHistorySnapshot(snapshotJson: string, rootDirectory?: string): Promise<AuditHistoryResponse>;
|
package/dist/audit-history.js
CHANGED
|
@@ -202,6 +202,33 @@ export async function getAuditHistorySnapshot(id, rootDirectory = basePath()) {
|
|
|
202
202
|
throw new Error("The requested audit history version was not found.");
|
|
203
203
|
return { ...summary(items), snapshot_json: JSON.stringify(found.snapshot) };
|
|
204
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* P2-01: read selected immutable saved versions in *stored* chronological
|
|
207
|
+
* order. A single guarded history read; no writes, ID discovery or archive
|
|
208
|
+
* mutation. Reject evicted versions rather than silently substituting them.
|
|
209
|
+
*/
|
|
210
|
+
export async function getAuditHistoryVersions(ids, rootDirectory = basePath()) {
|
|
211
|
+
if (!Array.isArray(ids) || ids.length < 2 || ids.length > MAX_AUDIT_HISTORY
|
|
212
|
+
|| new Set(ids).size !== ids.length
|
|
213
|
+
|| ids.some((id) => !z.string().uuid().safeParse(id).success)) {
|
|
214
|
+
throw new Error("Supply two to ten distinct saved audit version IDs, oldest first.");
|
|
215
|
+
}
|
|
216
|
+
const history = await readHistory(rootDirectory);
|
|
217
|
+
const byId = new Map(history.map((item, index) => [item.id, { item, index }]));
|
|
218
|
+
let previousIndex = -1;
|
|
219
|
+
const result = [];
|
|
220
|
+
for (const id of ids) {
|
|
221
|
+
const entry = byId.get(id);
|
|
222
|
+
if (!entry)
|
|
223
|
+
throw new Error("A requested saved audit history version was not found or was evicted.");
|
|
224
|
+
if (entry.index <= previousIndex) {
|
|
225
|
+
throw new Error("Saved audit version IDs must be ordered oldest to newest.");
|
|
226
|
+
}
|
|
227
|
+
previousIndex = entry.index;
|
|
228
|
+
result.push({ saved_at: entry.item.saved_at, snapshot: entry.item.snapshot });
|
|
229
|
+
}
|
|
230
|
+
return result;
|
|
231
|
+
}
|
|
205
232
|
export function saveAuditHistorySnapshot(snapshotJson, rootDirectory = basePath()) {
|
|
206
233
|
const snapshot = parseCompactAuditSnapshot(snapshotJson);
|
|
207
234
|
const action = async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-history.js","sourceRoot":"","sources":["../src/audit-history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAC/C,MAAM,sBAAsB,GAAG,OAAO,CAAC;AACvC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAC3C,MAAM,YAAY,GAAG,oBAAoB,CAAC;AAE1C,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;IACvD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,CAAC;eACzD,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;eACrB,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,C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AAO;YACL,GAAG,OAAO,CAAC,IAAI,CAAC;YAChB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC/C,CAAC;IACJ,CAAC,CAAC;IACF,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjD,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC7C,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import * as fs from \"node:fs/promises\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport { randomUUID } from \"node:crypto\";\nimport { z } from \"zod\";\n\nexport const MAX_AUDIT_HISTORY = 10;\nexport const MAX_AUDIT_SNAPSHOT_BYTES = 60_000;\nconst MAX_HISTORY_FILE_BYTES = 660_000;\nconst HISTORY_DIRECTORY = \".mcp-validator\";\nconst HISTORY_FILE = \"audit-history.json\";\n\nconst publicUrl = z.string().max(2_048).refine((value) => {\n try {\n const url = new URL(value);\n return (url.protocol === \"https:\" || url.protocol === \"http:\")\n && Boolean(url.hostname)\n && !url.username && !url.password && !url.search && !url.hash\n && !url.port;\n } catch {\n return false;\n }\n}, \"Only query-free, credential-free public HTTP(S) URLs may be saved.\");\n\nconst count = z.number().int().nonnegative();\nconst severity = z.enum([\"error\", \"warning\", \"info\"]);\nconst category = z.enum([\"HTML\", \"SEO\", \"Schema\", \"Accessibility\"]);\nconst finding = z.object({\n code: z.string().max(120).optional(),\n severity,\n category,\n message: z.string().max(300),\n});\nconst page = z.object({\n url: publicUrl,\n fetched_url: publicUrl.optional(),\n status: z.enum([\"passed\", \"needs_attention\", \"partial\", \"failed\", \"skipped\"]),\n http_status: z.number().int().min(200).max(299).optional(),\n redirects_followed: z.number().int().min(0).max(3).optional(),\n page_fetched: z.boolean(),\n html_validation_status: z.enum([\"completed\", \"timeout\", \"unavailable\", \"not_run\"]),\n html_errors: count,\n html_warnings: count,\n seo_errors: count,\n seo_warnings: count,\n schema_errors: count,\n schema_warnings: count,\n notes: count,\n health_score: z.number().int().min(0).max(100).optional(),\n failure_code: z.string().max(120).optional(),\n top_findings: z.array(finding).max(3),\n});\nconst issueGroup = finding.extend({\n affected_pages: count,\n example_urls: z.array(publicUrl).max(3),\n});\n\n/**\n * Keep only the fields used by compare_site_audits.\n * Rich page signals, raw HTML, widget state and unrelated user-supplied fields\n * are deliberately not persisted; the hosted app remains completely stateless.\n */\nexport const compactAuditSnapshotSchema = z.object({\n site_url: publicUrl,\n sitemap_url: publicUrl.optional(),\n discovery: z.enum([\"sitemap\", \"root_only\", \"partial\"]),\n discovery_error: z.enum([\"robots_unavailable\", \"sitemap_unavailable\", \"sitemap_invalid\", \"sitemap_query_unsupported\"]).optional(),\n pages_discovered: count,\n pages_selected: count,\n pages_audited: count,\n pages_partial: count,\n pages_failed: count,\n pages_skipped_robots: count,\n truncated: z.boolean(),\n next_page_offset: count.optional(),\n discovery_fingerprint: z.string().regex(/^[0-9a-f]{64}$/),\n audit_health_score: z.number().int().min(0).max(100).optional(),\n score_coverage_percent: z.number().int().min(0).max(100),\n pages: z.array(page).max(8),\n issue_groups: z.array(issueGroup).max(50),\n issue_groups_truncated: z.boolean(),\n});\n\nexport type CompactAuditSnapshot = z.infer<typeof compactAuditSnapshotSchema>;\n\nexport interface AuditHistoryItem {\n id: string;\n saved_at: string;\n site_url: string;\n}\n\ninterface PersistedItem extends AuditHistoryItem {\n snapshot: CompactAuditSnapshot;\n}\n\nconst historySchema = z.object({\n version: z.literal(1),\n items: z.array(z.object({\n id: z.string().uuid(),\n saved_at: z.string().datetime({ offset: true }),\n site_url: publicUrl,\n snapshot: compactAuditSnapshotSchema,\n })).max(MAX_AUDIT_HISTORY),\n});\n\nexport interface AuditHistoryResponse {\n count: number;\n items: AuditHistoryItem[];\n snapshot_json?: string;\n evicted_id?: string;\n}\n\nconst basePath = (): string => {\n const configured = process.env.MCP_WEB_VALIDATOR_WORKSPACE_ROOT;\n if (configured === undefined) return os.homedir();\n if (!path.isAbsolute(configured)) {\n throw new Error(\"MCP_WEB_VALIDATOR_WORKSPACE_ROOT must be an absolute directory path.\");\n }\n return configured;\n};\n\nasync function historyFile(rootDirectory: string, create: boolean): Promise<string> {\n const root = await fs.realpath(rootDirectory);\n const dir = path.join(root, HISTORY_DIRECTORY);\n if (create) await fs.mkdir(dir, { recursive: true, mode: 0o700 });\n const entry = await fs.lstat(dir).catch((error: NodeJS.ErrnoException) => {\n if (!create && error.code === \"ENOENT\") return undefined;\n throw error;\n });\n if (!entry) return path.join(dir, HISTORY_FILE);\n if (!entry.isDirectory() || entry.isSymbolicLink()) {\n throw new Error(\"The audit history directory must be a real directory, not a symbolic link.\");\n }\n const realDir = await fs.realpath(dir);\n if (path.dirname(realDir) !== root) {\n throw new Error(\"Audit history directory must stay inside the configured root.\");\n }\n return path.join(realDir, HISTORY_FILE);\n}\n\nasync function readHistory(rootDirectory: string): Promise<PersistedItem[]> {\n const file = await historyFile(rootDirectory, false);\n const info = await fs.lstat(file).catch((error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\") return undefined;\n throw error;\n });\n if (!info) return [];\n if (!info.isFile() || info.isSymbolicLink() || info.nlink !== 1 || info.size > MAX_HISTORY_FILE_BYTES) {\n throw new Error(\"History must be a bounded regular file, not a link or oversized file.\");\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(await fs.readFile(file, \"utf8\"));\n } catch {\n throw new Error(\"Audit history is unreadable or corrupt; no stored versions were modified.\");\n }\n const result = historySchema.safeParse(parsed);\n if (!result.success) throw new Error(\"Audit history is invalid; no stored versions were modified.\");\n return result.data.items;\n}\n\nasync function writeHistory(rootDirectory: string, items: PersistedItem[]): Promise<void> {\n const file = await historyFile(rootDirectory, true);\n const contents = JSON.stringify({ version: 1, items });\n if (Buffer.byteLength(contents, \"utf8\") > MAX_HISTORY_FILE_BYTES) {\n throw new Error(\"The audit history file would exceed the configured size cap.\");\n }\n const tmp = path.join(path.dirname(file), `.${HISTORY_FILE}.${randomUUID()}.tmp`);\n let handle: fs.FileHandle | undefined;\n try {\n handle = await fs.open(tmp, \"wx\", 0o600);\n await handle.writeFile(contents, \"utf8\");\n await handle.sync();\n await handle.close();\n handle = undefined;\n await fs.rename(tmp, file);\n } finally {\n if (handle) await handle.close();\n await fs.rm(tmp, { force: true });\n }\n}\n\nfunction summary(items: PersistedItem[]): AuditHistoryResponse {\n return {\n count: items.length,\n items: items.slice().reverse().map(({ id, saved_at, site_url }) => ({ id, saved_at, site_url })),\n };\n}\n\n// The stdio MCP server normally has one process. Serialize saves in-process\n// so simultaneous client calls cannot overwrite one another's latest version.\nlet pendingSave: Promise<unknown> = Promise.resolve();\n\nexport function parseCompactAuditSnapshot(snapshotJson: string): CompactAuditSnapshot {\n if (Buffer.byteLength(snapshotJson, \"utf8\") > MAX_AUDIT_SNAPSHOT_BYTES) {\n throw new Error(\"Audit snapshot exceeds the 60 KB input limit.\");\n }\n let candidate: unknown;\n try {\n candidate = JSON.parse(snapshotJson);\n } catch {\n throw new Error(\"Audit snapshot must be valid JSON.\");\n }\n const parsed = compactAuditSnapshotSchema.safeParse(candidate);\n if (!parsed.success) {\n throw new Error(\"Audit snapshot must be a valid bounded audit_public_site structured result without secret-bearing URLs.\");\n }\n const compact = JSON.stringify(parsed.data);\n if (Buffer.byteLength(compact, \"utf8\") > MAX_AUDIT_SNAPSHOT_BYTES) {\n throw new Error(\"Compact audit snapshot exceeds the 60 KB storage limit.\");\n }\n return parsed.data;\n}\n\nexport async function listAuditHistory(rootDirectory = basePath()): Promise<AuditHistoryResponse> {\n return summary(await readHistory(rootDirectory));\n}\n\nexport async function getAuditHistorySnapshot(\n id: string,\n rootDirectory = basePath(),\n): Promise<AuditHistoryResponse> {\n const items = await readHistory(rootDirectory);\n const found = items.find((item) => item.id === id);\n if (!found) throw new Error(\"The requested audit history version was not found.\");\n return { ...summary(items), snapshot_json: JSON.stringify(found.snapshot) };\n}\n\nexport function saveAuditHistorySnapshot(\n snapshotJson: string,\n rootDirectory = basePath(),\n): Promise<AuditHistoryResponse> {\n const snapshot = parseCompactAuditSnapshot(snapshotJson);\n const action = async (): Promise<AuditHistoryResponse> => {\n const items = await readHistory(rootDirectory);\n const newItem: PersistedItem = {\n id: randomUUID(),\n saved_at: new Date().toISOString(),\n site_url: snapshot.site_url,\n snapshot,\n };\n const next = [...items, newItem];\n const evicted = next.length > MAX_AUDIT_HISTORY ? next.shift() : undefined;\n await writeHistory(rootDirectory, next);\n return {\n ...summary(next),\n ...(evicted ? { evicted_id: evicted.id } : {}),\n };\n };\n const request = pendingSave.then(action, action);\n pendingSave = request.catch(() => undefined);\n return request;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"audit-history.js","sourceRoot":"","sources":["../src/audit-history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAC/C,MAAM,sBAAsB,GAAG,OAAO,CAAC;AACvC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAC3C,MAAM,YAAY,GAAG,oBAAoB,CAAC;AAE1C,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;IACvD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC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I,IAAI,EAAE,CAAC,WAAW,EAAE;YAClC,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,QAAQ;SACT,CAAC;QACF,MAAM,IAAI,GAAG,CAAC,GAAG,KAAK,EAAE,OAAO,CAAC,CAAC;QACjC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,GAAG,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3E,MAAM,YAAY,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;QACxC,OAAO;YACL,GAAG,OAAO,CAAC,IAAI,CAAC;YAChB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC/C,CAAC;IACJ,CAAC,CAAC;IACF,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjD,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC7C,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import * as fs from \"node:fs/promises\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport { randomUUID } from \"node:crypto\";\nimport { z } from \"zod\";\n\nexport const MAX_AUDIT_HISTORY = 10;\nexport const MAX_AUDIT_SNAPSHOT_BYTES = 60_000;\nconst MAX_HISTORY_FILE_BYTES = 660_000;\nconst HISTORY_DIRECTORY = \".mcp-validator\";\nconst HISTORY_FILE = \"audit-history.json\";\n\nconst publicUrl = z.string().max(2_048).refine((value) => {\n try {\n const url = new URL(value);\n return (url.protocol === \"https:\" || url.protocol === \"http:\")\n && Boolean(url.hostname)\n && !url.username && !url.password && !url.search && !url.hash\n && !url.port;\n } catch {\n return false;\n }\n}, \"Only query-free, credential-free public HTTP(S) URLs may be saved.\");\n\nconst count = z.number().int().nonnegative();\nconst severity = z.enum([\"error\", \"warning\", \"info\"]);\nconst category = z.enum([\"HTML\", \"SEO\", \"Schema\", \"Accessibility\"]);\nconst finding = z.object({\n code: z.string().max(120).optional(),\n severity,\n category,\n message: z.string().max(300),\n});\nconst page = z.object({\n url: publicUrl,\n fetched_url: publicUrl.optional(),\n status: z.enum([\"passed\", \"needs_attention\", \"partial\", \"failed\", \"skipped\"]),\n http_status: z.number().int().min(200).max(299).optional(),\n redirects_followed: z.number().int().min(0).max(3).optional(),\n page_fetched: z.boolean(),\n html_validation_status: z.enum([\"completed\", \"timeout\", \"unavailable\", \"not_run\"]),\n html_errors: count,\n html_warnings: count,\n seo_errors: count,\n seo_warnings: count,\n schema_errors: count,\n schema_warnings: count,\n notes: count,\n health_score: z.number().int().min(0).max(100).optional(),\n failure_code: z.string().max(120).optional(),\n top_findings: z.array(finding).max(3),\n});\nconst issueGroup = finding.extend({\n affected_pages: count,\n example_urls: z.array(publicUrl).max(3),\n});\n\n/**\n * Keep only the fields used by compare_site_audits.\n * Rich page signals, raw HTML, widget state and unrelated user-supplied fields\n * are deliberately not persisted; the hosted app remains completely stateless.\n */\nexport const compactAuditSnapshotSchema = z.object({\n site_url: publicUrl,\n sitemap_url: publicUrl.optional(),\n discovery: z.enum([\"sitemap\", \"root_only\", \"partial\"]),\n discovery_error: z.enum([\"robots_unavailable\", \"sitemap_unavailable\", \"sitemap_invalid\", \"sitemap_query_unsupported\"]).optional(),\n pages_discovered: count,\n pages_selected: count,\n pages_audited: count,\n pages_partial: count,\n pages_failed: count,\n pages_skipped_robots: count,\n truncated: z.boolean(),\n next_page_offset: count.optional(),\n discovery_fingerprint: z.string().regex(/^[0-9a-f]{64}$/),\n audit_health_score: z.number().int().min(0).max(100).optional(),\n score_coverage_percent: z.number().int().min(0).max(100),\n pages: z.array(page).max(8),\n issue_groups: z.array(issueGroup).max(50),\n issue_groups_truncated: z.boolean(),\n});\n\nexport type CompactAuditSnapshot = z.infer<typeof compactAuditSnapshotSchema>;\n\nexport interface AuditHistoryItem {\n id: string;\n saved_at: string;\n site_url: string;\n}\n\ninterface PersistedItem extends AuditHistoryItem {\n snapshot: CompactAuditSnapshot;\n}\n\nconst historySchema = z.object({\n version: z.literal(1),\n items: z.array(z.object({\n id: z.string().uuid(),\n saved_at: z.string().datetime({ offset: true }),\n site_url: publicUrl,\n snapshot: compactAuditSnapshotSchema,\n })).max(MAX_AUDIT_HISTORY),\n});\n\nexport interface AuditHistoryResponse {\n count: number;\n items: AuditHistoryItem[];\n snapshot_json?: string;\n evicted_id?: string;\n}\n\nconst basePath = (): string => {\n const configured = process.env.MCP_WEB_VALIDATOR_WORKSPACE_ROOT;\n if (configured === undefined) return os.homedir();\n if (!path.isAbsolute(configured)) {\n throw new Error(\"MCP_WEB_VALIDATOR_WORKSPACE_ROOT must be an absolute directory path.\");\n }\n return configured;\n};\n\nasync function historyFile(rootDirectory: string, create: boolean): Promise<string> {\n const root = await fs.realpath(rootDirectory);\n const dir = path.join(root, HISTORY_DIRECTORY);\n if (create) await fs.mkdir(dir, { recursive: true, mode: 0o700 });\n const entry = await fs.lstat(dir).catch((error: NodeJS.ErrnoException) => {\n if (!create && error.code === \"ENOENT\") return undefined;\n throw error;\n });\n if (!entry) return path.join(dir, HISTORY_FILE);\n if (!entry.isDirectory() || entry.isSymbolicLink()) {\n throw new Error(\"The audit history directory must be a real directory, not a symbolic link.\");\n }\n const realDir = await fs.realpath(dir);\n if (path.dirname(realDir) !== root) {\n throw new Error(\"Audit history directory must stay inside the configured root.\");\n }\n return path.join(realDir, HISTORY_FILE);\n}\n\nasync function readHistory(rootDirectory: string): Promise<PersistedItem[]> {\n const file = await historyFile(rootDirectory, false);\n const info = await fs.lstat(file).catch((error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\") return undefined;\n throw error;\n });\n if (!info) return [];\n if (!info.isFile() || info.isSymbolicLink() || info.nlink !== 1 || info.size > MAX_HISTORY_FILE_BYTES) {\n throw new Error(\"History must be a bounded regular file, not a link or oversized file.\");\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(await fs.readFile(file, \"utf8\"));\n } catch {\n throw new Error(\"Audit history is unreadable or corrupt; no stored versions were modified.\");\n }\n const result = historySchema.safeParse(parsed);\n if (!result.success) throw new Error(\"Audit history is invalid; no stored versions were modified.\");\n return result.data.items;\n}\n\nasync function writeHistory(rootDirectory: string, items: PersistedItem[]): Promise<void> {\n const file = await historyFile(rootDirectory, true);\n const contents = JSON.stringify({ version: 1, items });\n if (Buffer.byteLength(contents, \"utf8\") > MAX_HISTORY_FILE_BYTES) {\n throw new Error(\"The audit history file would exceed the configured size cap.\");\n }\n const tmp = path.join(path.dirname(file), `.${HISTORY_FILE}.${randomUUID()}.tmp`);\n let handle: fs.FileHandle | undefined;\n try {\n handle = await fs.open(tmp, \"wx\", 0o600);\n await handle.writeFile(contents, \"utf8\");\n await handle.sync();\n await handle.close();\n handle = undefined;\n await fs.rename(tmp, file);\n } finally {\n if (handle) await handle.close();\n await fs.rm(tmp, { force: true });\n }\n}\n\nfunction summary(items: PersistedItem[]): AuditHistoryResponse {\n return {\n count: items.length,\n items: items.slice().reverse().map(({ id, saved_at, site_url }) => ({ id, saved_at, site_url })),\n };\n}\n\n// The stdio MCP server normally has one process. Serialize saves in-process\n// so simultaneous client calls cannot overwrite one another's latest version.\nlet pendingSave: Promise<unknown> = Promise.resolve();\n\nexport function parseCompactAuditSnapshot(snapshotJson: string): CompactAuditSnapshot {\n if (Buffer.byteLength(snapshotJson, \"utf8\") > MAX_AUDIT_SNAPSHOT_BYTES) {\n throw new Error(\"Audit snapshot exceeds the 60 KB input limit.\");\n }\n let candidate: unknown;\n try {\n candidate = JSON.parse(snapshotJson);\n } catch {\n throw new Error(\"Audit snapshot must be valid JSON.\");\n }\n const parsed = compactAuditSnapshotSchema.safeParse(candidate);\n if (!parsed.success) {\n throw new Error(\"Audit snapshot must be a valid bounded audit_public_site structured result without secret-bearing URLs.\");\n }\n const compact = JSON.stringify(parsed.data);\n if (Buffer.byteLength(compact, \"utf8\") > MAX_AUDIT_SNAPSHOT_BYTES) {\n throw new Error(\"Compact audit snapshot exceeds the 60 KB storage limit.\");\n }\n return parsed.data;\n}\n\nexport async function listAuditHistory(rootDirectory = basePath()): Promise<AuditHistoryResponse> {\n return summary(await readHistory(rootDirectory));\n}\n\nexport async function getAuditHistorySnapshot(\n id: string,\n rootDirectory = basePath(),\n): Promise<AuditHistoryResponse> {\n const items = await readHistory(rootDirectory);\n const found = items.find((item) => item.id === id);\n if (!found) throw new Error(\"The requested audit history version was not found.\");\n return { ...summary(items), snapshot_json: JSON.stringify(found.snapshot) };\n}\n\n/**\n * P2-01: read selected immutable saved versions in *stored* chronological\n * order. A single guarded history read; no writes, ID discovery or archive\n * mutation. Reject evicted versions rather than silently substituting them.\n */\nexport async function getAuditHistoryVersions(\n ids: string[],\n rootDirectory = basePath(),\n): Promise<Array<{ saved_at: string; snapshot: CompactAuditSnapshot }>> {\n if (!Array.isArray(ids) || ids.length < 2 || ids.length > MAX_AUDIT_HISTORY\n || new Set(ids).size !== ids.length\n || ids.some((id) => !z.string().uuid().safeParse(id).success)) {\n throw new Error(\"Supply two to ten distinct saved audit version IDs, oldest first.\");\n }\n const history = await readHistory(rootDirectory);\n const byId = new Map(history.map((item, index) => [item.id, { item, index }]));\n let previousIndex = -1;\n const result: Array<{ saved_at: string; snapshot: CompactAuditSnapshot }> = [];\n for (const id of ids) {\n const entry = byId.get(id);\n if (!entry) throw new Error(\"A requested saved audit history version was not found or was evicted.\");\n if (entry.index <= previousIndex) {\n throw new Error(\"Saved audit version IDs must be ordered oldest to newest.\");\n }\n previousIndex = entry.index;\n result.push({ saved_at: entry.item.saved_at, snapshot: entry.item.snapshot });\n }\n return result;\n}\n\nexport function saveAuditHistorySnapshot(\n snapshotJson: string,\n rootDirectory = basePath(),\n): Promise<AuditHistoryResponse> {\n const snapshot = parseCompactAuditSnapshot(snapshotJson);\n const action = async (): Promise<AuditHistoryResponse> => {\n const items = await readHistory(rootDirectory);\n const newItem: PersistedItem = {\n id: randomUUID(),\n saved_at: new Date().toISOString(),\n site_url: snapshot.site_url,\n snapshot,\n };\n const next = [...items, newItem];\n const evicted = next.length > MAX_AUDIT_HISTORY ? next.shift() : undefined;\n await writeHistory(rootDirectory, next);\n return {\n ...summary(next),\n ...(evicted ? { evicted_id: evicted.id } : {}),\n };\n };\n const request = pendingSave.then(action, action);\n pendingSave = request.catch(() => undefined);\n return request;\n}\n"]}
|