WebPerf Snippets — Claude Code MCP server for Core Web Vitals measurement
WebPerf Snippets runs 56 web performance diagnostics snippets in headless Chromium: measures LCP, CLS, INP and their subparts, analyzes resources and render.
MIT ★ 1,458 updated 2026-10-24
claude mcp add webperf-snippets -e CRUX_API_KEY=<CRUX_API_KEY> -- npx -y webperf-snippetsWhat WebPerf Snippets does
The server gives the agent commands to run snippets from the webperf-snippets.net collection via Playwright. Measures Core Web Vitals (LCP, CLS, INP) and breakdowns: TTFB, render delays, blocking resources, long tasks, LoAF script attribution. Built-in workflows: core-web-vitals (LCP and CLS, LCP subparts if threshold is exceeded), loading (11 steps: TTFB, FCP, blocking resources, cache), interaction (tasks, animation frames, scroll, shifts), audit (22 CI checks: compression, fonts, images, DOM size).
Compares measurements with CrUX field data (real user experience at 75th percentile). Needs a Chrome UX Report API key, passed as CRUX_API_KEY during install. Playwright and the chromium browser install separately: npm install --save-dev playwright && npx playwright install chromium.
Pages behind a login open via storage state (cookies and localStorage), behind a proxy via --header flags. Interaction scripts for INP are passed with --interact-script.
What it helps with
- measure Core Web Vitals (LCP, CLS, INP) in a headless browser for CI
- diagnose LCP regressions via subparts (TTFB, Resource Load Delay, Element Render Delay)
- check blocking resources, long tasks and LoAF script attribution
- compare synthetic measurements with real user data from CrUX
- automate DevTools snippets in a CI pipeline
Example prompts for the agent
- Run Core Web Vitals measurement for example.com and compare with CrUX data
- Run the loading workflow on the site and output results as markdown
- Measure INP on a page with interactions from
interactions.json
How to install WebPerf Snippets
Platform CLI
claude mcp add webperf-snippets -e CRUX_API_KEY=<CRUX_API_KEY> -- npx -y webperf-snippetsReplace <…> with your own values
Platform CLI
codex mcp add cli --env CRUX_API_KEY=<CRUX_API_KEY> -- npx -y webperf-snippetsReplace <…> with your own values
Config file
{
"mcpServers": {
"cli": {
"command": "npx",
"args": [
"-y",
"webperf-snippets"
],
"env": {
"CRUX_API_KEY": "<CRUX_API_KEY>"
}
}
}
}Replace <…> with your own values
Config file
{
"servers": {
"cli": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"webperf-snippets"
],
"env": {
"CRUX_API_KEY": "<CRUX_API_KEY>"
}
}
}
}Replace <…> with your own values
Platform CLI
gemini mcp add -e CRUX_API_KEY=<CRUX_API_KEY> cli npx -y webperf-snippetsReplace <…> with your own values
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about WebPerf Snippets
How do I install WebPerf Snippets in Claude Code?
Run claude mcp add webperf-snippets -e CRUX_API_KEY=<CRUX_API_KEY> -- npx -y webperf-snippets. Before that, install Playwright and chromium: npm install --save-dev playwright && npx playwright install chromium.
What does WebPerf Snippets do?
Runs performance diagnostics snippets in a headless browser. Measures Core Web Vitals and their subparts, identifies blocking resources, long tasks, script attribution, and compares with CrUX data.
Why is the CRUX_API_KEY needed?
The key grants access to the Chrome UX Report API, a database of field performance data. With it, the server compares synthetic measurements with what real users experience at the 75th percentile.