Skip to main content
Glama
lxman

Safari MCP Server

by lxman

safari_start_session

Start a Safari automation session with developer tools access to control the browser, debug web applications, and monitor network activity.

Instructions

Start a new Safari automation session with dev tools access

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesUnique session identifier
optionsNo

Implementation Reference

  • Core implementation of starting a Safari session using Selenium WebDriver. Configures SafariOptions for devtools inspection, profiling, technology preview, sets up logging preferences, builds the driver, and stores the session.
    async createSession(sessionId: string, options: SafariSessionOptions = {}): Promise<SafariSession> {
      if (this.sessions.has(sessionId)) {
        throw new Error(`Session ${sessionId} already exists`);
      }
    
      try {
        // Configure Safari options
        const safariOptions = new safari.Options();
        
        // Enable dev tools features
        if (options.enableInspection) {
          // Note: automaticInspection may not be available in all Safari versions
          try {
            (safariOptions as any).setAutomaticInspection(true);
          } catch (e) {
            console.warn('Automatic inspection not supported in this Safari version');
          }
        }
        
        if (options.enableProfiling) {
          // Note: automaticProfiling may not be available in all Safari versions
          try {
            (safariOptions as any).setAutomaticProfiling(true);
          } catch (e) {
            console.warn('Automatic profiling not supported in this Safari version');
          }
        }
    
        if (options.usesTechnologyPreview) {
          safariOptions.setTechnologyPreview(true);
        }
    
        // Enable logging for console and performance
        const loggingPrefs = new logging.Preferences();
        loggingPrefs.setLevel(logging.Type.BROWSER, logging.Level.ALL);
        loggingPrefs.setLevel(logging.Type.PERFORMANCE, logging.Level.ALL);
        
        const driver = await new Builder()
          .forBrowser('safari')
          .setSafariOptions(safariOptions)
          .setLoggingPrefs(loggingPrefs)
          .build();
    
        const session: SafariSession = {
          driver,
          sessionId,
          options,
          createdAt: new Date()
        };
    
        this.sessions.set(sessionId, session);
        return session;
      } catch (error: unknown) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        throw new Error(`Failed to create Safari session: ${errorMessage}`);
      }
    }
  • MCP server handler wrapper for 'safari_start_session' tool call. Extracts arguments and delegates to SafariDriverManager.createSession, returns success message.
    private async startSession(args: Record<string, any>): Promise<Array<{ type: string; text: string }>> {
      const { sessionId, options = {} } = args;
      
      await this.driverManager.createSession(sessionId, options);
      
      return [
        {
          type: 'text',
          text: `Safari session '${sessionId}' started successfully with dev tools enabled.\nInspection: ${options.enableInspection !== false}\nProfiling: ${options.enableProfiling !== false}\nTechnology Preview: ${options.usesTechnologyPreview === true}`
        }
      ];
    }
  • Registration of the 'safari_start_session' tool in the MCP ListTools response, including name, description, and input schema.
      name: 'safari_start_session',
      description: 'Start a new Safari automation session with dev tools access',
      inputSchema: {
        type: 'object',
        properties: {
          sessionId: { 
            type: 'string', 
            description: 'Unique session identifier' 
          },
          options: {
            type: 'object',
            properties: {
              enableInspection: { 
                type: 'boolean', 
                description: 'Enable Web Inspector for debugging'
              },
              enableProfiling: { 
                type: 'boolean', 
                description: 'Enable timeline profiling'
              },
              usesTechnologyPreview: {
                type: 'boolean',
                description: 'Use Safari Technology Preview'
              }
            }
          }
        },
        required: ['sessionId']
      }
    },
  • TypeScript interface defining the options schema for Safari session creation, matching the tool inputSchema.
    export interface SafariSessionOptions {
      enableInspection?: boolean;
      enableProfiling?: boolean;
      usesTechnologyPreview?: boolean;
    }
  • Tool dispatcher switch case that routes 'safari_start_session' calls to the startSession handler.
    case 'safari_start_session':
      return await this.startSession(args);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'dev tools access' but doesn't cover critical aspects like whether this is a read-only or mutating operation, authentication requirements, potential side effects (e.g., opening a browser instance), rate limits, or error handling. For a tool that likely initiates a session, this is a significant gap in transparency.

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 is a single, efficient sentence that front-loads the core action ('Start a new Safari automation session') and adds a key feature ('with dev tools access') without unnecessary details. Every word earns its place, making it highly concise and well-structured.

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 starting an automation session, no annotations, no output schema, and moderate schema coverage, the description is incomplete. It lacks details on behavioral traits, parameter usage, expected outputs, or how it integrates with sibling tools, leaving significant gaps for an AI agent to understand and invoke it correctly.

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 description does not mention any parameters, while the input schema has 2 parameters with 50% coverage (only 'sessionId' is described). Since schema coverage is moderate, the baseline is 3, as the description adds no value beyond the schema—it doesn't explain what 'sessionId' is used for or the purpose of 'options' like enabling inspection or profiling.

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

Purpose4/5

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

The description clearly states the action ('Start a new Safari automation session') and the resource ('Safari'), with the specific feature of 'dev tools access' distinguishing it from generic session tools. However, it doesn't explicitly differentiate from sibling tools like 'safari_list_sessions' or 'safari_close_session' in terms of purpose, keeping it from a perfect score.

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, such as whether it's for initial setup before other operations like 'safari_execute_script' or 'safari_navigate', or how it relates to sibling tools like 'safari_list_sessions'. It lacks explicit when/when-not instructions or named alternatives.

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