browser_evalute
Execute JavaScript expressions directly in the browser console for web scraping, testing, or automation, bypassing anti-bot detection systems to handle complex protections.
Instructions
Evaluate a JavaScript expression in the browser console
Args:
script: The JavaScript expression to evaluate - required
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes |
Implementation Reference
- Full handler implementation for the 'browser_evalute' tool. Includes registration via @mcp.tool(), input schema in function signature and docstring, validation, and execution of JavaScript using driver.execute_script(script). Uses shared helpers for browser management and response formatting.@mcp.tool() async def browser_evalute( script: str, ): """Evaluate a JavaScript expression in the browser console Args: script: The JavaScript expression to evaluate - required """ assert script, "Script is required" async def evaluate_handler(driver: uc.Chrome): return await create_success_response( [ "Executed script:", f"{script}", "Result:", f"{driver.execute_script(script)}", ] ) return await tool.safe_execute( ToolContext(webdriver=await ensure_browser()), evaluate_handler )