Skip to main content
Glama

browser_hover

Hover over specified web elements using Playwright MCP to interact with page elements directly, enabling precise browser automation without visual models or screenshots.

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 derives a locator from the page snapshot for the given element reference and performs a hover operation using Playwright, generating corresponding code and an action callback.
    handle: async (context, params) => { const snapshot = context.currentTabOrDie().snapshotOrDie(); const locator = snapshot.refLocator(params); const code = [ `// Hover over ${params.element}`, `await page.${await generateLocator(locator)}.hover();` ]; return { code, action: () => locator.hover(), captureSnapshot: true, waitForNetwork: true, }; },
  • Schema definition for the browser_hover tool, specifying name, title, description, input schema (elementSchema), and type as readOnly.
    schema: { name: 'browser_hover', title: 'Hover mouse', description: 'Hover over element on page', inputSchema: elementSchema, type: 'readOnly', },
  • Shared elementSchema used as inputSchema for browser_hover and other interaction tools, defining element description and reference.
    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 browser_hover tool is defined and registered using defineTool, which creates a Tool object exported for inclusion in the tools registry.
    const hover = defineTool({ capability: 'core', schema: { name: 'browser_hover', title: 'Hover mouse', description: 'Hover over element on page', inputSchema: elementSchema, type: 'readOnly', }, handle: async (context, params) => { const snapshot = context.currentTabOrDie().snapshotOrDie(); const locator = snapshot.refLocator(params); const code = [ `// Hover over ${params.element}`, `await page.${await generateLocator(locator)}.hover();` ]; return { code, action: () => locator.hover(), captureSnapshot: true, waitForNetwork: true, }; }, });
  • src/tools.ts:47-47 (registration)
    The snapshot tools module, which exports browser_hover among others, is spread into the snapshotTools array for top-level tool registration.
    ...snapshot,

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/lewisvoncken/playwright-mcp'

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