Skip to main content
Glama
VikashLoomba

MCP-Server-Playwright

browser_hover_text

Hover over web page elements using text content to trigger interactive features or reveal hidden information during browser automation with Playwright.

Instructions

Hover an element on the page by its text content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText content of the element to hover

Implementation Reference

  • The main handler logic for the 'browser_hover_text' tool. It uses Playwright to hover over an element matching the provided text, includes try-catch error handling, and retries on the first matching element if strict mode violation occurs.
    case ToolName.BrowserHoverText:
      try {
        await page.getByText(args.text).hover();
        return {
          content: [{
            type: "text",
            text: `Hovered element with text: ${args.text}`,
          }],
          isError: false,
        };
      } catch (error) {
        if((error as Error).message.includes("strict mode violation")) {
            console.log("Strict mode violation, retrying on first element...");
            try {
                await page.getByText(args.text).first().hover();
                return {
                    content: [{
                        type: "text",
                        text: `Hovered element with text: ${args.text}`,
                    }],
                    isError: false,
                };
            } catch (error) {
                return {
                    content: [{
                        type: "text",
                        text: `Failed (twice) to hover element with text ${args.text}: ${(error as Error).message}`,
                    }],
                    isError: true,
                };
            }
        }
        return {
          content: [{
            type: "text",
            text: `Failed to hover element with text ${args.text}: ${(error as Error).message}`,
          }],
          isError: true,
        };
      }
  • Schema definition for the 'browser_hover_text' tool, including input schema requiring a 'text' string parameter.
    {
      name: ToolName.BrowserHoverText,
      description: "Hover an element on the page by its text content",
      inputSchema: {
        type: "object",
        properties: {
          text: { type: "string", description: "Text content of the element to hover" },
        },
        required: ["text"],
      },
    },
  • index.ts:640-642 (registration)
    Registration of all tools, including 'browser_hover_text', via the TOOLS array in the ListToolsRequestSchema handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: TOOLS,
    }));
  • ToolName enum defining the string constant for 'browser_hover_text' tool.
    enum ToolName {
      BrowserNavigate = "browser_navigate",
      BrowserScreenshot = "browser_screenshot",
      BrowserClick = "browser_click",
      BrowserClickText = "browser_click_text",
      BrowserFill = "browser_fill",
      BrowserSelect = "browser_select",
      BrowserSelectText = "browser_select_text",
      BrowserHover = "browser_hover",
      BrowserHoverText = "browser_hover_text",
      BrowserEvaluate = "browser_evaluate"
    }
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 what the tool does but lacks critical details: it doesn't specify if hovering triggers side effects (e.g., loading content), what happens if the text isn't found (error behavior), or any performance considerations (e.g., timeouts). This leaves significant gaps for a browser interaction 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 that directly states the tool's function without unnecessary words. It is 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 complexity of browser interactions (which often involve side effects and error handling), no annotations, and no output schema, the description is incomplete. It fails to address behavioral aspects like what the tool returns or how it handles failures, which are crucial for an agent to use it correctly in a dynamic environment.

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 'text' parameter clearly documented. The description adds no additional meaning beyond the schema (e.g., it doesn't explain text matching rules like case sensitivity or partial matches), so it meets the baseline score of 3 where the schema does the heavy lifting.

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 action ('hover') and target ('an element on the page by its text content'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'browser_hover' (which likely hovers by selector rather than text) or 'browser_click_text' (which clicks rather than hovers), missing full sibling distinction.

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 when hovering is appropriate (e.g., for tooltips or dropdowns) or when to choose text-based hovering over selector-based hovering ('browser_hover'), leaving usage context implied at best.

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/VikashLoomba/MCP-Server-Playwright'

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