Skip to main content
Glama

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);

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