MCPLighthouseClaude CodeCursorWindsurfAI Agents

Lighthouse MCP Server for Claude Code, Cursor & Windsurf

Connect Claude Code, Cursor, Windsurf, and VS Code to PageSpeed Exporter's Lighthouse MCP server. Run live audits, read scorePlan, and fix Core Web Vitals.

PageSpeed Exporter Team··4 min read

A Lighthouse MCP server lets AI coding agents run live Google PageSpeed Insights audits directly from your terminal or IDE, inspect a stripped AIReport under 50KB, edit the exact source files causing slow Core Web Vitals, and re-scan to verify the fix.

Instead of copying screenshots from pagespeed.web.dev or wrestling with 500KB–2MB raw PSI JSON dumps, your agent calls one MCP tool (analyze_url), reads scorePlan.pointsAtRisk, patches your codebase, and loops until every lab metric hits targetFor90.


Why Use MCP Instead of Manual Lighthouse Exports?

WorkflowPayload SizeContext Window ImpactRe-scan LoopSetup
| Google PSI Web UI | N/A (visual only) | Manual copy/paste | Manual | None |

| Raw PSI API / CLI JSON | 500 KB – 2 MB | High (screenshots + passing audits) | Scripted | Google API key |

| Downloaded AIReport JSON | Under 50 KB | Low (culprits + scorePlan only) | Re-upload each run | None |

| PageSpeed Exporter MCP | Under 50 KB | Low (tool call in-editor) | Autonomous tool call | 1 account token |

Every analyze_url call returns the same stripped AIReport produced by the web app: 0–100 category scores, Core Web Vitals lab metrics, CrUX real-user field data, scorePlan ranked by pointsAtRisk, fixLocation ownership (code, build-config, server-cdn, third-party, asset), exact culprit selectors/modules, and framework stackPacks.


Step 1: Create Your MCP Account Token

  1. Sign in at speedexporter.com and open your account dashboard.
  2. Generate an MCP token and copy it once (only a SHA-256 hash is stored server-side).
  3. MCP calls share your account's monthly report allowance with the website:

- Free (\$0): 5 mobile reports/month

- Starter (\$9/month): 50 reports/month, Mobile + Desktop + Both

- Pro (\$29/month): 200 reports/month, batch ZIP export

Handshake and discovery calls (initialize, tools/list, prompts/get) are never billed. If you upgrade on the same account later, your existing token immediately picks up the higher allowance with no reconfiguration.


Step 2: Connect Your Coding Agent

Endpoint: https://speedexporter.com/api/mcp (HTTP, JSON-RPC 2.0, MCP spec 2024-11-05).

Claude Code (CLI)

Register the server in a single command:

claude mcp add --transport http pagespeed-exporter \
  https://speedexporter.com/api/mcp \
  --header "Authorization: Bearer YOUR_ACCOUNT_TOKEN"

See the dedicated Claude Code workflow page for terminal prompts.

Cursor (.cursor/mcp.json)

{
  "mcpServers": {
    "pagespeed-exporter": {
      "url": "https://speedexporter.com/api/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_ACCOUNT_TOKEN"
      }
    }
  }
}

You can also pair this with our Cursor guide and downloadable rule file (/cursor-rules/pagespeed.mdc).

Windsurf (~/.codeium/windsurf/mcp_config.json)

{
  "mcpServers": {
    "pagespeed-exporter": {
      "serverUrl": "https://speedexporter.com/api/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_ACCOUNT_TOKEN"
      }
    }
  }
}

VS Code / GitHub Copilot (.vscode/mcp.json)

{
  "servers": {
    "pagespeed-exporter": {
      "type": "http",
      "url": "https://speedexporter.com/api/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_ACCOUNT_TOKEN"
      }
    }
  }
}

Claude Desktop (claude_desktop_config.json)

Add the same mcpServers block to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows), then restart Claude Desktop. Full details are on the MCP server documentation page.


Step 3: Run the scorePlan Fix Loop

Once connected, trigger either the built-in fix_all_issues prompt or a direct instruction like:

Call analyze_url on https://staging.example.com with strategy "mobile".

1. Read scorePlan first and list each metric's numericValue, pointsAtRisk, and targetFor90.
2. Edit our project files for every failing issue whose affectsMetrics includes the metric with the largest pointsAtRisk.
3. Use fixLocation, selectors, source modules, and thirdParty/entity ownership so you only edit files we control.
4. Skip passedAuditIds and do not sort by savings.ms.
5. After I deploy the preview branch, call analyze_url again and stop only when every lab metric reaches targetFor90.

Why pointsAtRisk Beats savings.ms

Lighthouse calculates your 0–100 performance score from five weighted lab metrics: TBT (30%), LCP (25%), CLS (25%), FCP (10%), and Speed Index (10%). An opportunity audit reporting savings.ms: 450 does not raise your score if it does not move one of those five metrics. Following scorePlan.pointsAtRisk keeps your agent focused on changes that actually move the score.

Because Lighthouse lab scores naturally vary by roughly ±5 points between runs, verify major fixes on a deployed preview URL rather than guessing from a single local build.


Further Reading


Sources

Frequently Asked Questions

What is a Lighthouse MCP server?

A Lighthouse MCP server exposes Google PageSpeed Insights (Lighthouse) audits as a Model Context Protocol tool so AI coding agents like Claude Code, Cursor, Windsurf, and VS Code Copilot can audit live URLs directly inside your editor without manual file exports.

Do I need an account token to call PageSpeed Exporter's MCP server?

Yes. Generate an account token while signed in at speedexporter.com/dashboard and pass it as Authorization: Bearer YOUR_ACCOUNT_TOKEN. Audits share your monthly plan allowance (Free 5, Starter 50, Pro 200 reports/month).

Does strategy 'both' count as one or two reports over MCP?

Passing strategy: 'both' runs both mobile and desktop Lighthouse audits in one call so device-specific failures are not missed. It is available on Starter ($9/mo) and Pro ($29/mo) and counts as two reports.

Can an MCP coding agent audit localhost?

No. Google PageSpeed Insights runs from Google's servers and private/local IP addresses are blocked by SSRF protection. Deploy a preview branch (such as a Vercel or Netlify preview URL) and pass that public HTTPS URL to analyze_url.


Further reading

Try it yourself

Run a free Lighthouse audit on any URL and export a stripped AIReport JSON under 50KB for your AI agent — no account required.

Analyze a URL for free