lighthouse_audit
Run comprehensive Lighthouse audits to measure website performance, accessibility, best practices, and SEO scores. Get detailed findings on render-blocking resources, image optimization, and unused code for actionable improvements.
Instructions
Run a full Lighthouse audit against a URL. Returns scores for Performance, Accessibility, Best Practices, and SEO (0-100), plus detailed audit findings for render-blocking resources, image optimization, unused code, and more. Heavier than performance_audit but provides industry-standard Lighthouse scores.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL of the page to audit (e.g., http://localhost:3000) |
Implementation Reference
- src/server.ts:558-586 (handler)The MCP tool registration and handler for 'lighthouse_audit'.
server.tool( "lighthouse_audit", "Run a full Lighthouse audit against a URL. Returns scores for Performance, Accessibility, Best Practices, and SEO (0-100), plus detailed audit findings for render-blocking resources, image optimization, unused code, and more. Heavier than performance_audit but provides industry-standard Lighthouse scores.", { url: z.string().url().describe("URL of the page to audit (e.g., http://localhost:3000)"), }, async ({ url }) => { try { const result = await runLighthouse(url); const report = formatLighthouseReport(result); return { content: [ { type: "text" as const, text: report }, { type: "text" as const, text: `\n\n<raw_data>\n${JSON.stringify(result, null, 2)}\n</raw_data>`, }, ], }; } catch (error) { const message = error instanceof Error ? error.message : String(error); return { content: [{ type: "text" as const, text: `Lighthouse audit failed: ${message}` }], isError: true, }; } } ); - src/tools/lighthouse.ts:224-227 (handler)The primary logic implementation for running the Lighthouse audit.
export async function runLighthouse( url: string, options?: { readonly chromePath?: string } ): Promise<LighthouseResult> { - src/tools/lighthouse.ts:24-31 (schema)Type definition for the Lighthouse audit results.
export interface LighthouseResult { readonly scores: LighthouseScores; readonly audits: readonly LighthouseAudit[]; readonly url: string; readonly timestamp: string; readonly lighthouseVersion: string; readonly runWarnings: readonly string[]; }