browser_navigate
Directs a Chrome browser to a specified URL using undetected automation, bypassing anti-bot detection mechanisms. Includes an optional timeout parameter for navigation control, ideal for web scraping and testing.
Instructions
Navigate to a URL
Args:
url: The URL to navigate to - required
timeout: The timeout for the navigation - optional, default is 30000
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timeout | No | ||
| url | Yes |
Implementation Reference
- The main handler function for the 'browser_navigate' tool. It uses undetected ChromeDriver to navigate to the specified URL with an optional timeout. Includes input validation, page load timeout setting, and error handling via safe_execute.@mcp.tool() async def browser_navigate(url: str, timeout: int = 30000): """Navigate to a URL Args: url: The URL to navigate to - required timeout: The timeout for the navigation - optional, default is 30000 """ assert url, "URL is required" async def navigate_handler(driver: uc.Chrome): print(f"Navigating to {url}") driver.set_page_load_timeout(timeout) driver.get(url) return await create_success_response(f"Navigated to {url}") return await tool.safe_execute( ToolContext(webdriver=await ensure_browser()), navigate_handler )
- src/mcp_server_undetected_chromedriver/server.py:85-85 (registration)The @mcp.tool() decorator registers the browser_navigate function as an MCP tool.@mcp.tool()
- The docstring provides the tool schema with parameter descriptions and types implied by function signature (url: str required, timeout: int optional default 30000)."""Navigate to a URL Args: url: The URL to navigate to - required timeout: The timeout for the navigation - optional, default is 30000 """
- Helper function to ensure the ChromeDriver instance is initialized.async def ensure_browser(config: dict | None = None): if not Global.webdriver: Global.webdriver = uc.Chrome( driver_executable_path=ChromeDriverManager().install() ) return Global.webdriver
- Helper to create successful tool response.async def create_success_response(message: str | list[str]) -> types.CallToolResult: if isinstance(message, str): message = [message] return types.CallToolResult( content=[TextContent(type="text", text=msg) for msg in message], isError=False, )