Skip to content
FunCoding

pagespeed-insights-mcp

Listed in the official MCP Registry

Google PageSpeed Insights and CrUX: six workflow tools for web performance.

Star
85
Version
v2.5.0
License
Apache-2.0
Last commit
Dec 1, 2026

PageSpeed Insights MCP Server

npm version npm downloads GitHub Release CI Documentation Live Demo License: Apache-2.0

Web performance engineering MCP server for Google PageSpeed Insights, Chrome UX Report (CrUX), and local Lighthouse. Audit public pages or localhost, inspect screenshots natively, track historical CrUX trends, enforce performance budgets in CI, and get code-level fixes directly inside Claude, Cursor, Codex, or Antigravity.

PageSpeed MCP chat demo PageSpeed MCP terminal demo

MCP Toplist Glama MCP Pagespeed Insights MCP on MCPRush Buy Me A Coffee


⚡ Quick Start (Zero-Config)

Paste into your MCP client config (claude_desktop_config.json, Cursor, or Antigravity) and restart:

{
  "mcpServers": {
    "pagespeed-insights": {
      "command": "npx",
      "args": ["-y", "pagespeed-insights-mcp"],
      "env": {
        "GOOGLE_API_KEY": "your-google-api-key"
      }
    }
  }
}
More configs: Codex / Grok (TOML), Docker, or Zero-Key mode

Codex / OpenAI / Grok (config.toml):

[mcp_servers.pagespeed-insights]
command = "npx"
args = ["-y", "pagespeed-insights-mcp"]
env = { GOOGLE_API_KEY = "your-google-api-key" }

Docker:

docker build -t pagespeed-insights-mcp .
docker run -i -e GOOGLE_API_KEY=your-key pagespeed-insights-mcp

No API key yet? You can omit env completely to start immediately:

  • Public URLs work up to Google's anonymous PSI quota.
  • localhost / private URLs run via local Chrome + Lighthouse CLI without any API key.
  • Get a free key at Google Cloud Console (enable PageSpeed Insights API & Chrome UX Report API) for 25,000 req/day and CrUX field data.

🔥 Why This Server

  • Hybrid Cloud + Local Engine: Public URLs run on Google PSI; localhost, 127.0.0.1, private IPs, and .local domains automatically run via local Chrome + Lighthouse CLI (with extraHeaders for auth-protected staging).
  • Evidence-Backed AI Remediation: Covers 48 Lighthouse 12/13 audits with concrete offending URLs/DOM selectors, framework stackPacks guidance (Next.js, React, etc.), and optional workspaceDir mapping to file:line in your repo.
  • Multimodal Visual Debugging: focus="visual" returns native MCP image screenshots & filmstrip keyframes plus LCP/CLS bounding-box coordinates so multimodal models see layout shifts directly.
  • Real-User CrUX + Historical Trends: 28-day p75 Core Web Vitals, Good / Needs Improvement / Poor histograms, and multi-week CrUX History trends (includeHistory: true) to pinpoint when regressions started.
  • Statistically Honest Regression Tracking: Multi-run median + spread (runs: 3–5), fetchTime replay deduplication, disjoint-range guaranteedDelta verdicts, and git-committable .pagespeed/baselines.json.
  • Same Engine in IDE & CI/CD: Built-in .pagespeed.json performance budgets, check CLI gate for GitHub Actions, and stateless Streamable HTTP transport (--http) for shared team deployments.

🛠️ Tools (v2)

Every data tool accepts responseFormat (markdown default, or json) and returns MCP structuredContent.

ToolPurpose
pagespeed_analyze_pageLighthouse health check (summary), full report, 48-audit recommendations (with optional workspaceDir & budget), audit, or Mermaid performance-map.
pagespeed_diagnose_pageDeep-dive through one lens: visual (native images + bounding boxes), elements (LCP phases & CLS), network, javascript, images, render-blocking, or third-parties. Reuses cached analysis automatically.
pagespeed_get_field_dataCrUX real-user Core Web Vitals (scope: "page" | "origin"), traffic histograms, and optional weekly includeHistory: true trends.
pagespeed_compare_pagesSide-by-side comparison (mode: "pages") or multi-run regression check against a stored baseline (mode: "baseline").
pagespeed_analyze_batchParallel triage of 1–10 URLs bounded by MAX_CONCURRENCY with MCP progress notifications.
pagespeed_clear_cacheClear the in-memory response cache after a deploy.

MCP Prompts (Slash Commands) & Resources

PromptWhat it runs
/performance-auditGuided 4-step triage: Lighthouse summary → CrUX field data → targeted diagnostic → prioritized fix plan.
/release-comparisonStaging vs production comparison with a clear GO / NO-GO release verdict.
/core-web-vitals-deepdiveContrasts real-user CrUX field metrics against synthetic Lighthouse lab data for LCP, INP, and CLS.
Resource URI / TemplateContent
pagespeed://web-vitals-guideOfficial 2026 Core Web Vitals thresholds & optimization playbook (text/markdown).
pagespeed://baselinesAll locally stored baselines (application/json).
pagespeed://baseline/{strategy}/{encodedUrl}Dynamic template to read a single stored baseline snapshot (application/json).

🚀 CI Performance Gate & Streamable HTTP

CI / GitHub Actions Budget Check (check)

