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);
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('Close') but does not describe what happens upon closure (e.g., whether resources are freed, if the session is terminated permanently, any side effects, or error conditions). For a mutation tool with zero annotation coverage, 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, clear sentence with no wasted words, making it highly concise and front-loaded. It directly communicates the tool's purpose without unnecessary elaboration, earning its place efficiently.

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 tool's complexity (a mutation operation to close a session), lack of annotations, and no output schema, the description is incomplete. It does not cover behavioral aspects like what closure entails, potential errors, or return values. For a tool that likely involves resource management, more context is needed to ensure safe and correct usage.

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 input schema has 100% description coverage, with the 'sessionId' parameter fully documented in the schema. The description does not add any meaning beyond what the schema provides (e.g., it doesn't explain where to get the sessionId or its format). With high schema coverage, the baseline score of 3 is appropriate as the schema handles the parameter documentation adequately.

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 verb ('Close') and resource ('Safari automation session'), making the purpose immediately understandable. It distinguishes this from siblings like 'safari_start_session' by indicating the opposite action, though it doesn't explicitly contrast with all alternatives. The specificity is good but lacks explicit sibling differentiation beyond the obvious.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by referencing 'session' closure, suggesting it should be used after a session is active (e.g., following 'safari_start_session'). However, it does not provide explicit guidance on when to use this tool versus alternatives (e.g., when to close vs. keep a session open) or any prerequisites. The implied context is minimal but reasonable.

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