navigate
Directs a browser to a specific webpage for automation tasks, enabling LLM-powered clients to control web navigation.
Instructions
Navigate to a URL
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | ||
| page_id | No |
Implementation Reference
- src/playwright_mcp/server.py:228-235 (handler)The handler logic for the 'navigate' tool within the handle_call_tool function. It retrieves the URL from arguments, gets the active page, navigates to the URL using page.goto, and returns a success message.if name == "navigate": url = arguments.get("url") if not url: raise ValueError("URL is required") page = get_active_page(arguments.get("page_id")) await page.goto(url) return [types.TextContent(type="text", text=f"Navigated to {url}")]
- src/playwright_mcp/server.py:85-96 (registration)Registration of the 'navigate' tool in the list_tools handler, including its name, description, and input schema.types.Tool( name="navigate", description="Navigate to a URL", inputSchema={ "type": "object", "properties": { "url": {"type": "string"}, "page_id": {"type": "string"}, }, "required": ["url"], }, ),
- src/playwright_mcp/server.py:200-210 (helper)Helper function used by the 'navigate' handler to retrieve the active browser page based on page_id or current default.def get_active_page(page_id: Optional[str] = None) -> Page: """Get the active page based on page_id or current default.""" global current_page_id if page_id is None: page_id = current_page_id if page_id not in pages: raise ValueError(f"Page not found: {page_id}") return pages[page_id]