Skip to main content
Glama
devskido

Playwright MCP Server

by devskido

playwright_hover

Simulate mouse hover interactions on web elements using CSS selectors for browser automation testing and UI interaction.

Instructions

Hover an element on the page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector for element to hover

Implementation Reference

  • The HoverTool class implements the core logic for the 'playwright_hover' tool. It waits for the selector and performs a hover action using Playwright's page.hover method.
    export class HoverTool extends BrowserToolBase {
      /**
       * Execute the hover tool
       */
      async execute(args: any, context: ToolContext): Promise<ToolResponse> {
        return this.safeExecute(context, async (page) => {
          await page.waitForSelector(args.selector);
          await page.hover(args.selector);
          return createSuccessResponse(`Hovered ${args.selector}`);
        });
      }
    }
  • Input schema definition for the 'playwright_hover' tool, specifying the required 'selector' parameter.
    {
      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 and dispatch in the main tool handler switch statement, calling HoverTool.execute for 'playwright_hover'.
    case "playwright_hover":
      return await hoverTool.execute(args, context);
  • Instantiation of the HoverTool instance in the initializeTools function.
    if (!hoverTool) hoverTool = new HoverTool(server);
  • Code generation helper in PlaywrightGenerator that converts 'playwright_hover' actions to equivalent Playwright test code.
        case 'playwright_hover':
          return this.generateHoverStep(parameters);
        case 'playwright_select':
          return this.generateSelectStep(parameters);
        case 'playwright_custom_user_agent':
          return this.generateCustomUserAgentStep(parameters);
        default:
          console.warn(`Unsupported tool: ${toolName}`);
          return null;
      }
    }
    
    private generateNavigateStep(parameters: Record<string, unknown>): string {
      const { url, waitUntil } = parameters;
      const options = waitUntil ? `, { waitUntil: '${waitUntil}' }` : '';
      return `
      // Navigate to URL
      await page.goto('${url}'${options});`;
    }
    
    private generateFillStep(parameters: Record<string, unknown>): string {
      const { selector, value } = parameters;
      return `
      // Fill input field
      await page.fill('${selector}', '${value}');`;
    }
    
    private generateClickStep(parameters: Record<string, unknown>): string {
      const { selector } = parameters;
      return `
      // Click element
      await page.click('${selector}');`;
    }
    
    private generateScreenshotStep(parameters: Record<string, unknown>): string {
      const { name, fullPage = false, path } = parameters;
      const options = [];
      if (fullPage) options.push('fullPage: true');
      if (path) options.push(`path: '${path}'`);
      
      const optionsStr = options.length > 0 ? `, { ${options.join(', ')} }` : '';
      return `
      // Take screenshot
      await page.screenshot({ path: '${name}.png'${optionsStr} });`;
    }
    
    private generateExpectResponseStep(parameters: Record<string, unknown>): string {
      const { url, id } = parameters;
      return `
      // Wait for response
      const ${id}Response = page.waitForResponse('${url}');`;
    }
    
    private generateAssertResponseStep(parameters: Record<string, unknown>): string {
      const { id, value } = parameters;
      const assertion = value 
        ? `\n    const responseText = await ${id}Response.text();\n    expect(responseText).toContain('${value}');`
        : `\n    expect(${id}Response.ok()).toBeTruthy();`;
      return `
      // Assert response${assertion}`;
    }
    
    private generateHoverStep(parameters: Record<string, unknown>): string {
      const { selector } = parameters;
      return `
      // Hover over element
      await page.hover('${selector}');`;
    }
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. It states the action ('hover') but doesn't explain what happens during hovering (e.g., whether it triggers events, waits for animations, or handles errors). This leaves gaps in understanding the tool's behavior beyond the basic action.

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, direct sentence with no wasted words, making it highly concise and front-loaded. It efficiently communicates the core action without unnecessary elaboration, earning full marks for brevity and clarity.

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 an interactive action. It doesn't cover behavioral aspects like error handling, return values, or side effects (e.g., page state changes), which are crucial for an AI agent to use it effectively in automation 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 fully documented. The description adds no additional meaning beyond what the schema provides, such as examples or constraints on selectors. Baseline score of 3 is appropriate since the schema handles parameter documentation adequately.

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 verb ('hover') and resource ('an element on the page'), making the tool's purpose immediately understandable. It doesn't explicitly differentiate from siblings like 'playwright_click' or 'playwright_press_key', which would require more specific context about hover interactions versus other actions.

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 'playwright_click' or 'playwright_press_key'. The description lacks context about hover-specific scenarios, like triggering dropdowns or tooltips, leaving the agent to infer usage from the tool name 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

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/devskido/customed-playwright'

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