Skip to main content
Glama
nzjami

Playwright MCP

by nzjami

browser_hover

Destructive

Hover over web page elements to trigger interactive features like dropdown menus, tooltips, or hover effects during browser automation with Playwright MCP.

Instructions

Hover over element on page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
elementYesHuman-readable element description used to obtain permission to interact with the element
refYesExact target element reference from the page snapshot

Implementation Reference

  • The handler function for the 'browser_hover' tool. It ensures a snapshot is included in the response, resolves the element locator from the provided ref and element description, generates code for hovering over the element in Playwright, and waits for the hover action to complete on the tab.
    handle: async (tab, params, response) => {
      response.setIncludeSnapshot();
    
      const locator = await tab.refLocator(params);
      response.addCode(`await page.${await generateLocator(locator)}.hover();`);
    
      await tab.waitForCompletion(async () => {
        await locator.hover();
      });
    },
  • The schema definition for the 'browser_hover' tool, specifying its name, title, description, input schema (reusing elementSchema), and readOnly type.
    schema: {
      name: 'browser_hover',
      title: 'Hover mouse',
      description: 'Hover over element on page',
      inputSchema: elementSchema,
      type: 'readOnly',
    },
  • Shared Zod schema for element-based tools like browser_hover, defining 'element' (human-readable description) and 'ref' (exact reference from snapshot).
    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'),
    });
  • The complete tool registration using defineTabTool, which wraps the tab-specific handler and schema for MCP compatibility.
    const hover = defineTabTool({
      capability: 'core',
      schema: {
        name: 'browser_hover',
        title: 'Hover mouse',
        description: 'Hover over element on page',
        inputSchema: elementSchema,
        type: 'readOnly',
      },
    
      handle: async (tab, params, response) => {
        response.setIncludeSnapshot();
    
        const locator = await tab.refLocator(params);
        response.addCode(`await page.${await generateLocator(locator)}.hover();`);
    
        await tab.waitForCompletion(async () => {
          await locator.hover();
        });
      },
    });
  • src/tools.ts:27-52 (registration)
    Top-level aggregation and registration of all tools, importing snapshot.ts (containing browser_hover) and including it in the allTools array used for MCP server registration.
    import snapshot from './tools/snapshot.js';
    import tabs from './tools/tabs.js';
    import screenshot from './tools/screenshot.js';
    import wait from './tools/wait.js';
    import mouse from './tools/mouse.js';
    
    import type { Tool } from './tools/tool.js';
    import type { FullConfig } from './config.js';
    
    export const allTools: Tool<any>[] = [
      ...common,
      ...console,
      ...dialogs,
      ...evaluate,
      ...files,
      ...install,
      ...keyboard,
      ...navigate,
      ...network,
      ...mouse,
      ...pdf,
      ...screenshot,
      ...snapshot,
      ...tabs,
      ...wait,
    ];

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.3/5.0
Behavior3/5

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

Annotations provide key behavioral hints: readOnlyHint=false, openWorldHint=true, and destructiveHint=true, indicating this is a mutable, open-world operation with potential destructive effects. The description adds minimal context beyond this, as 'Hover over element on page' doesn't disclose additional traits like what 'destructive' entails (e.g., unintended page changes) or any rate limits. It doesn't contradict annotations, but offers little extra insight, meeting the lower bar with annotations present.

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 'Hover over element on page' is extremely concise and front-loaded, consisting of a single, direct sentence that immediately conveys the core action. There is no wasted language or unnecessary elaboration, making it efficient for quick understanding without sacrificing clarity.

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 the tool's moderate complexity (interactive browser action with destructive potential), the description is minimal but adequate when combined with annotations and a well-documented schema. It lacks output schema or details on return values, but annotations cover safety and world hints. The description could be more complete by explaining hover effects or prerequisites, but it meets basic needs without being misleading.

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%, with clear descriptions for both parameters: 'element' as a human-readable description for permission and 'ref' as an exact target reference. The description adds no parameter-specific information beyond what the schema provides, such as examples or usage notes. Given the high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 'Hover over element on page' clearly states the action (hover) and target (element on page), making the purpose immediately understandable. It distinguishes itself from siblings like 'browser_click' or 'browser_type' by specifying a hover interaction rather than click or typing. However, it doesn't explicitly differentiate from other mouse-related tools like 'browser_drag' beyond the verb, which keeps it from a perfect score.

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. It doesn't mention scenarios where hovering is appropriate (e.g., to trigger dropdowns or tooltips) or when to avoid it (e.g., for direct interactions like clicking). With siblings like 'browser_click' and 'browser_drag' available, the lack of usage context leaves the agent to infer when this specific mouse action is needed.

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