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
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session identifier |
Implementation Reference
- src/safari-mcp-server.ts:387-401 (handler)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}` } ]; }
- src/safari-mcp-server.ts:187-197 (registration)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'] } },
- src/safari-mcp-server.ts:190-196 (schema)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'] }
- src/safari-driver.ts:378-390 (helper)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}`); } }
- src/safari-driver.ts:392-404 (helper)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}`); } }