click
Click on a page element using a CSS selector to enable dynamic interaction during JavaScript reverse engineering and debugging.
Instructions
Click on a page element.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes |
Implementation Reference
- The click tool handler - takes a CSS selector, gets the active page from BrowserManager, and uses Playwright's page.click() to perform the click.
@mcp.tool() async def click(selector: str) -> dict: """Click on a page element.""" try: page = await browser_manager.get_active_page() await page.click(selector) return {"status": "clicked", "selector": selector} except Exception as e: return {"error": str(e)} - src/camoufox_reverse_mcp/tools/navigation.py:5-8 (registration)Registration via @mcp.tool() decorator - the 'mcp' FastMCP instance is imported from server.py and the @mcp.tool() decorator on line 313 registers the click function as an MCP tool.
import json as _json import os from ..server import mcp, browser_manager - BrowserManager.get_active_page helper used by the click handler to retrieve the current page instance.
async def get_active_page(self) -> Page: """Get the currently active page, launching the browser if needed.""" await self._ensure_browser() if self.active_page_name and self.active_page_name in self.pages: return self.pages[self.active_page_name] raise RuntimeError("No active page available. Call launch_browser first.")