Skip to main content
Glama
livoras

Better Playwright MCP

by livoras

browserClick

Automate web element clicks with precision using page ID and element reference. Optimizes browser interactions by reducing HTML token usage, enabling efficient and controlled automation workflows.

Instructions

点击页面元素

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageIdYes页面ID
refYes元素的xp引用值
waitForTimeoutNo操作后等待获取快照的延迟时间(毫秒,默认2000)

Implementation Reference

  • Zod schemas (elementSchema and clickSchema) that define the input parameters for the browser_click tool, including element description, ref, optional doubleClick, and button.
    export const elementSchema = z.object({
        element: z.string().describe('Human-readable element description used to obtain permission to interact with the element'),
        ref: z.string().describe('Exact target element reference from the page snapshot'),
    });
    const clickSchema = elementSchema.extend({
        doubleClick: z.boolean().optional().describe('Whether to perform a double click instead of a single click'),
        button: z.enum(['left', 'right', 'middle']).optional().describe('Button to click, defaults to left'),
    });
  • The handler function that performs the click or double-click on the element using the resolved locator, adds corresponding Playwright code to response, and waits for completion.
    handle: async (tab, params, response) => {
        response.setIncludeSnapshot();
        const locator = await tab.refLocator(params);
        const button = params.button;
        const buttonAttr = button ? `{ button: '${button}' }` : '';
        if (params.doubleClick)
            response.addCode(`await page.${await generateLocator(locator)}.dblclick(${buttonAttr});`);
        else
            response.addCode(`await page.${await generateLocator(locator)}.click(${buttonAttr});`);
        await tab.waitForCompletion(async () => {
            if (params.doubleClick)
                await locator.dblclick({ button });
            else
                await locator.click({ button });
        });
    },
  • The full definition and registration of the 'browser_click' tool using defineTabTool, including schema and handler. This is the core implementation location.
    const click = defineTabTool({
        capability: 'core',
        schema: {
            name: 'browser_click',
            title: 'Click',
            description: 'Perform click on a web page',
            inputSchema: clickSchema,
            type: 'destructive',
        },
  • lib/tools.js:32-49 (registration)
    Aggregates all individual tool modules, including snapshot.js which exports the browser_click tool, into the allTools array used by the backend.
    export const allTools = [
        ...common,
        ...console,
        ...dialogs,
        ...evaluate,
        ...files,
        ...form,
        ...install,
        ...keyboard,
        ...navigate,
        ...network,
        ...mouse,
        ...pdf,
        ...screenshot,
        ...snapshot,
        ...tabs,
        ...wait,
    ];
  • The MCP backend's callTool method that looks up the tool by name ('browser_click'), parses arguments, invokes the handler, and serializes the response.
    async callTool(name, rawArguments) {
        const tool = this._tools.find(tool => tool.schema.name === name);
        if (!tool)
            throw new Error(`Tool "${name}" not found`);
        const parsedArguments = tool.schema.inputSchema.parse(rawArguments || {});
        const context = this._context;
        const response = new Response(context, name, parsedArguments);
        context.setRunningTool(name);
        try {
            await tool.handle(context, parsedArguments, response);
            await response.finish();
            this._sessionLog?.logResponse(response);
        }
        catch (error) {
            response.addError(String(error));
        }
        finally {
            context.setRunningTool(undefined);
        }
        return response.serialize();
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. '点击页面元素' only states the action but doesn't describe what happens after clicking (e.g., page navigation, element state change, error handling). It doesn't mention authentication needs, rate limits, or whether this is a read-only or mutating operation. The description is too minimal for a tool that performs interactive browser actions.

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 extremely concise - a single Chinese phrase. While this may be too brief for adequate tool understanding, it's perfectly front-loaded with zero wasted words. Every character serves the core purpose statement, making it maximally efficient in terms of word economy.

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 this is a browser interaction tool with 3 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what the tool returns (success/failure status, page state changes), doesn't mention error conditions, and provides minimal context for a tool that performs potentially complex browser automation. The agent would need to guess about the tool's behavior and outcomes.

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 all parameters (pageId, ref, waitForTimeout) are documented in the schema. The description adds no additional parameter information beyond what's already in the structured schema. According to scoring rules, when schema coverage is high (>80%), the baseline score is 3 even without parameter details in the description.

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

Purpose2/5

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

The description '点击页面元素' (click page element) is a tautology that essentially restates the tool name 'browserClick' in Chinese. It doesn't specify what type of clicking occurs (single click, double click, right click) or what happens after the click. While it mentions the resource ('页面元素' - page element), it lacks the specificity needed to distinguish it from similar tools like browserPressKey or browserSelectOption.

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 about when to use this tool versus alternatives. The description doesn't mention prerequisites (e.g., needing an active page), exclusions, or comparison to sibling tools like browserPressKey (for keyboard interactions) or browserSelectOption (for dropdown selections). The agent must infer usage from context alone.

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

Related 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/livoras/better-playwright-mcp'

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