Skip to main content
Glama
andytango
by andytango

mouse

Control mouse actions at specific coordinates in a browser, including moving, clicking, and pressing buttons, to automate web interactions through the Puppeteer MCP Server.

Instructions

Perform mouse actions at specific coordinates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xYesX coordinate
yYesY coordinate
buttonNoleft
actionNoMouse action to performclick
tabIdNoTab ID to operate on (uses active tab if not specified)

Implementation Reference

  • Registers the 'mouse' tool on the MCP server, including the input schema reference, description, and the full handler function that uses Puppeteer to perform mouse move, click, down, or up actions at specified coordinates.
    server.tool(
      'mouse',
      'Perform mouse actions at specific coordinates',
      mouseSchema.shape,
      async ({ x, y, button, action, tabId }) => {
        const pageResult = await getPageForOperation(tabId);
        if (!pageResult.success) {
          return handleResult(pageResult);
        }
    
        const page = pageResult.data;
        const mouseButton = (button ?? 'left') as MouseButton;
        const mouseAction = (action ?? 'click') as MouseAction;
    
        try {
          switch (mouseAction) {
            case 'move':
              await page.mouse.move(x, y);
              break;
            case 'click':
              await page.mouse.click(x, y, { button: mouseButton });
              break;
            case 'down':
              await page.mouse.move(x, y);
              await page.mouse.down({ button: mouseButton });
              break;
            case 'up':
              await page.mouse.move(x, y);
              await page.mouse.up({ button: mouseButton });
              break;
          }
    
          return handleResult(ok({
            action: mouseAction,
            x,
            y,
            button: mouseButton,
          }));
        } catch (error) {
          return handleResult(err(normalizeError(error)));
        }
      }
    );
  • Zod schema defining the input parameters for the mouse tool: coordinates (x,y), optional button and action, and tabId.
    export const mouseSchema = z.object({
      x: z.number().describe('X coordinate'),
      y: z.number().describe('Y coordinate'),
      button: z.enum(['left', 'right', 'middle']).optional().default('left'),
      action: z.enum(['move', 'click', 'down', 'up']).optional().default('click').describe('Mouse action to perform'),
      tabId: tabIdSchema,
    });
  • The core handler logic for the mouse tool, which gets the page for the tab, determines button and action, and dispatches to Puppeteer's mouse API based on the action type.
    async ({ x, y, button, action, tabId }) => {
      const pageResult = await getPageForOperation(tabId);
      if (!pageResult.success) {
        return handleResult(pageResult);
      }
    
      const page = pageResult.data;
      const mouseButton = (button ?? 'left') as MouseButton;
      const mouseAction = (action ?? 'click') as MouseAction;
    
      try {
        switch (mouseAction) {
          case 'move':
            await page.mouse.move(x, y);
            break;
          case 'click':
            await page.mouse.click(x, y, { button: mouseButton });
            break;
          case 'down':
            await page.mouse.move(x, y);
            await page.mouse.down({ button: mouseButton });
            break;
          case 'up':
            await page.mouse.move(x, y);
            await page.mouse.up({ button: mouseButton });
            break;
        }
    
        return handleResult(ok({
          action: mouseAction,
          x,
          y,
          button: mouseButton,
        }));
      } catch (error) {
        return handleResult(err(normalizeError(error)));
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Perform mouse actions' implies interaction with the UI, it doesn't specify whether this requires focus on a specific window/tab, potential side effects (e.g., triggering events), or error conditions. The description is too vague for a tool that manipulates user interface 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 that directly states the tool's function without unnecessary words. It's front-loaded with the core purpose, making it easy to parse quickly, though its brevity contributes to gaps in other dimensions.

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 a mouse interaction tool with 5 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain return values, error handling, coordinate systems, or how it integrates with sibling tools (e.g., 'click' vs. 'mouse' with action='click'), leaving critical gaps for an AI agent to use it effectively.

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?

Schema description coverage is 80%, providing a solid baseline. The description adds minimal value beyond the schema—it mentions 'specific coordinates' (implied by x and y parameters) and 'mouse actions' (implied by the action parameter), but doesn't clarify coordinate systems (e.g., screen vs. viewport), action sequences, or tab context. This meets the baseline for high schema coverage.

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 'Perform mouse actions at specific coordinates' clearly states the verb ('perform mouse actions') and resource ('at specific coordinates'), making the purpose understandable. However, it doesn't distinguish this tool from sibling tools like 'click' or 'hover', which also involve mouse interactions, leaving some ambiguity about its specific role.

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 like 'click' or 'hover'. It lacks context about scenarios where this tool is preferred, prerequisites, or exclusions, leaving the agent to infer usage from the tool name and parameters 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/andytango/puppeteer-mcp'

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