Skip to main content
Glama
lxman

Safari MCP Server

by lxman

safari_clear_console_logs

Remove captured console logs from a Safari browser session to maintain clean debugging environments and manage log data.

Instructions

Clear captured console logs for a session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession identifier

Implementation Reference

  • Defines the tool schema for safari_clear_console_logs, specifying the input as an object requiring 'sessionId'.
    {
      name: 'safari_clear_console_logs',
      description: 'Clear captured console logs for a session',
      inputSchema: {
        type: 'object',
        properties: {
          sessionId: { type: 'string', description: 'Session identifier' }
        },
        required: ['sessionId']
      }
    },
  • MCP tool handler that delegates to SafariDriverManager.clearConsoleLogs(sessionId) and returns a success message.
    private async clearConsoleLogs(args: Record<string, any>): Promise<Array<{ type: string; text: string }>> {
      const { sessionId } = args;
      
      await this.driverManager.clearConsoleLogs(sessionId);
      
      return [
        {
          type: 'text',
          text: `Console logs cleared for session '${sessionId}'`
        }
      ];
  • Executes JavaScript in the browser context to clear the __safariMCPConsoleLogs array, which captures console.log calls.
    async clearConsoleLogs(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.__safariMCPConsoleLogs) {
            window.__safariMCPConsoleLogs = [];
          }
        `);
      } catch (error: unknown) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        throw new Error(`Failed to clear console logs: ${errorMessage}`);
      }
    }
  • Switch case in handleToolCall that routes calls to the clearConsoleLogs handler.
    case 'safari_clear_console_logs':
      return await this.clearConsoleLogs(args);

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