UNPKG

web-perf-mcp

Version:

MCP Server that audits the web page for finding the bottlenecks and CPU profiling using Lighthouse and Puppeteer

141 lines (140 loc) 3.73 kB
import { Result } from "lighthouse"; export interface TestConfig { url: string; device?: 'desktop' | 'mobile'; profile?: boolean; headless?: boolean; } export interface MetricRating { value: number; rating: 'good' | 'needs-improvement' | 'poor' | 'unknown'; } export interface PerformanceMetrics { url: string; timestamp: string; coreWebVitals: { fcp: MetricRating; lcp: MetricRating; cls: MetricRating; ttfb: MetricRating; tbt: MetricRating; }; performanceScore: number; longTasks: Result["audits"]["long-tasks"]; } export interface CPUProfileAnalysis { executive_summary: { total_execution_time_ms: number; total_samples: number; sample_interval_ms: number; }; high_impact_functions: Array<{ function: string; file: string; execution_time_ms: number; cpu_percentage: string; call_count: number; location: string; originalFile?: string; originalLine?: number; originalColumn?: number; originalName?: string | null; isSourceMapped?: boolean; fullOriginalPath?: string; sourceMapUrl?: string; resolvedStackTrace?: string; }>; flamegraph_analysis?: { callStack: { deepestStacks: Array<{ depth: number; path: string[]; }>; mostFrequentPaths: Array<{ path: string[]; frequency: number; }>; criticalPath: Array<{ function: string; selfTime: number; totalTime: number; percentage: string; location: string; }>; }; hotPaths: Array<{ path: string[]; totalTime: number; percentage: string; }>; functionHierarchy: { rootFunctions: Array<{ name: string; selfTime: number; children: Array<{ name: string; selfTime: number; }>; }>; leafFunctions: Array<any>; }; visualSummary: { totalExecutionTime: number; topCPUConsumers: Array<{ name: string; percentage: string; visualWeight: number; }>; bottleneckDistribution: Array<{ severity: string; function: string; impact: string; }>; executionPattern: { pattern: string; description: string; }; }; }; } export interface CPUProfileNode { id: number; selfTime: number; totalTime: number; parent: CPUProfileNode | null; callFrame: { functionName: string; url: string; lineNumber: number; columnNumber: number; }; children?: number[]; hitCount?: number; } export interface CPUProfile { nodes: CPUProfileNode[]; samples: number[]; timeDeltas?: number[]; startTime?: number; endTime?: number; sampleInterval?: number; } export interface AggregatedFunction { nodeId: number; functionName: string; url: string; lineNumber: number; columnNumber: number; selfTime: number; totalTime: number; hitCount: number; percentage: string; originalFile?: string; originalLine?: number; originalColumn?: number; originalName?: string | null; isSourceMapped?: boolean; fullOriginalPath?: string; sourceMapUrl?: string; resolvedStackTrace?: string; }