select_option
Select a dropdown option by providing the element's index and the value or visible text to choose.
Instructions
Select an option from a dropdown/select element.
Args: element_index: The [N] index of the select element value: The value or visible text to select
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| element_index | Yes | ||
| value | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- argus/mcp_server.py:363-381 (handler)MCP tool handler for 'select_option'. Decorated with @mcp.tool(). Validates element index, appends step to session, calls browser.select_option(), and returns success/failure message.
@mcp.tool() async def select_option(element_index: int, value: str) -> str: """Select an option from a dropdown/select element. Args: element_index: The [N] index of the select element value: The value or visible text to select """ s = _require_session() if element_index < 0 or element_index >= len(s._last_elements): return f"Error: element index {element_index} out of range" step = f'Select "{value}" in element [{element_index}]' s.steps.append(step) ok = await s.browser.select_option(element_index, value, s._last_elements) if ok: return f'Selected "{value}"' return "Failed to select option" - argus/browser.py:349-358 (handler)Low-level browser implementation of select_option. Builds a Playwright selector from the element and calls _page.select_option() with a 5-second timeout. Returns bool.
async def select_option( self, element_index: int, value: str, elements: List[InteractiveElement] ) -> bool: el = elements[element_index] selector = self._build_selector(el) try: await self._page.select_option(selector, value, timeout=5_000) return True except Exception: return False - argus/mcp_server.py:363-364 (registration)Registration via @mcp.tool() decorator. The function name 'select_option' becomes the tool name exposed to the MCP client (Claude Code).
@mcp.tool() async def select_option(element_index: int, value: str) -> str: - argus/mcp_server.py:249-258 (helper)The get_page_state() tool's docstring mentions select_option as one of the interaction methods users can use with element indices.
@mcp.tool() async def get_page_state() -> str: """Get the current page URL, title, and all interactive elements. Returns a numbered list of elements you can interact with using click(index), type_text(index, text), or select_option(index, value). """ s = _require_session() state = await s.browser.get_state() s._last_elements = state.elements - argus/explorer.py:230-238 (helper)Explorer._execute_action handles ActionType.SELECT by calling browser.select_option() with the action's element_index and value.
elif t == ActionType.SELECT: if ( action.element_index is not None and action.value and action.element_index < len(state.elements) ): return await self.browser.select_option( action.element_index, action.value, state.elements )