navigate
Perform browser navigation by directing to a specified URL, optionally waiting for the page to fully load. Enables automated web interactions via the MCP Browser Server.
Instructions
Navigate to a URL
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to navigate to | |
| waitForLoad | No | Wait for page to fully load |
Implementation Reference
- src/index.ts:458-481 (handler)The main handler function for the 'navigate' tool. It validates input with NavigateSchema, navigates the current page to the specified URL using Playwright's goto method (with optional networkidle wait), retrieves the page title, and returns a success message.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}` } ] }; }
- src/index.ts:23-26 (schema)Zod schema defining the input parameters for the navigate tool: required URL (validated as string URL) and optional waitForLoad boolean.const NavigateSchema = z.object({ url: z.string().url(), waitForLoad: z.boolean().default(true) });
- src/index.ts:158-176 (registration)Registration of the 'navigate' tool in the ListTools response, including name, description, and input schema for MCP protocol compliance.{ 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'] } },