Skip to main content
Glama

safari_get_page_info

Retrieve the current page URL and title from Safari browser sessions using session identifiers for browser automation and debugging tasks.

Instructions

Get current page URL and title

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession identifier

Implementation Reference

  • The primary handler function that executes the logic for the 'safari_get_page_info' MCP tool. It retrieves the current page URL and title for the specified session.
    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}` } ]; }
  • Registration of the 'safari_get_page_info' tool in the ListTools response, defining its metadata and input schema.
    { name: 'safari_get_page_info', description: 'Get current page URL and title', inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'Session identifier' } }, required: ['sessionId'] } },
  • JSON schema defining the input parameters for the 'safari_get_page_info' tool.
    inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'Session identifier' } }, required: ['sessionId'] }
  • Supporting helper method in SafariDriverManager to retrieve the current URL 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 to retrieve the page title 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}`); } }

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