Skip to main content
Glama
lxman

Safari MCP Server

by lxman

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']
      }
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Get page performance metrics' implies a read-only operation, but it doesn't specify whether this requires an active session, what the output format might be, or if there are any rate limits or permissions needed. The description lacks details on what 'performance metrics' encompass, leaving behavioral traits unclear.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description 'Get page performance metrics' is a single, clear sentence that efficiently conveys the core action without unnecessary words. It's front-loaded with the key information, making it easy to parse quickly. There's no wasted text, and it directly addresses the tool's function in a minimal format.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of performance metrics and the lack of annotations and output schema, the description is incomplete. It doesn't explain what types of metrics are returned (e.g., numeric values, timestamps, categories) or any dependencies, such as needing an active session. For a tool that likely outputs structured data, more context is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with 'sessionId' documented as 'Session identifier'. The description doesn't add any parameter-specific information beyond what the schema provides, such as explaining how the sessionId relates to performance metrics or providing examples. Since schema coverage is high, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get page performance metrics' states the verb ('Get') and resource ('page performance metrics'), making the purpose clear at a basic level. However, it doesn't distinguish this tool from potential alternatives or specify what types of performance metrics are included (e.g., load times, resource timing, memory usage), leaving it somewhat vague compared to more specific descriptions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. Given sibling tools like 'safari_get_page_info' and 'safari_get_console_logs', there's no indication of whether this tool is for real-time metrics, historical data, or specific performance aspects. Without any context on prerequisites or exclusions, users must infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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