# Inline budget thresholds (exits 0 on pass, 1 on budget violation or baseline regression)
npx pagespeed-insights-mcp check https://example.com --strategy mobile --min-score 90 --max-lcp 2500 --max-cls 0.1

# Or load thresholds from .pagespeed.json (supports route overrides) and output JSON
npx pagespeed-insights-mcp check https://example.com --budget .pagespeed.json --json

# Per-type transfer budgets (Lighthouse resource-summary; 0 is a real limit, an unmeasured run fails the check)
npx pagespeed-insights-mcp check https://example.com --max-js-bytes 150000 --max-image-bytes 400000

.pagespeed.json is discovered from the nearest project root (.git or .pagespeed.json) at or above the working directory, so check and the MCP server pick up the same strategy, budget and route budgets from any checkout subdirectory. Precedence: per-call/flag values > route budget (exact URL, else pathname) > budget. The MCP pagespeed_analyze_page and pagespeed_compare_pages tools apply the same defaults; compare resolves each URL's route budget independently.

Example .pagespeed.json
{
  "strategy": "mobile",
  "budget": {
    "performanceScore": 85,
    "lcp": 2500,
    "cls": 0.1,
    "tbt": 200,
    "jsBytes": 150000,
    "imageBytes": 400000
  },
  "budgets": {
    "/checkout": {
      "performanceScore": 92,
      "lcp": 2000,
      "jsBytes": 100000
    }
  },
  "baselinesDir": ".pagespeed"
}

Budget keys: performanceScore (≥), lcp/tbt/fcp/si/ttfb (ms, ≤), cls (≤), totalByteWeight (bytes, ≤), jsBytes and imageBytes (transfer bytes from Lighthouse resource-summary, ≤). A budget whose measurement is missing from the result fails rather than passing silently.

Baseline storage (.pagespeed/baselines.json)

Baseline files are shared by the CLI and MCP server. The directory is chosen in this order (first match wins):

  1. PAGESPEED_BASELINES_DIR environment variable.
  2. baselinesDir in the project's .pagespeed.json (relative paths resolve against that file).
  3. <project root>/.pagespeed/ — created on first write, so it does not need to pre-exist. The project root is the nearest ancestor with .git or .pagespeed.json, so baselines land in the checkout, not in the subdirectory.
  4. ~/.pagespeed-mcp/ when there is no project — a personal global store is never mixed with a project's.

Streamable HTTP Transport (--http)

Run a shared stateless MCP server for teams or cloud agents (/mcp endpoint + /health probe + optional Bearer auth):

MCP_AUTH_TOKEN=your-secret npx pagespeed-insights-mcp --http --port 3000 --host 127.0.0.1

⚙️ Environment Variables

VariableDefaultDescription
GOOGLE_API_KEY(optional)Recommended for higher PSI quotas; required for CrUX field data.
MAX_CONCURRENCY3Concurrent upstream/local analysis limit (1–10).
REQUEST_TIMEOUT30000Per-request timeout in milliseconds (1000–60000).
RETRY_ATTEMPTS3Retry count for transient 5xx/network failures (0–5).
CACHE_TTL3600In-memory cache TTL in seconds (60–86400).
LOG_LEVELinfotrace | debug | info | warn | error | fatal (JSON to stderr).
LOG_PRETTYfalseSet true for colorized logs when dev dependencies are installed. Otherwise, logs stay JSON on stderr.
MCP_AUTH_TOKEN(optional)Bearer token required on /mcp in --http mode.
PAGESPEED_BASELINES_DIR(optional)Override baseline storage dir. Without it: .pagespeed/baselinesDir, else <project root>/.pagespeed/, else ~/.pagespeed-mcp.
CHROME_PATH(auto)Chrome/Chromium binary path for local Lighthouse (localhost).

📚 Documentation & Development

npm run dev        # Run with tsx
npm run build      # Compile TypeScript -> dist/
npm run lint       # ESLint
npm run typecheck  # tsc --noEmit
npm test           # Vitest suite

Acknowledgments & License

Special thanks to @engmsaleh and @system-conf for their significant contributions to this project.

Licensed under Apache-2.0.

Similar MCP servers

Featured

activepieces

An open-source Zapier alternative; every integration is also available as an MCP server.

ACactivepieces/activepieces26k116 new stars in the last 7 days

Featured

n8n-mcp

Gives your agent docs for 2,900+ n8n nodes so it can build workflows for you.

CZczlonkowski/n8n-mcp23k32 new stars in the last 7 days

mobilerun

Control real Android and iOS devices with LLM agents — tap, swipe, type, automate flows.

DRdroidrun/mobilerun10k62 new stars in the last 7 days

mcp-agent

Build effective agents using Model Context Protocol and simple workflow patterns

LAlastmile-ai/mcp-agent8.6k3 new stars in the last 7 days

spec-workflow-mcp

A Model Context Protocol (MCP) server that provides structured spec-driven development workflow tools for AI-assisted software development, featuring a real-time web dashboard and VSCode extension for monitoring and managing your project's progress directly in your development environment.

PIPimzino/spec-workflow-mcp4.3k2 new stars in the last 7 days

n8n-nodes-mcp

n8n custom node for MCP

NEnerding-io/n8n-nodes-mcp3k1 new stars in the last 7 days