Skip to main content
Glama

browser_hover

Simulate hovering over a web element using a CSS selector to test UI interactions and identify potential vulnerabilities during web application penetration testing.

Instructions

Hover an element on the page using CSS selector

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector for element to hover

Implementation Reference

  • The handler function for the 'browser_hover' tool. Hovers over the element specified by the CSS selector using Playwright's locator.hover(), with fallback for strict mode violations by targeting the first matching element.
    case ToolName.BrowserHover: try { await page.locator(args.selector).hover(); return { content: [{ type: "text", text: `Hovered ${args.selector}`, }], 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.locator(args.selector).first().hover(); 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, }; } } return { content: [{ type: "text", text: `Failed to hover ${args.selector}: ${(error as Error).message}`, }], isError: true, }; }
  • index.ts:133-143 (registration)
    Registers the 'browser_hover' tool in the TOOLS array, which is provided to the MCP server via ListToolsRequestSchema handler. Includes description and input schema.
    { name: ToolName.BrowserHover, description: "Hover an element on the page using CSS selector", inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for element to hover" }, }, required: ["selector"], }, },
  • Defines the input schema for the 'browser_hover' tool, requiring a 'selector' property of type string.
    inputSchema: { type: "object", properties: { selector: { type: "string", description: "CSS selector for element to hover" }, }, required: ["selector"], },
  • Enum definition mapping ToolName.BrowserHover to the string 'browser_hover' used throughout the code for tool identification.
    BrowserHover = "browser_hover",
  • index.ts:844-846 (registration)
    Registers the handleToolCall function as the handler for all CallToolRequests, which dispatches to specific tool handlers based on name.
    server.setRequestHandler(CallToolRequestSchema, async (request) => handleToolCall(request.params.name as ToolName, request.params.arguments ?? {}) );

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/9olidity/MCP-Server-Pentest'

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