Diagnose Core Web Vitals and web performance using curated snippets in a headless Chromium browser via Playwright.
Also known as nucliweb/webperf-snippets, webperf-snippets
- Stars
- 1,455
- Tools
- โ
- Downloads, 30 days
- โ
- Latest version
- 1.16.0
- Last commit
- Nov 12, 2026
- License
- MIT
What is WebPerf Snippets MCP?
WebPerf Snippets is an MCP server. Diagnose Core Web Vitals and web performance using curated snippets in a headless Chromium browser via Playwright.
Summary generated from the project's README
About WebPerf Snippets MCP server
WebPerf Snippets provides a command-line interface for diagnosing Core Web Vitals and web performance using curated snippets. It operates by running these snippets in a headless Chromium browser via Playwright, allowing developers to move beyond the basic scores provided by Lighthouse. The tool is designed for engineers who need to automate performance audits, gate pull requests based on real performance budgets, and identify specific issues like LCP sub-parts or LoAF script attribution.
Users can run specific workflows such as loading, interaction, or structural audits. The server supports authenticated testing through Playwright storage states for pages behind a login, or via custom request headers for sites protected by access proxies. For deeper analysis, it can integrate with the Chrome UX Report API to compare synthetic lab measurements against real-world field data from CrUX. Results can be output in Markdown for pull request comments or JSON for automated processing and reporting to external endpoints.
What you can do with it
- 1Automate performance regression testingA developer can use this tool to gate pull requests by checking performance budgets in a continuous integration environment.
- 2Diagnose specific LCP issuesYou can run a specific snippet to break down Largest Contentful Paint into sub-parts like TTFB and render delay.
- 3Audit authenticated web pagesAn engineer can measure the performance of a dashboard or private page by providing a saved session file.
- 4Compare lab and field dataYou can compare your synthetic measurements against the actual experience of real users using the CrUX API.
Written from the project's README. Every use case is checked against a quote from it.
How to install WebPerf Snippets MCP
Formats verified 10 Nov 2026Install WebPerf Snippets MCP in Claude Code
$ claude mcp add --env CRUX_API_KEY=<YOUR_CRUX_API_KEY> webperf-snippets -- npx -y webperf-snippetsInstall WebPerf Snippets MCP in Cursor
~/.cursor/mcp.json
{
"mcpServers": {
"webperf-snippets": {
"command": "npx",
"args": [
"-y",
"webperf-snippets"
],
"env": {
"CRUX_API_KEY": "<YOUR_CRUX_API_KEY>"
}
}
}
}Install WebPerf Snippets MCP in VS Code
.vscode/mcp.json
{
"servers": {
"webperf-snippets": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"webperf-snippets"
],
"env": {
"CRUX_API_KEY": "<YOUR_CRUX_API_KEY>"
}
}
}
}Install WebPerf Snippets MCP in Claude Desktop
claude_desktop_config.json
{
"mcpServers": {
"webperf-snippets": {
"command": "npx",
"args": [
"-y",
"webperf-snippets"
],
"env": {
"CRUX_API_KEY": "<YOUR_CRUX_API_KEY>"
}
}
}
}Install WebPerf Snippets MCP in Codex
~/.codex/config.toml
[mcp_servers.webperf-snippets] command = "npx" args = ["-y", "webperf-snippets"] [mcp_servers.webperf-snippets.env] CRUX_API_KEY = "<YOUR_CRUX_API_KEY>"
Install WebPerf Snippets MCP in Gemini CLI
~/.gemini/settings.json
{
"mcpServers": {
"webperf-snippets": {
"command": "npx",
"args": [
"-y",
"webperf-snippets"
],
"env": {
"CRUX_API_KEY": "<YOUR_CRUX_API_KEY>"
}
}
}
}Configuration
CRUX_API_KEYSecretChrome UX Report API key for the field data of get_crux; the other tools work without it
| Name | Description | |
|---|---|---|
| CRUX_API_KEY | Chrome UX Report API key for the field data of get_crux; the other tools work without it | Secret |
Automated checks
Ran Nov 12, 2026Full report โPassed our automated checks. That is not a security audit: read the code and give the server the narrowest access it needs. How checks work
- Source repository linked and reachablePass
- Open source license (OSI)Pass
- Commit or release in the last yearPass
- Package name not close to a popular packagePass
- Remote endpoint uses HTTPSNot checked
- Destructive tools are labelledNot checked
- No hidden instructions to the modelPass
- No critical advisory in the package or its dependenciesPass
README
View on GitHubwebperf-snippets CLI
Run curated WebPerf Snippets headlessly via Playwright. Diagnose Core Web Vitals beyond what Lighthouse exposes and gate CI on real performance budgets.
Status: v0.4. Core Web Vitals, loading, interaction and structural audit workflows, and every snippet of the collection by name. See the Roadmap.
Why
Lighthouse gives you a score. The DevTools snippets give you the diagnosis, such as TTFB / Resource Load Delay / Element Render Delay sub-parts, LoAF script attribution, and render-blocking resources. This CLI runs the same curated snippets in a headless browser so you can:
- Diagnose LCP regressions in CI without copy-pasting into DevTools.
- Gate pull requests on real performance budgets.
- Automate the snippets you already run by hand.
Install
Playwright is a peer dependency. Install both, plus the chromium browser:
npm install --save-dev webperf-snippets playwright
npx playwright install chromium
npx playwright install chromium downloads two builds of Chromium: the full Chromium and the headless shell. The CLI and its MCP server run the full Chromium in its headless mode, the binary of Chrome DevTools MCP and of a --headed run, and the headless shell only when it is the one installed (--only-shell). The full Chromium alone is enough, and skips the download of the headless shell (266 MB on Linux ARM64):
npx playwright install --no-shell chromium
Usage
npx webperf-snippets <url> [options]
Examples
Run the default Core Web Vitals workflow (LCP + CLS, plus LCP-Subparts if LCP > 2.5s):
npx webperf-snippets https://example.com
Loading audit (11 steps: TTFB, FCP, render-blocking, scripts, resource timings, third-party impact, fonts, cache; the list is in the CLI page):
npx webperf-snippets https://example.com --workflow loading
The steps that tell first-party from third-party resources count as first party the root domain of the page and its subdomains (cdn.example.com for example.com). A site that serves its own assets from another domain, such as its CDN, lists it with --own-domains, comma-separated or repeated:
npx webperf-snippets https://example.com --workflow loading --own-domains cdn.example.net,static.example.org
Each domain counts with its root domain, so cdn.example.net makes every host under example.net first party. The CLI writes the list in the OWN_DOMAINS constant of each snippet, the same one you edit at the top of the snippet in the console. An empty domain or one with spaces exits with code 2.
Structural checks for CI (22 checks: render-blocking, compression, fonts, images, hints, DOM size and more; the list is in the CLI page):
npx webperf-snippets https://example.com --workflow audit
Markdown output for PR comments:
npx webperf-snippets https://example.com --markdown
JSON output (for piping into jq or CI):
npx webperf-snippets https://example.com --json
Before its results, the JSON output says when the page was measured and what the results found, as the JSON the audit of the DevTools extension exports, so a script or an agent reads it without going through every result: date, when the measurement started, in UTC; overview, how many snippets have errors, warnings only or nothing to fix (a snippet that failed counts as an error, and a rating that is not good as a warning when no issue says more); and issues, every issue of every result in one list, errors first, then warnings and info, each with its code, severity, the id of its step, the path of its snippet, its message and, when it has one, its target. A follow-up of the decision tree lists its issues too, and they do not change the exit code.
"date": "2026-11-11T09:00:00.000Z",
"overview": { "snippets": 22, "withErrors": 5, "withWarnings": 6, "withNothingToFix": 11 },
"issues": [
{ "code": "render-blocking", "severity": "error", "id": "render-blocking", "path": "Loading/Find-render-blocking-resources", "message": "2 render-blocking resources delay the first paint until 532ms" }
]
The JSON output records how the page was measured in conditions, so a later run can tell whether it measured the same way: the viewport, the workflow (or the path of the snippet with --snippet), the wait, the browser (build chromium for the full Chromium or chromium-headless-shell, its mode and its version), the version of the CLI and the machine: its CPU model, cores, architecture and memory, as the operating system reports them, and a benchmark index, a short CPU test in Node before Chromium starts, which only informs, since on the same machine it moves by up to 40 % with the load.
"conditions": { "viewport": "mobile", "workflow": "core-web-vitals", "waitMs": 3000, "browser": { "build": "chromium", "mode": "headless", "version": "153.0.8010.12" }, "cliVersion": "1.15.0", "machine": { "cpu": "Apple M4", "cores": 10, "arch": "arm64", "memoryGB": 16, "benchmarkIndex": 2371 } }
Single snippet:
npx webperf-snippets https://example.com --snippet LCP-Subparts
Synthetic INP measurement with an interaction script:
npx webperf-snippets https://example.com --snippet INP --interact-script interactions.json
npx webperf-snippets https://example.com --snippet Interaction/Interactions --interact-script interactions.json
The Interaction snippets (Interactions, Input-Latency-Breakdown, LongTask, Forced-Synchronous-Layout...) are installed before the first step and read after the last one, so their result holds what the steps caused.
The CLI waits for the browser to report the timing of the last interaction before it reads the snippets. A script that ends right after a click still reads the page before anything the click sets in motion later has happened, such as a request or an animation, so end it with a wait step when you want to measure that.
Interaction audit (long tasks, long animation frames, scroll, layout shifts, forced layouts, interaction latency). It scrolls the page, or runs your --interact-script; the steps that need a click are skipped when the script has none:
npx webperf-snippets https://example.com --workflow interaction
Pages behind a login, with a Playwright storage state (cookies and localStorage):
# Step 1: sign in once and save the session
npx playwright codegen --save-storage=auth.json https://example.com/login
# Step 2: measure an authenticated page
npx webperf-snippets https://example.com/dashboard --storage-state auth.json
The file holds live session cookies. Keep it out of version control (add it to .gitignore) and use a throwaway account when you run it in CI. The CLI exits with code 2 if the path does not exist.
Pages behind an access proxy that reads a token from every request, such as the service tokens of Cloudflare Access, take the token as request headers with --header, once per header:
npx webperf-snippets https://review.example.com \
--header "CF-Access-Client-Id: $CF_ACCESS_CLIENT_ID" \
--header "CF-Access-Client-Secret: $CF_ACCESS_CLIENT_SECRET"
The headers go with every request to the origin of the URL and never to another origin, so third parties do not receive the token and their cross-origin requests need no CORS preflight. Each request to that origin is paused in the browser to add them, which adds a few milliseconds to its timing; when the proxy accepts a session cookie, --storage-state measures without that cost. A header without a name or a colon exits with code 2. Read the values from environment variables, as above, to keep them out of the shell history.
Compare the measured values with CrUX field data (what real users experience at the 75th percentile):
CRUX_API_KEY=your-key npx webperf-snippets https://example.com
Field data (CrUX p75, mobile)
๐ก LCP 2.80s needs-improvement (synthetic: 2.10s)
๐ข CLS 0.0800 good (synthetic: 0.0500)
๐ก INP 220ms needs-improvement (synthetic: n/a)
Get a key for the Chrome UX Report API and pass it with --crux-key or the CRUX_API_KEY environment variable; prefer the variable, because a flag ends up in shell history and CI logs. The section appears in the human and markdown output and under crux in the --json output.
With a key, the field data also gives what CrUX knows of the LCP when it is an image: the p75 of its sub-parts, TTFB, load delay, load duration and render delay. When the measurement ran LCP-Subparts, with --snippet LCP-Subparts or the core-web-vitals workflow over 2.5 s, a table puts each one next to its lab value, with a note where one side is at least 1.5 times the other and 100 ms apart: a slower server or network for users, an image the lab finds sooner, slower connections, slower devices, or a lab slower than users. The field sub-parts describe only the loads whose LCP is an image, and the table says which share that is; when the LCP of the lab is not an image, only TTFB and render delay compare. Each p75 is taken on its own, so the sub-parts do not add up to the p75 of LCP. A line gives the navigation types of the users, by share, and points to Back-Forward-Cache when over 5 % of the visits come back without the back/forward cache. The JSON output carries them in crux.subParts, crux.lcpImageShare, crux.roundTripTime and crux.navigationTypes.
--crux-history <weeks> adds the trend of the field data over the last 1 to 40 weeks, from the CrUX History API, with the same key. Each week is the p75 of the 28 days before it, so the weeks overlap and the series is smooth. For LCP, CLS and INP the section gives the first and the last week, the change between them and its direction, stable within 5 %, and the weeks as a sparkline, where a gap is a week with too little data. The bars span at least the smallest change --baseline counts for the metric (100 ms for LCP, 50 ms for INP, 0.05 for CLS), so a series that barely moves draws almost flat:
Field data trend (CrUX p75, 40 weeks, mobile, origin-level)
LCP 2.88s โ 3.10s โฒ +7.7% worsening โโโโโโโโโโโโโโโโโโโโโ
โโโโโโ
CLS 0.2600 โ 0.2100 โผ โ19.2% improving โ
โโโโโโโโโ
โโโโโโโโโโโโโโโโ
INP 253ms โ 251ms โผ โ0.8% stable โ
โ
โ
โโโโ
โ
โโโโ
โ
โโโโโ
โ
โ
โ
โโโโโโโโโ
โ
The JSON output carries it in crux.history, with the periods, the p75 of each week and the trend of each metric. Like the p75, it uses the page when it has data of its own and its origin otherwise, and says which in scope.
- The population follows
--viewport:desktopuses desktop data,mobileandtabletuse phone data. The heading says which one. - When the page itself has no data, the CLI looks the origin up instead and labels the section
origin-level, so it is not mistaken for page-level data. If the origin has none either, the output saysField data: not available. - A CrUX error (quota, network, no answer within 10 seconds) only skips the section. It never changes the exit code, and the key is never printed.
- INP shows
n/aas the synthetic value unless you run an interaction script.
Send the results to an endpoint after the run with --report-to:
npx webperf-snippets https://example.com --workflow audit \
--report-to https://reports.example.com/api/report \
--api-key $REPORT_API_KEY
Without --report-to the CLI makes no external calls. With it, the results are POSTed as JSON once the snippets have finished:
{
"url": "https://example.com",
"workflow": "audit",
"timestamp": "2026-05-06T10:00:00.000Z",
"navMs": 1240,
"overview": { "snippets": 22, "withErrors": 5, "withWarnings": 6, "withNothingToFix": 11 },
"issues": [],
"results": [],
"meta": { "viewport": "mobile", "waitMs": 3000, "cli_version": "1.15.0" }
}
For a --snippet run, workflow is null and a snippet field carries the name. With --cpu or --network, meta carries the conditions in throttling, and with --runs, the summary of the runs in runs. overview, issues and results are the ones of the --json output, so it can include URLs and details of the measured page; send it only to an endpoint you trust.
- The URL must be
https.httpis accepted only forlocalhost, so a key is never sent in clear text. --api-keyis sent asAuthorization: Bearer <key>. Prefer thePERF_REVIEWS_API_KEYenvironment variable, because a flag ends up in shell history and CI logs. The key is never printed.- The exit code never depends on the report. A failed POST (error status, unreachable endpoint, or no answer within 5 seconds) prints a warning and the exit code stays the one the budgets and snippets decide. If the endpoint answers
{ "ok": false, "regressions": [...] }, the regressions are printed as a warning, again without changing the exit code.
Measure under the conditions of a slower device and network with --cpu and --network. Without them the CLI runs at the speed of the machine, which on a laptop or a CI runner is faster than most phones:
npx webperf-snippets https://example.com --cpu 4 --network slow-4g
--cpu <factor> slows the main thread down by that factor. --network takes the presets of DevTools, with the same values:
| Preset | Download | Upload | Latency |
|---|---|---|---|
fast-4g |
8.1 Mbps | 1.35 Mbps | 165 ms |
slow-4g |
1.44 Mbps | 675 kbps | 562.5 ms |
3g |
400 kbps | 400 kbps | 2000 ms |
Chrome adds the latency to the body of each response, not to its headers. The values read from responseStart, such as the TTFB and its sub-parts, do not include it; the download of each resource, FCP, LCP and the load event do. The report names the conditions under its header, and the JSON output carries them in throttling, such as { "cpu": 4, "network": "slow-4g" }. A CPU factor below 1 or an unknown preset exits with code 2.
One page load is one sample, and lab values vary from one load to the next. --runs <n> measures the page n times, from 1 to 9, one after the other, and reports the median run, as WebPageTest does: every result comes from that run, so they agree with each other (the sub-parts of the LCP add up to its LCP):
npx webperf-snippets https://example.com --runs 5 --budget-lcp 2500
The median run is the one with the median LCP. A workflow without LCP uses the first of FCP, TTFB, INP and the navigation time that it measures, so a measurement of interactions answers with its median INP, and --median-by <metric> picks another one (LCP, FCP, TTFB, CLS, INP or navMs). With an even count it takes the lower of the two middle runs, so the report is always a run that happened. The report adds the median, min and max of each metric across the runs, and how much the runs agree, and the JSON output carries them in runs:
"runs": {
"count": 5,
"failed": 0,
"medianRun": 3,
"medianBy": "LCP",
"summary": {
"LCP": { "median": 2140, "min": 1980, "max": 2610, "values": [2610, 2010, 2140, 1980, 2290], "unit": "ms", "cv": 11.6, "agreement": "noisy" }
}
}
medianRun counts from 1, and values keeps the order of the runs. cv is the coefficient of variation of the runs, their standard deviation over their mean in percent, and agreement its band: consistent up to 5 %, variable up to 10 % and noisy above, where one median says little and more runs help. Runs that vary by less than half of the minimum change of --baseline (50 ms for LCP, FCP and TTFB, 25 ms for INP, 0.025 for CLS) are consistent whatever their CV, since a local TTFB of 3 to 18 ms has a CV of 64 %. The budgets compare the median of each metric, not one run. A run that fails, such as a navigation that does not finish, counts in failed and is left out of the median; when every run fails, the command exits with code 1. Each run is reported on stderr as it starts, so stdout keeps only the report. An invalid count or metric exits with code 2.
Measure several pages, on several devices and in several variants, in one command with --matrix <file>. The file lists them, and the CLI measures every URL on every device and in every variant, each combination runs times, one load after the other:
{
"urls": {
"home": "https://example.com/",
"article": "https://example.com/news/some-article"
},
"devices": {
"mobile": { "viewport": "mobile", "cpu": 4, "network": "slow-4g" },
"high-end": { "viewport": "mobile", "cpu": 1, "network": { "downloadKbps": 50000, "uploadKbps": 10000, "latencyMs": 20 } },
"desktop": { "viewport": "desktop" }
},
"variants": {
"no-consent": {},
"consent": { "storageState": "states/consent.json" }
},
"runs": 3
}
npx webperf-snippets --matrix matrix.json --budget-lcp 2500
urls: names and URLs. An array of URLs also works, and names each one by its path and query (/,/news/), with the host when the URLs have more than one.devices: theviewportpreset, thecpufactor and thenetwork, a preset (fast-4g,slow-4g,3g) or a network of its own in kilobits per second and milliseconds, for the ones DevTools has no preset for, such as 5G. An array of viewport presets (["mobile", "desktop"]) is a shortcut for devices without throttling. Withoutdevices, the matrix measures a mid-range phone, with CPU 4x and Slow 4G, as Lighthouse does.variants: the conditions of each variant,storageState(relative to the file),headersandownDomains. Withoutvariants, the combinations are the pages on the devices: the report has no Variant column, and theidof a combination is its page and device (/news/ ยท mobile).runs(1 to 9) andmedianBy, which--runsand--median-byreplace.
The options of the command line apply to every combination: --workflow, --snippet, --wait, --interact-script, --header, --own-domains, --storage-state, --cpu, --network and the budgets. The file replaces cpu, network and storageState where it sets them, and its headers and ownDomains add to the ones of the command line, the variant winning on the same header. A matrix file is meant to be versioned, so pass secrets, such as the token of an access proxy, with --header and an environment variable; a header of the file whose name looks like a secret raises a warning. A key the CLI does not know is an error, so a typo does not measure without its condition.
The report is a table with one row per combination and the rated median of each metric, a variable or noisy one followed by the coefficient of variation of its runs (๐ก 2.71s ยฑ14%), then the errors that decide the exit code; --verbose adds the report of the median run of each combination. --markdown gives the same table and folds the report of each combination into a <details> block, to keep a pull request comment readable. With --json, it is { "matrix", "date", "runs", "combinations" }, with the date the matrix started, each combination being the report of its median run with its id, name, device, variant (when the file defines variants), date, overview, issues, runs and conditions, with the viewport of its device. The budgets compare the median of each combination. The command exits with code 1 when a combination exceeds a budget, has an error or fails every run, and with code 2 for an invalid file, before any page load, naming the place of the problem in the JSON. --viewport does not apply, since each device sets its own.
With CrUX, the CLI asks once for each URL and form factor, so the variants of a device share their field data. With --report-to, it posts one report for each combination, the body of one page with meta.device, meta.variant and meta.runs; the headers of the command line and of the file are conditions of the load, and no report carries their values.
Compare a run with an earlier one with --baseline <file>, the --json output of that run. The comparison says which metrics got worse or better beyond the noise of the lab, which errors are new or fixed, and what differs in how both runs were measured:
# On main, once: the baseline
npx webperf-snippets https://example.com --runs 5 --json > baseline.json
# On the pull request: compare and report
npx webperf-snippets https://pr-123.example.com --runs 5 --baseline baseline.json --markdown
WebPerf Snippets MCP questions
How do I add WebPerf Snippets MCP to Claude Code?
Run claude mcp add --env CRUX_API_KEY=<YOUR_CRUX_API_KEY> webperf-snippets -- npx -y webperf-snippets in your terminal. Add --scope user to make it available in every project.
How do I add WebPerf Snippets MCP to Cursor?
Open ~/.cursor/mcp.json and add the server under mcpServers, using the Cursor config shown in the install section above.
How do I measure pages that require a login?
You can use a Playwright storage state file containing cookies and localStorage by passing it with the --storage-state flag.
Can I use this in a CI/CD pipeline?
Yes, you can gate pull requests on performance budgets and output results in Markdown for PR comments or JSON for automated processing.
How can I compare synthetic measurements with real user data?
By providing a Chrome UX Report (CrUX) API key, the tool compares your lab measurements with field data from real users.
Does the tool make external calls by default?
No, the CLI does not make any external calls unless you explicitly use the --report-to flag to send results to an endpoint.