safari_close_session
Terminate a specific Safari browser automation session using its session identifier, ensuring clean closure and resource management for efficient browser automation workflows.
Instructions
Close a Safari automation session
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session identifier |
Implementation Reference
- src/safari-mcp-server.ts:414-425 (handler)The primary handler for the 'safari_close_session' tool. Extracts sessionId from input arguments, delegates to SafariDriverManager.closeSession(), and returns a textual 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` } ]; }
- src/safari-mcp-server.ts:206-216 (registration)Registration of the 'safari_close_session' tool in the ListTools response, including name, description, and input schema definition.{ name: 'safari_close_session', description: 'Close a Safari automation session', inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'Session identifier' } }, required: ['sessionId'] } }
- src/safari-mcp-server.ts:261-262 (handler)Dispatch case in the main handleToolCall switch statement that routes 'safari_close_session' calls to the closeSession handler.case 'safari_close_session': return await this.closeSession(args);
- src/safari-driver.ts:78-91 (helper)Helper method in SafariDriverManager that performs the actual session closure by quitting the Selenium WebDriver instance and removing the session from the internal 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}`); } }