Skip to main content
Glama

click_element

Click on webpage elements using CSS selectors to automate browser interactions for testing, debugging, and data extraction workflows.

Instructions

Clica em um elemento da página

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesSeletor CSS do elemento para clicar
waitForNavigationNoAguardar navegação após o clique

Implementation Reference

  • The core handler function that implements the click_element tool. It clicks on the specified CSS selector using Puppeteer's page.click(), optionally waiting for navigation, and returns a success message.
    export async function handleClickElement(args: unknown, currentPage: Page): Promise<ToolResponse> {
      const typedArgs = args as unknown as ClickElementArgs;
      const { selector, waitForNavigation = false } = typedArgs;
    
      if (waitForNavigation) {
        await Promise.all([currentPage.waitForNavigation(), currentPage.click(selector)]);
      } else {
        await currentPage.click(selector);
      }
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              success: true,
              message: `Elemento clicado: ${selector}`,
            }),
          },
        ],
      };
    }
  • TypeScript interface defining the input arguments for the click_element tool: selector (required) and waitForNavigation (optional).
    export interface ClickElementArgs {
      selector: string;
      waitForNavigation?: boolean;
    }
  • src/tools.ts:192-210 (registration)
    MCP tool registration entry including the name 'click_element', description, and JSON inputSchema for validation.
    {
      name: 'click_element',
      description: 'Clica em um elemento da página',
      inputSchema: {
        type: 'object',
        properties: {
          selector: {
            type: 'string',
            description: 'Seletor CSS do elemento para clicar',
          },
          waitForNavigation: {
            type: 'boolean',
            description: 'Aguardar navegação após o clique',
            default: false,
          },
        },
        required: ['selector'],
      },
    },
  • src/index.ts:103-106 (registration)
    Runtime dispatch/registration in the main server handler switch statement, which initializes the browser page and calls the click_element handler.
    case 'click_element': {
      const currentPage = await initBrowser();
      return await handleClickElement(args, currentPage);
    }
Behavior2/5

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

With no annotations, the description carries full burden but only states the basic action. It doesn't disclose behavioral traits like error handling (e.g., if element not found), side effects (e.g., page changes), or performance aspects (e.g., timeouts). More context is needed for a mutation tool.

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?

The description is a single, efficient sentence with zero waste. It's front-loaded and appropriately sized for the tool's purpose, making it easy to parse quickly.

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?

Given no annotations, no output schema, and a mutation tool with two parameters, the description is incomplete. It lacks details on return values, error cases, or interaction context, leaving gaps for an AI agent to understand full behavior.

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 100%, so the schema already documents both parameters ('selector' and 'waitForNavigation') well. The description adds no additional meaning beyond what the schema provides, meeting the baseline for high coverage.

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

Purpose3/5

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

The description 'Clica em um elemento da página' clearly states the action (click) and target (element on a page), but it's vague about the context (e.g., web page interaction) and doesn't differentiate from siblings like 'get_element' or 'type_text'. It's understandable but lacks specificity.

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 is provided on when to use this tool versus alternatives such as 'type_text' for input or 'get_element' for retrieval. The description implies usage for clicking but offers no context, prerequisites, or exclusions.

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/EmmanuelBarbosaMonteiro/mcp-server-browser'

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