navigate
Load a specified URL in the current browser tab, resetting page state, and wait for the page to fully load. Use to navigate directly to known URLs instead of clicking interactive elements.
Instructions
Loads a URL in the current tab and waits for the page load event. Resets page state — DOM, JS runtime, timers, and frame context are destroyed. Use instead of clicking links when the target URL is known.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The URL to navigate to |
Implementation Reference
- src/tools/navigate.tool.ts:16-29 (handler)The navigateAction function is the core handler for the 'navigate' tool. It gets the browser instance via getBrowser() and calls browser.url(url) to navigate, returning a success or error result.
export const navigateAction = async (url: string): Promise<CallToolResult> => { try { const browser = getBrowser(); await browser.url(url); return { content: [{ type: 'text', text: `Navigated to ${url}` }], }; } catch (e) { return { isError: true, content: [{ type: 'text', text: `Error navigating: ${e}` }], }; } }; - src/tools/navigate.tool.ts:7-14 (schema)The navigateToolDefinition defines the tool's name ('navigate'), description, annotations, and input schema (a required 'url' string parameter validated with zod).
export const navigateToolDefinition: ToolDefinition = { name: 'navigate', description: 'Loads a URL in the current tab and waits for the page load event. Resets page state — DOM, JS runtime, timers, and frame context are destroyed. Use instead of clicking links when the target URL is known.', annotations: { title: 'Navigate to URL', destructiveHint: false, idempotentHint: true }, inputSchema: { url: z.string().min(1).describe('The URL to navigate to'), }, }; - src/server.ts:12-12 (registration)Import of navigateTool and navigateToolDefinition from the navigate tool module.
import { navigateTool, navigateToolDefinition } from './tools/navigate.tool'; - src/server.ts:127-127 (registration)Registration of the 'navigate' tool on the MCP server using registerTool with recording wrapper.
registerTool(navigateToolDefinition, withRecording('navigate', navigateTool)); - src/tools/navigate.tool.ts:31-31 (handler)The navigateTool callback that wraps navigateAction, extracting the url from the input parameters.
export const navigateTool: ToolCallback = async ({ url }: { url: string }) => navigateAction(url);