browser_navigate
Direct a browser instance to a target URL with configurable wait conditions and timeout settings for precise navigation control in concurrent browsing tasks.
Instructions
Navigate to a specified URL
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instanceId | Yes | Instance ID | |
| timeout | No | Timeout in milliseconds | |
| url | Yes | Target URL | |
| waitUntil | No | Wait condition | load |
Implementation Reference
- src/tools.ts:600-626 (handler)Core implementation of browser_navigate tool: retrieves browser instance, navigates to URL using Playwright page.goto, handles errors, returns navigation result.private async navigate(instanceId: string, url: string, options: NavigationOptions): Promise<ToolResult> { const instance = this.browserManager.getInstance(instanceId); if (!instance) { return { success: false, error: `Instance ${instanceId} not found` }; } try { const gotoOptions: any = { waitUntil: options.waitUntil }; if (options.timeout) { gotoOptions.timeout = options.timeout; } await instance.page.goto(url, gotoOptions); return { success: true, data: { url: instance.page.url(), title: await instance.page.title() }, instanceId }; } catch (error) { return { success: false, error: `Navigation failed: ${error instanceof Error ? error.message : error}`, instanceId }; } }
- src/tools.ts:93-121 (schema)Tool definition including name, description, and input schema for browser_navigate, provided by getTools() for MCP listTools requests.{ name: 'browser_navigate', description: 'Navigate to a specified URL', inputSchema: { type: 'object', properties: { instanceId: { type: 'string', description: 'Instance ID' }, url: { type: 'string', description: 'Target URL', }, timeout: { type: 'number', description: 'Timeout in milliseconds', default: 30000 }, waitUntil: { type: 'string', enum: ['load', 'domcontentloaded', 'networkidle'], description: 'Wait condition', default: 'load' } }, required: ['instanceId', 'url'] } },
- src/tools.ts:518-522 (registration)Registration/dispatch of browser_navigate in the executeTools switch statement, calling the navigate handler with parsed arguments.case 'browser_navigate': return await this.navigate(args.instanceId, args.url, { timeout: args.timeout || 30000, waitUntil: args.waitUntil || 'load' });
- src/server.ts:40-45 (registration)MCP server handler for listing tools, which returns the array including browser_navigate from BrowserTools.getTools().this.server.setRequestHandler(ListToolsRequestSchema, async () => { const tools = this.browserTools.getTools(); return { tools: tools, }; });
- src/server.ts:47-75 (registration)MCP server handler for calling tools, which dispatches to BrowserTools.executeTools based on tool name, enabling browser_navigate execution.// Handle tool call requests this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { const result = await this.browserTools.executeTools(name, args || {}); if (result.success) { return { content: [ { type: 'text', text: JSON.stringify(result.data, null, 2), }, ], }; } else { throw new McpError(ErrorCode.InternalError, result.error || 'Tool execution failed'); } } catch (error) { if (error instanceof McpError) { throw error; } throw new McpError( ErrorCode.InternalError, `Tool execution failed: ${error instanceof Error ? error.message : error}` ); } });