browser_navigate
Navigate a browser to a specified URL for accessibility testing, returning page title and status code upon completion.
Instructions
Navigate the connected browser to a URL. Returns the page title and HTTP status code when complete.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to navigate to | |
| waitUntil | No | When to consider navigation complete. Default: load | load |
| timeout | No | Navigation timeout in milliseconds. Default: 30000 |
Implementation Reference
- src/tools/browserNavigate.ts:21-49 (handler)The main handler function that executes the browser navigation logic. It connects to the browser, navigates to the specified URL, waits for the page to load, and returns success information including the page title, final URL, and HTTP status.export async function browserNavigateHandler(args: { url: string; waitUntil?: 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2'; timeout?: number; }): Promise<ReturnType<typeof toolSuccess | typeof toolError>> { try { const { page } = browserManager.requireConnection(); const response = await page.goto(args.url, { waitUntil: args.waitUntil ?? 'load', timeout: args.timeout ?? 30000, }); const title = await page.title().catch(() => ''); const finalUrl = page.url(); const status = response?.status() ?? null; return toolSuccess({ navigated: true, url: args.url, finalUrl, title, status, message: `Navigated to "${title || finalUrl}" (HTTP ${status})`, }); } catch (error) { return toolError(error); } }
- src/tools/browserNavigate.ts:5-19 (schema)Zod schema defining the input parameters for the browser_navigate tool, including url (required), waitUntil (optional, enum), and timeout (optional, number) with default values and descriptions.export const browserNavigateSchema = { url: z.string().url().describe('URL to navigate to'), waitUntil: z .enum(['load', 'domcontentloaded', 'networkidle0', 'networkidle2']) .optional() .default('load') .describe('When to consider navigation complete. Default: load'), timeout: z .number() .int() .positive() .optional() .default(30000) .describe('Navigation timeout in milliseconds. Default: 30000'), };
- src/index.ts:34-45 (registration)Tool registration in the MCP server, registering 'browser_navigate' with its title, description, input schema, and handler function.// ── browser_navigate ───────────────────────────────────────────────────────── server.registerTool( 'browser_navigate', { title: 'Navigate to URL', description: 'Navigate the connected browser to a URL. ' + 'Returns the page title and HTTP status code when complete.', inputSchema: browserNavigateSchema, }, browserNavigateHandler );