Skip to main content
Glama

safari_get_performance_metrics

Retrieve page performance metrics from Safari sessions using sessionId, enabling analysis of browser behavior and page efficiency for automation and debugging tasks.

Instructions

Get page performance metrics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession identifier

Implementation Reference

  • Core handler that retrieves performance metrics by executing JavaScript using the browser's Performance API to access navigation timing and paint events.
    async getPerformanceMetrics(sessionId: string): Promise<PerformanceMetrics> { const session = this.getSession(sessionId); if (!session) { throw new Error(`Session ${sessionId} not found`); } try { const metrics = await session.driver.executeScript(` const timing = performance.timing; const paintEntries = performance.getEntriesByType('paint'); return { navigationStart: timing.navigationStart, loadEventEnd: timing.loadEventEnd, domContentLoadedEventEnd: timing.domContentLoadedEventEnd, firstPaint: paintEntries.find(entry => entry.name === 'first-paint')?.startTime, firstContentfulPaint: paintEntries.find(entry => entry.name === 'first-contentful-paint')?.startTime }; `); return metrics; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); throw new Error(`Failed to get performance metrics: ${errorMessage}`); } }
  • Tool registration entry including name, description, and input schema definition.
    { name: 'safari_get_performance_metrics', description: 'Get page performance metrics', inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'Session identifier' } }, required: ['sessionId'] } },
  • MCP server wrapper handler that calls the driver manager and formats the response as MCP content.
    private async getPerformanceMetrics(args: Record<string, any>): Promise<Array<{ type: string; text: string }>> { const { sessionId } = args; const metrics = await this.driverManager.getPerformanceMetrics(sessionId); return [ { type: 'text', text: `Performance Metrics:\n\n${JSON.stringify(metrics, null, 2)}` } ]; }
  • Dispatch registration in the tool call switch statement routing to the specific handler.
    case 'safari_get_performance_metrics': return await this.getPerformanceMetrics(args);
  • TypeScript interface defining the structure of performance metrics returned by the tool.
    export interface PerformanceMetrics { navigationStart?: number; loadEventEnd?: number; domContentLoadedEventEnd?: number; firstPaint?: number; firstContentfulPaint?: number; }

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/lxman/safari-mcp-server'

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