Skip to main content
Glama
lxman

Safari MCP Server

by lxman

safari_close_session

Close an active Safari browser automation session to free system resources and end browser control tasks.

Instructions

Close a Safari automation session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession identifier

Implementation Reference

  • Main tool handler that delegates to driverManager.closeSession and returns success response.
    private async closeSession(args: Record<string, any>): Promise<Array<{ type: string; text: string }>> {
      const { sessionId } = args;
      
      await this.driverManager.closeSession(sessionId);
      
      return [
        {
          type: 'text',
          text: `Safari session '${sessionId}' closed successfully`
        }
      ];
    }
  • Core helper function that quits the Selenium driver for the session and removes it from the manager's session map.
    async closeSession(sessionId: string): Promise<void> {
      const session = this.sessions.get(sessionId);
      if (!session) {
        throw new Error(`Session ${sessionId} not found`);
      }
    
      try {
        await session.driver.quit();
        this.sessions.delete(sessionId);
      } catch (error: unknown) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        throw new Error(`Failed to close session: ${errorMessage}`);
      }
    }
  • JSON schema defining the tool's input parameters (requires sessionId).
    {
      name: 'safari_close_session',
      description: 'Close a Safari automation session',
      inputSchema: {
        type: 'object',
        properties: {
          sessionId: { type: 'string', description: 'Session identifier' }
        },
        required: ['sessionId']
      }
    }
  • Switch case registration in handleToolCall that routes the tool call to the closeSession handler.
    case 'safari_close_session':
      return await this.closeSession(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