Skip to main content
Glama
lxman

Safari MCP Server

by lxman

safari_clear_network_logs

Clear captured network logs for a specific Safari browser session to manage monitoring data and maintain privacy.

Instructions

Clear captured network logs for a session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession identifier

Implementation Reference

  • Registers the 'safari_clear_network_logs' tool in the MCP tools list, including its name, description, and input schema requiring 'sessionId'.
    {
      name: 'safari_clear_network_logs',
      description: 'Clear captured network logs for a session',
      inputSchema: {
        type: 'object',
        properties: {
          sessionId: { type: 'string', description: 'Session identifier' }
        },
        required: ['sessionId']
      }
    },
  • Switch case in handleToolCall that dispatches 'safari_clear_network_logs' calls to the clearNetworkLogs method.
    case 'safari_clear_network_logs':
      return await this.clearNetworkLogs(args);
  • MCP server handler method that extracts sessionId from args, calls driverManager.clearNetworkLogs(sessionId), and returns success message.
    private async clearNetworkLogs(args: Record<string, any>): Promise<Array<{ type: string; text: string }>> {
      const { sessionId } = args;
      
      await this.driverManager.clearNetworkLogs(sessionId);
      
      return [
        {
          type: 'text',
          text: `Network logs cleared for session '${sessionId}'`
        }
      ];
    }
  • Core implementation in SafariDriverManager that executes JavaScript in the browser session to reset the __safariMCPNetworkLogs array, effectively clearing captured network logs.
    async clearNetworkLogs(sessionId: string): Promise<void> {
      const session = this.getSession(sessionId);
      if (!session) {
        throw new Error(`Session ${sessionId} not found`);
      }
    
      try {
        await session.driver.executeScript(`
          if (window.__safariMCPNetworkLogs) {
            window.__safariMCPNetworkLogs = [];
          }
        `);
      } catch (error: unknown) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        throw new Error(`Failed to clear network logs: ${errorMessage}`);
      }
    }
  • Input schema definition for the tool, specifying an object with required 'sessionId' string property.
    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