playwright_navigate
Launch a browser instance, navigate to a specified URL, and control viewport size, browser type, navigation timeout, and headless mode for web automation tasks.
Instructions
Navigate to a URL
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| browserType | No | Browser type to use (chromium, firefox, webkit). Defaults to chromium | |
| headless | No | Run browser in headless mode (default: false) | |
| height | No | Viewport height in pixels (default: 720) | |
| timeout | No | Navigation timeout in milliseconds | |
| url | Yes | URL to navigate to the website specified | |
| waitUntil | No | Navigation wait condition | |
| width | No | Viewport width in pixels (default: 1280) |
Implementation Reference
- src/tools/browser/navigation.ts:8-57 (handler)NavigationTool class with execute method implementing the playwright_navigate tool logic using Playwright's page.gotoexport class NavigationTool extends BrowserToolBase { /** * Execute the navigation tool */ async execute(args: any, context: ToolContext): Promise<ToolResponse> { // Check if browser is available if (!context.browser || !context.browser.isConnected()) { // If browser is not connected, we need to reset the state to force recreation resetBrowserState(); return createErrorResponse( "Browser is not connected. The connection has been reset - please retry your navigation." ); } // Check if page is available and not closed if (!context.page || context.page.isClosed()) { return createErrorResponse( "Page is not available or has been closed. Please retry your navigation." ); } return this.safeExecute(context, async (page) => { try { await page.goto(args.url, { timeout: args.timeout || 30000, waitUntil: args.waitUntil || "load" }); return createSuccessResponse(`Navigated to ${args.url}`); } catch (error) { const errorMessage = (error as Error).message; // Check for common disconnection errors if ( errorMessage.includes("Target page, context or browser has been closed") || errorMessage.includes("Target closed") || errorMessage.includes("Browser has been disconnected") ) { // Reset browser state to force recreation on next attempt resetBrowserState(); return createErrorResponse( `Browser connection issue: ${errorMessage}. Connection has been reset - please retry your navigation.` ); } // For other errors, return the standard error throw error; } }); }
- src/tools.ts:78-93 (schema)Input schema definition for the playwright_navigate tool, including parameters like url, browserType, dimensions, etc.{ name: "playwright_navigate", description: "Navigate to a URL", inputSchema: { type: "object", properties: { url: { type: "string", description: "URL to navigate to the website specified" }, browserType: { type: "string", description: "Browser type to use (chromium, firefox, webkit). Defaults to chromium", enum: ["chromium", "firefox", "webkit"] }, width: { type: "number", description: "Viewport width in pixels (default: 1280)" }, height: { type: "number", description: "Viewport height in pixels (default: 720)" }, timeout: { type: "number", description: "Navigation timeout in milliseconds" }, waitUntil: { type: "string", description: "Navigation wait condition" }, headless: { type: "boolean", description: "Run browser in headless mode (default: false)" } }, required: ["url"], },
- src/toolHandler.ts:472-473 (registration)Registration and dispatch of playwright_navigate in the main tool handler switch statementcase "playwright_navigate": return await navigationTool.execute(args, context);
- src/toolHandler.ts:318-318 (registration)Instantiation of the NavigationTool instance used for handling playwright_navigate callsif (!navigationTool) navigationTool = new NavigationTool(server);
- src/tools.ts:451-451 (registration)Inclusion of playwright_navigate in the BROWSER_TOOLS array for conditional browser launching"playwright_navigate",