Skip to main content
Glama
random-robbie

MCP Web Browser Server

click_element

Click elements on web pages using CSS selectors to interact with buttons, links, or other interactive components in automated browser sessions.

Instructions

Click an element on the current page.

Args:
    selector: CSS selector for the element to click
    context: Optional context object for logging (ignored)

Returns:
    Confirmation message or error details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYes
contextNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'click_element' tool. It is decorated with @mcp.tool() which serves as the registration mechanism in this MCP implementation. The function locates an element by CSS selector on the current browser page and clicks it, returning a success message or raising an error.
    @mcp.tool()
    async def click_element(
        selector: str, 
        context: Optional[Any] = None
    ) -> str:
        """
        Click an element on the current page.
        
        Args:
            selector: CSS selector for the element to click
            context: Optional context object for logging (ignored)
        
        Returns:
            Confirmation message or error details
        """
        global _current_page
        
        if not _current_page:
            raise ValueError("No page is currently loaded. Use browse_to first.")
        
        try:
            element = await _current_page.query_selector(selector)
            if not element:
                raise ValueError(f"No element found with selector: {selector}")
            
            await element.click()
            print(f"Clicked element: {selector}", file=sys.stderr)
            
            return f"Successfully clicked element: {selector}"
        
        except Exception as e:
            print(f"Error clicking element: {e}", file=sys.stderr)
            raise ValueError(f"Error clicking element: {e}")
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action is 'click' but doesn't mention what happens if the element isn't found, if the page needs to be loaded first, if there are timing considerations, or what errors might occur. This leaves significant gaps for a tool that performs UI interactions.

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

Conciseness4/5

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

The description is appropriately sized with a clear purpose statement followed by parameter and return value sections. Each sentence adds value, though the 'context' explanation could be more precise about why it's included if ignored.

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

Completeness3/5

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

Given that this is a UI interaction tool with no annotations and 2 parameters (one with 0% schema coverage), the description is minimally adequate. It explains the basic purpose and parameters but lacks crucial behavioral context about error conditions, prerequisites, and interaction patterns. The presence of an output schema helps but doesn't fully compensate for missing operational details.

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

Parameters3/5

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

Schema description coverage is 0%, so the description must compensate. It explains that 'selector' is a 'CSS selector for the element to click' and that 'context' is 'optional... for logging (ignored)', which adds meaningful semantics beyond the bare schema. However, it doesn't provide examples of valid selectors or explain what 'ignored' means operationally.

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

Purpose4/5

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

The description clearly states the action ('click an element') and the target ('on the current page'), providing a specific verb+resource combination. However, it doesn't explicitly distinguish this tool from potential sibling tools like 'input_text' or 'browse_to' that might also interact with page elements, missing full sibling differentiation.

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?

The description provides no guidance on when to use this tool versus alternatives like 'input_text' for text entry or 'browse_to' for navigation. It mentions the context parameter is 'ignored' but doesn't explain when this tool is appropriate versus other interaction methods.

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/random-robbie/mcp-web-browser'

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