navigate_to_url
Navigate to a specified URL while preserving browser session data like cookies and authentication state. Use this tool to move between different website sections or pages during web application analysis and automation.
Instructions
Navigate to a different URL within the same browser session. Maintains all cookies, authentication state, and session data. Useful for moving between different sections of a website (e.g., from login page to chat page, or from homepage to a specific conversation URL). Supports different wait strategies for page load completion.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Session ID obtained from initialize_session | |
| url | Yes | Complete URL to navigate to (e.g., 'https://chat.example.com/conversation/new') | |
| waitUntil | No | Page load strategy: 'load' (wait for load event), 'domcontentloaded' (wait for DOM ready), 'networkidle' (wait for network to be idle). Use 'networkidle' for SPAs (default: 'load') | load |
Implementation Reference
- src/tools/navigation.js:10-28 (handler)The core handler function that executes the navigation logic using Puppeteer's page.goto method, handles errors, updates the session's current URL, and returns success details including current URL and page title.export async function navigateToUrl(sessionId, url, waitUntil = "load") { const session = getSession(sessionId); const { page } = session; try { await page.goto(url, { waitUntil, timeout: 30000 }); session.currentUrl = url; return { success: true, sessionId, currentUrl: page.url(), title: await page.title(), message: "Navigation successful", }; } catch (error) { throw new Error(`Failed to navigate: ${error.message}`); } }
- src/index.js:221-246 (schema)The tool schema definition in the ListTools response, including name, description, and detailed inputSchema with parameter types, descriptions, defaults, and required fields.{ name: "navigate_to_url", description: "Navigate to a different URL within the same browser session. Maintains all cookies, authentication state, and session data. Useful for moving between different sections of a website (e.g., from login page to chat page, or from homepage to a specific conversation URL). Supports different wait strategies for page load completion.", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "Session ID obtained from initialize_session", }, url: { type: "string", description: "Complete URL to navigate to (e.g., 'https://chat.example.com/conversation/new')", }, waitUntil: { type: "string", description: "Page load strategy: 'load' (wait for load event), 'domcontentloaded' (wait for DOM ready), 'networkidle' (wait for network to be idle). Use 'networkidle' for SPAs (default: 'load')", default: "load", }, }, required: ["sessionId", "url"], }, },
- src/index.js:495-510 (registration)Registration and dispatching logic in the CallToolRequestSchema handler's switch statement, including parameter validation and call to the navigateToUrl handler.case "navigate_to_url": { const { sessionId, url, waitUntil = "load" } = args; if (!sessionId) { throw new McpError( ErrorCode.InvalidParams, "sessionId parameter is required" ); } if (!url) { throw new McpError( ErrorCode.InvalidParams, "url parameter is required" ); } result = await navigateToUrl(sessionId, url, waitUntil); break;
- src/tools/reverseEngineer.js:19-19 (registration)Re-export of the navigateToUrl function from its implementation module (navigation.js) to the central tools export file, enabling easy import in index.js.export { navigateToUrl, switchTab } from "./navigation.js";
- src/index.js:12-26 (registration)Import of the navigateToUrl function (via re-export) into the main index.js file where tool handlers are set up.reverseEngineerChat, takeScreenshot, clickElement, fillForm, switchTab, waitForElement, navigateToUrl, getCurrentPageInfo, initializeSession, closeSession, startNetworkCapture, stopNetworkCapture, getNetworkCaptureStatus, clearNetworkCapture, } from "./tools/reverseEngineer.js";