navigate
Go to a specified URL with an option to wait for full page load, enabling browser navigation for web automation and content retrieval.
Instructions
Navigate to a URL
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to navigate to | |
| waitForLoad | No | Wait for page to fully load |
Implementation Reference
- src/index.ts:23-26 (schema)Zod schema for the 'navigate' tool: validates url (string that must be a valid URL) and optional waitForLoad (boolean, defaults to true).
const NavigateSchema = z.object({ url: z.string().url(), waitForLoad: z.boolean().default(true) }); - src/index.ts:127-404 (registration)Tool registration inside setupToolHandlers(). The 'navigate' tool is registered in the ListToolsRequestSchema handler (lines 158-176) with name 'navigate', description 'Navigate to a URL', and inputSchema defining url (required string) and waitForLoad (optional boolean with default true).
private setupToolHandlers() { this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: 'launch_browser', description: 'Launch a new browser instance (chromium, firefox, or webkit)', inputSchema: { type: 'object', properties: { browser: { type: 'string', enum: ['chromium', 'firefox', 'webkit'], default: 'chromium', description: 'Browser engine to use' }, headless: { type: 'boolean', default: true, description: 'Run browser in headless mode' }, viewport: { type: 'object', properties: { width: { type: 'number', default: 1280 }, height: { type: 'number', default: 720 } } } } } }, { name: 'navigate', description: 'Navigate to a URL', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'URL to navigate to' }, waitForLoad: { type: 'boolean', default: true, description: 'Wait for page to fully load' } }, required: ['url'] } }, { name: 'click_element', description: 'Click on an element by CSS selector', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the element to click' }, timeout: { type: 'number', default: 5000, description: 'Timeout in milliseconds' } }, required: ['selector'] } }, { name: 'type_text', description: 'Type text into an input field', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the input element' }, text: { type: 'string', description: 'Text to type' }, delay: { type: 'number', default: 100, description: 'Delay between keystrokes in milliseconds' } }, required: ['selector', 'text'] } }, { name: 'screenshot', description: 'Take a screenshot of the current page', inputSchema: { type: 'object', properties: { fullPage: { type: 'boolean', default: false, description: 'Capture full scrollable page' }, path: { type: 'string', description: 'Path to save screenshot (optional)' } } } }, { name: 'get_element_text', description: 'Get text content of an element', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the element' }, timeout: { type: 'number', default: 5000, description: 'Timeout in milliseconds' } }, required: ['selector'] } }, { name: 'wait_for_element', description: 'Wait for an element to appear or disappear', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the element' }, timeout: { type: 'number', default: 30000, description: 'Timeout in milliseconds' }, state: { type: 'string', enum: ['attached', 'detached', 'visible', 'hidden'], default: 'visible', description: 'State to wait for' } }, required: ['selector'] } }, { name: 'evaluate_javascript', description: 'Execute JavaScript in the browser context', inputSchema: { type: 'object', properties: { script: { type: 'string', description: 'JavaScript code to execute' } }, required: ['script'] } }, { name: 'get_console_logs', description: 'Get console logs from the browser', inputSchema: { type: 'object', properties: { level: { type: 'string', enum: ['log', 'info', 'warn', 'error', 'debug'], description: 'Filter logs by level' }, clear: { type: 'boolean', default: false, description: 'Clear console logs after retrieving' } } } }, { name: 'get_page_info', description: 'Get information about the current page', inputSchema: { type: 'object', properties: {} } }, { name: 'close_browser', description: 'Close the current browser instance', inputSchema: { type: 'object', properties: {} } }, { name: 'analyze_screenshot', description: 'Take a screenshot and analyze it with AI (Gemma3) to describe what is visible on the page', inputSchema: { type: 'object', properties: { fullPage: { type: 'boolean', default: false, description: 'Capture full scrollable page' }, path: { type: 'string', description: 'Path to save screenshot (optional)' }, pretext: { type: 'string', description: 'Optional context or specific instructions for what to look for in the analysis' }, model: { type: 'string', default: 'gemma3:4b', description: 'AI model to use for analysis (default: gemma3:4b)' }, detailed: { type: 'boolean', default: false, description: 'Provide detailed structural analysis of the page' } } } }, { name: 'scroll', description: 'Scroll the page in the specified direction', inputSchema: { type: 'object', properties: { direction: { type: 'string', enum: ['up', 'down', 'left', 'right'], default: 'down', description: 'Direction to scroll' }, pixels: { type: 'number', description: 'Number of pixels to scroll (optional)' }, behavior: { type: 'string', enum: ['auto', 'smooth'], default: 'auto', description: 'Scrolling behavior' } } } }, { name: 'check_scrollability', description: 'Check if the page is scrollable in the specified direction', inputSchema: { type: 'object', properties: { direction: { type: 'string', enum: ['vertical', 'horizontal', 'both'], default: 'both', description: 'Direction to check for scrollability' } } } } ], }; }); - src/index.ts:458-481 (handler)The actual handler for the 'navigate' tool inside the CallToolRequestSchema handler. It parses args using NavigateSchema, navigates currentPage to the URL (with optional waitUntil:'networkidle' if waitForLoad is true), gets the page title, and returns a text response with the navigation result and page title.
case 'navigate': { if (!currentPage) { throw new Error('No browser page available. Launch a browser first.'); } const params = NavigateSchema.parse(args); if (params.waitForLoad) { await currentPage.goto(params.url, { waitUntil: 'networkidle' }); } else { await currentPage.goto(params.url); } const title = await currentPage.title(); return { content: [ { type: 'text', text: `Navigated to ${params.url}\nPage title: ${title}` } ] }; }