Skip to main content
Glama

playwright_hover

Simulate mouse hover interactions on web elements using CSS selectors for testing or automation scenarios.

Instructions

Hover an element on the page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector for element to hover

Implementation Reference

  • The switch case in handleToolCall function that implements the playwright_hover tool. It waits for the selector, hovers the element using page.hover, and returns success or error message.
    case "playwright_hover":
      try {
        await page!.waitForSelector(args.selector);
        await page!.hover(args.selector);
        return {
          content: [{
            type: "text",
            text: `Hovered ${args.selector}`,
          }],
          isError: false,
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: `Failed to hover ${args.selector}: ${(error as Error).message}`,
          }],
          isError: true,
        };
      }
  • The tool schema definition in createToolDefinitions(), specifying name, description, and input schema requiring a 'selector' property.
    {
      name: "playwright_hover",
      description: "Hover an element on the page",
      inputSchema: {
        type: "object",
        properties: {
          selector: { type: "string", description: "CSS selector for element to hover" },
        },
        required: ["selector"],
      },
    },
  • Registration of the listTools request handler, which returns the array of all tools including playwright_hover.
    // List tools handler
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: tools,
    }));
  • Registration of the callTool request handler, which dispatches to the specific handler based on tool name.
    server.setRequestHandler(CallToolRequestSchema, async (request) =>
      handleToolCall(request.params.name, request.params.arguments ?? {}, server)
    );
  • src/index.ts:22-26 (registration)
    Where the tools are created via createToolDefinitions() and passed to setupRequestHandlers for registration on the MCP server.
    // Create tool definitions
    const TOOLS = createToolDefinitions();
    
    // Setup request handlers
    setupRequestHandlers(server, TOOLS);
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It states the action but doesn't mention potential side effects (e.g., triggering hover states, tooltips, or animations), error conditions (e.g., if selector not found), or performance implications. This leaves significant gaps for a tool that interacts with dynamic page elements.

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 ('Hover an element on the page') that directly states the tool's purpose without unnecessary words. It's front-loaded and wastes no space, 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 the lack of annotations and output schema, the description is incomplete for a tool that performs a UI interaction. It doesn't explain what happens after hovering (e.g., does it wait for effects, return success/failure, or trigger events?), leaving the agent with insufficient context to use it effectively in complex scenarios.

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?

The input schema has 100% description coverage, with the 'selector' parameter clearly documented as a CSS selector. The description doesn't add any meaning beyond this, such as examples of valid selectors or tips for targeting elements. Given the high schema coverage, the baseline score of 3 is appropriate.

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 an element on the page' clearly states the action (hover) and target (element on page), providing a specific verb+resource. However, it doesn't differentiate from sibling tools like playwright_click or playwright_select, which also interact with page elements, leaving some ambiguity about when to use hover versus other interactions.

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. With siblings like playwright_click, playwright_fill, and playwright_select available, there's no indication of whether hovering is for triggering UI effects, inspecting elements, or other purposes, leaving usage context entirely implied.

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/lars-hagen/mcp-playwright-cdp'

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