Skip to main content
Glama

get_performance_score

Assess website performance by generating a performance score. Input a URL and specify device type (desktop or mobile) to evaluate site efficiency and responsiveness.

Instructions

Get the performance score for a website

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceNoDevice to emulate (default: desktop)desktop
urlYesURL to audit

Implementation Reference

  • MCP tool handler function for 'get_performance_score' that invokes the core getPerformanceScore helper, structures the result, adds recommendations, and handles errors.
    async ({ url, device }) => { try { const result = await getPerformanceScore(url, device); const structuredResult = createStructuredPerformance( "Performance Score", result.url, result.device, { performanceScore: result.performanceScore, metrics: Object.fromEntries( Object.entries(result.metrics).map(([key, metric]) => [ key, { title: metric.title, value: metric.displayValue, score: metric.score, }, ]), ), fetchTime: result.fetchTime, }, [ "Focus on Core Web Vitals improvements", "Optimize largest contentful paint for better user experience", "Reduce total blocking time to improve interactivity", ], ); return { content: [ { type: "text" as const, text: JSON.stringify(structuredResult, null, 2), }, ], }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text" as const, text: JSON.stringify( { error: "Performance analysis failed", url, device: device || "desktop", message: errorMessage, }, null, 2, ), }, ], isError: true, }; }
  • Core handler that runs Lighthouse performance audit, extracts score and metrics.
    export async function getPerformanceScore(url: string, device: "desktop" | "mobile" = "desktop") { const result = await runLighthouseAudit(url, ["performance"], device); return { url: result.url, device: result.device, performanceScore: result.categories.performance?.score || 0, metrics: result.metrics, fetchTime: result.fetchTime, }; }
  • Input schema definition for the tool, validating url (HTTP/HTTPS) and device (desktop/mobile).
    export const basicAuditSchema = { url: baseSchemas.url, device: baseSchemas.device, };
  • Registers the 'get_performance_score' tool on the MCP server with name, description, schema, and handler.
    server.tool( "get_performance_score", "Get the performance score for a website", basicAuditSchema, async ({ url, device }) => { try { const result = await getPerformanceScore(url, device); const structuredResult = createStructuredPerformance( "Performance Score", result.url, result.device, { performanceScore: result.performanceScore, metrics: Object.fromEntries( Object.entries(result.metrics).map(([key, metric]) => [ key, { title: metric.title, value: metric.displayValue, score: metric.score, }, ]), ), fetchTime: result.fetchTime, }, [ "Focus on Core Web Vitals improvements", "Optimize largest contentful paint for better user experience", "Reduce total blocking time to improve interactivity", ], ); return { content: [ { type: "text" as const, text: JSON.stringify(structuredResult, null, 2), }, ], }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text" as const, text: JSON.stringify( { error: "Performance analysis failed", url, device: device || "desktop", message: errorMessage, }, null, 2, ), }, ], isError: true, }; } }, );
  • src/index.ts:26-26 (registration)
    Top-level call to registerPerformanceTools which includes the get_performance_score tool.
    registerPerformanceTools(server);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/danielsogl/lighthouse-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server