mouse_move
Relocate the mouse cursor to specific pixel coordinates on the screen using absolute x and y values.
Instructions
Move the mouse pointer to absolute screen coordinates (x, y).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | ||
| y | Yes |
Implementation Reference
- server.js:219-229 (handler)The mouseMove function is the handler for the mouse_move tool. It validates x/y are numbers, runs 'xdotool mousemove <x> <y>' via the run() helper, and returns success/failure.
// ─── Tool: mouse_move ───────────────────────────────────────────────────── async function mouseMove(args) { const missing = requireBin('xdotool'); if (missing) return errorResult(missing); if (typeof args.x !== 'number' || typeof args.y !== 'number') { return errorResult('x and y are required numbers'); } const r = await run(BIN.xdotool, ['mousemove', String(args.x), String(args.y)]); if (r.code !== 0) return errorResult(`mouse_move failed: ${r.stderr || r.stdout}`); return textResult({ x: args.x, y: args.y }); } - server.js:439-448 (schema)Input schema registration for mouse_move: defines the name, description, annotations (title, destructiveHint), and inputSchema requiring x (number) and y (number).
{ name: 'mouse_move', description: 'Move the mouse pointer to absolute screen coordinates (x, y).', annotations: { title: 'Move mouse', destructiveHint: true }, inputSchema: { type: 'object', properties: { x: { type: 'number' }, y: { type: 'number' } }, required: ['x', 'y'], }, }, - server.js:553-559 (registration)The HANDLERS object maps tool name 'mouse_move' to the mouseMove handler function, enabling JSON-RPC dispatch when tools/call is invoked with name 'mouse_move'.
const HANDLERS = { screenshot, list_windows: listWindows, focus_window: focusWindow, move_window: moveWindow, close_window: closeWindow, mouse_move: mouseMove, - server.js:57-62 (helper)The requireBin helper checks that xdotool (the binary required by mouse_move) is installed, returning an error message if not found.
function requireBin(name) { if (!BIN[name]) { return `Required system tool "${name}" is not installed. Install with: sudo apt install ${name === 'gnomeShot' ? 'gnome-screenshot' : name === 'xclip' ? 'xclip' : name === 'xdotool' ? 'xdotool' : 'wmctrl'}`; } return null; } - server.js:64-83 (helper)The run helper spawns a child process (xdotool) with given args and returns a promise resolving with code, stdout, stderr. Used by mouseMove to execute the xdotool mousemove command.
function run(cmd, args, opts = {}) { return new Promise((resolve) => { const child = spawn(cmd, args, { stdio: ['pipe', 'pipe', 'pipe'], ...opts }); let out = Buffer.alloc(0); let err = Buffer.alloc(0); child.stdout.on('data', (d) => { out = Buffer.concat([out, d]); }); child.stderr.on('data', (d) => { err = Buffer.concat([err, d]); }); if (opts.stdin !== undefined) { child.stdin.end(opts.stdin); } else { child.stdin.end(); } child.on('error', (e) => resolve({ code: -1, stdout: '', stderr: e.message })); child.on('close', (code) => resolve({ code, stdout: out.toString('utf8'), stderr: err.toString('utf8'), })); }); }