Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
element_indexYes
valueYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • 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"
  • 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
  • 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:
  • 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
  • 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
            )
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must disclose behavioral traits. It only states basic function, omitting what happens if the value is not found, whether the selection triggers form changes, or any side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two-line summary plus concise Args section; no wasted words. Front-loaded with the main action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite having an output schema (not shown), the description does not clarify what the tool returns (e.g., success flag, new page state). For an interactive tool, this is a significant gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, but description adds meaning by explaining element_index as '[N] index' and value as 'the value or visible text', which goes beyond bare schema definitions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Select' and the resource 'option from a dropdown/select element', uniquely distinguishing it from siblings like click or type_text.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives (e.g., click for standard buttons, type_text for text inputs). Context signals list many siblings but description offers no comparison.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/chriswu727/argus'

If you have feedback or need assistance with the MCP directory API, please join our Discord server