Skip to main content
Glama
lxman

Safari MCP Server

by lxman

safari_get_page_info

Retrieve the current URL and page title from Safari browser sessions to enable web automation and monitoring tasks.

Instructions

Get current page URL and title

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession identifier

Implementation Reference

  • The primary handler function for the 'safari_get_page_info' tool. It extracts the sessionId from arguments, fetches the current URL and page title using the SafariDriverManager, and returns formatted text content with the page information.
    private async getPageInfo(args: Record<string, any>): Promise<Array<{ type: string; text: string }>> {
      const { sessionId } = args;
      
      const [url, title] = await Promise.all([
        this.driverManager.getCurrentUrl(sessionId),
        this.driverManager.getPageTitle(sessionId)
      ]);
      
      return [
        {
          type: 'text',
          text: `Page Info:\nURL: ${url}\nTitle: ${title}`
        }
      ];
    }
  • Supporting helper method in SafariDriverManager that retrieves the current URL of the Safari session using Selenium WebDriver's getCurrentUrl().
    async getCurrentUrl(sessionId: string): Promise<string> {
      const session = this.getSession(sessionId);
      if (!session) {
        throw new Error(`Session ${sessionId} not found`);
      }
    
      try {
        return await session.driver.getCurrentUrl();
      } catch (error: unknown) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        throw new Error(`Failed to get current URL: ${errorMessage}`);
      }
    }
  • Supporting helper method in SafariDriverManager that retrieves the title of the current page in the Safari session using Selenium WebDriver's getTitle().
    async getPageTitle(sessionId: string): Promise<string> {
      const session = this.getSession(sessionId);
      if (!session) {
        throw new Error(`Session ${sessionId} not found`);
      }
    
      try {
        return await session.driver.getTitle();
      } catch (error: unknown) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        throw new Error(`Failed to get page title: ${errorMessage}`);
      }
    }
  • Tool schema definition in the listTools response, specifying the name, description, and input schema requiring a sessionId.
    {
      name: 'safari_get_page_info',
      description: 'Get current page URL and title',
      inputSchema: {
        type: 'object',
        properties: {
          sessionId: { type: 'string', description: 'Session identifier' }
        },
        required: ['sessionId']
      }
    },
  • Registration of the tool handler in the switch statement within handleToolCall method, dispatching calls to the getPageInfo handler.
    case 'safari_get_page_info':
      return await this.getPageInfo(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 states what the tool does but lacks critical details: it doesn't specify if this is a read-only operation, what permissions are required, how it handles errors (e.g., invalid sessionId), or the format of returned data (e.g., JSON structure). This leaves significant gaps for safe and effective use.

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 extremely concise and front-loaded, consisting of a single, clear sentence that directly states the tool's function. There is no wasted language or unnecessary elaboration, making it efficient for quick comprehension.

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 browser automation tools and the lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., a JSON object with URL and title fields), error conditions, or dependencies on other tools like 'safari_start_session'. This leaves the agent with insufficient context for reliable use.

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 schema description coverage is 100%, with the single parameter 'sessionId' fully documented in the schema. The description adds no additional parameter information beyond what the schema provides, such as context on where to obtain the sessionId or its format. This meets the baseline for high schema coverage but doesn't enhance understanding.

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 tool's purpose with specific verbs ('Get') and resources ('current page URL and title'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'safari_get_console_logs' or 'safari_get_network_logs', which also retrieve information but for different resources.

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. It doesn't mention prerequisites (e.g., needing an active session), exclusions, or comparisons to siblings like 'safari_inspect_element' or 'safari_get_performance_metrics', leaving the agent to infer usage from context alone.

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