Skip to main content
Glama

safari_get_performance_metrics

Retrieve page performance metrics from Safari to analyze loading times, resource usage, and browser performance data for optimization.

Instructions

Get page performance metrics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession identifier

Implementation Reference

  • Core handler implementation in SafariDriverManager that executes JavaScript to fetch browser performance metrics using the Performance Timing API and paint entries.
    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}`); } }
  • MCP server handler method that extracts the sessionId from arguments, calls the driver manager, and formats the metrics as a text response.
    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)}` } ]; }
  • Tool registration entry in the MCP server's tool list, including the 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'] } },
  • Input schema definition for the tool, specifying the required sessionId parameter.
    { name: 'safari_get_performance_metrics', description: 'Get page performance metrics', inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'Session identifier' } }, required: ['sessionId'] } },

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