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
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"sessionId": "<sessionId>"
},
"name": "safari_get_page_info"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session identifier |
Implementation Reference
- src/safari-mcp-server.ts:387-401 (handler)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}` } ]; } - src/safari-driver.ts:378-390 (helper)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}`); } } - src/safari-driver.ts:392-404 (helper)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}`); } } - src/safari-mcp-server.ts:187-197 (schema)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'] } }, - src/safari-mcp-server.ts:255-256 (registration)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);