Skip to main content
Glama

safari_start_session

Initiate a Safari automation session with access to Web Inspector, timeline profiling, and optional Safari Technology Preview for debugging and browser automation tasks.

Instructions

Start a new Safari automation session with dev tools access

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
optionsNo
sessionIdYesUnique session identifier

Implementation Reference

  • Tool registration including name, description, and input schema in the listTools response
    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'] } },
  • MCP server handler for safari_start_session tool call, which delegates to driverManager.createSession and formats response
    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}` } ]; }
  • Core implementation that creates Safari WebDriver session using selenium-webdriver with devtools options and logging
    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}`); } }
  • TypeScript interface defining the options for Safari session creation, matching the tool input schema
    export interface SafariSessionOptions { enableInspection?: boolean; enableProfiling?: boolean; usesTechnologyPreview?: boolean; }
  • Dispatch case in handleToolCall switch statement that routes to the startSession handler
    case 'safari_start_session': return await this.startSession(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