multi_click
Click multiple labeled elements simultaneously to solve CAPTCHAs, select checkboxes, or perform batch interactions on web pages.
Instructions
Click multiple elements at once (useful for CAPTCHA, checkboxes, etc.)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| label_ids | Yes | List of label IDs to click (e.g., [1, 5, 8]) |
Implementation Reference
- src/atlas_browser_mcp/browser.py:400-442 (handler)The _multi_click method implements the core logic for clicking multiple elements by label IDs. It validates input, iterates through label IDs, performs humanized clicks for each valid element, tracks results, and returns an observation with click details.
def _multi_click(self, label_ids: list = None, **_) -> BrowserResult: """Click multiple elements (for CAPTCHA, checkboxes, etc.)""" if not label_ids: return BrowserResult(success=False, error="label_ids required (e.g., [1, 5, 8])") if self._page is None: return BrowserResult(success=False, error="No page open") self._page.evaluate("() => document.querySelectorAll('.atlas-som-label').forEach(el => el.remove())") results = [] for label_id in label_ids: if label_id not in self._element_map: results.append({"label_id": label_id, "success": False, "error": "Not found"}) continue element = self._element_map[label_id] try: self._human_click_at( element['x'], element['y'], element['width'], element['height'] ) results.append({"label_id": label_id, "success": True}) if self._humanize: time.sleep(random.uniform(0.15, 0.35)) except Exception as e: results.append({"label_id": label_id, "success": False, "error": str(e)}) self._page.wait_for_timeout(300) observe_result = self._observe() if observe_result.success: observe_result.data["clicks"] = results observe_result.data["clicked_count"] = sum(1 for r in results if r.get("success")) return observe_result - Tool schema definition for multi_click, specifying it accepts a 'label_ids' array of integers. This defines the input/output contract for the MCP tool.
Tool( name="multi_click", description="Click multiple elements at once (useful for CAPTCHA, checkboxes, etc.)", inputSchema={ "type": "object", "properties": { "label_ids": { "type": "array", "items": {"type": "integer"}, "description": "List of label IDs to click (e.g., [1, 5, 8])" } }, "required": ["label_ids"] } ), - src/atlas_browser_mcp/browser.py:76-84 (registration)Action mapping in the execute method that registers 'multi_click' string to the _multi_click handler method, making it available as a browser action.
actions = { "navigate": self._navigate, "observe": self._observe, "click": self._click, "multi_click": self._multi_click, "type": self._type, "scroll": self._scroll, "close": self._close } - src/atlas_browser_mcp/server.py:160-165 (registration)The call_tool handler that routes 'multi_click' tool invocations to the browser.execute method with the appropriate action and label_ids arguments.
elif name == "multi_click": result = await asyncio.to_thread( browser.execute, action="multi_click", label_ids=arguments.get("label_ids") ) - Special formatting in format_result to include multi_click specific data (clicks array and clicked_count) in the MCP response.
# 如果是 multi_click,加入點擊結果 if "clicks" in data: info["clicks"] = data["clicks"] info["clicked_count"] = data.get("clicked_count", 0)