Skip to main content
Glama
beekamai
by beekamai

cursor_info

Retrieves the current mouse cursor coordinates, the active window title, and the window title under the cursor to provide context about the user's desktop focus.

Instructions

Return the current mouse cursor position, the foreground window title, and the title of the window directly under the cursor (Windows only; other platforms report position only when available).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • CursorInfo interface defining the shape returned by cursor_info: x, y, monitor, foregroundWindow, windowUnderCursor.
    export interface CursorInfo {
      x: number;
      y: number;
      monitor?: number;
      foregroundWindow?: string;
      /** Title of the window under the cursor when available. */
      windowUnderCursor?: string;
    }
  • getCursorInfo() - main handler that dispatches to Windows-specific implementation or returns a stub on other platforms.
    export async function getCursorInfo(): Promise<CursorInfo> {
      if (process.platform === "win32") {
        return getCursorInfoWindows();
      }
      /* On other platforms we keep a stub - position lookup needs platform-specific
       * code that is out of scope for the first release. Callers should treat the
       * absence of x/y as "unknown". */
      return { x: -1, y: -1 };
    }
  • getCursorInfoWindows() - PowerShell-based Windows implementation that gets cursor position, foreground window title, and window under cursor via Win32 APIs.
    async function getCursorInfoWindows(): Promise<CursorInfo> {
      const ps = `
    Add-Type -AssemblyName System.Windows.Forms
    Add-Type -TypeDefinition @"
    using System;
    using System.Runtime.InteropServices;
    using System.Text;
    public class W {
      [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow();
      [DllImport("user32.dll")] public static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
      [DllImport("user32.dll")] public static extern IntPtr WindowFromPoint(POINT p);
      [DllImport("user32.dll")] public static extern IntPtr GetAncestor(IntPtr hWnd, uint flags);
      [StructLayout(LayoutKind.Sequential)] public struct POINT { public int x; public int y; }
    }
    "@
    $pos = [System.Windows.Forms.Cursor]::Position
    $fg = [W]::GetForegroundWindow()
    $sb = New-Object System.Text.StringBuilder 512
    [void][W]::GetWindowText($fg, $sb, 512)
    $fgTitle = $sb.ToString()
    $pt = New-Object W+POINT
    $pt.x = $pos.X
    $pt.y = $pos.Y
    $wnd = [W]::WindowFromPoint($pt)
    $root = [W]::GetAncestor($wnd, 2)
    $sb2 = New-Object System.Text.StringBuilder 512
    [void][W]::GetWindowText($root, $sb2, 512)
    $undTitle = $sb2.ToString()
    $out = @{ x = $pos.X; y = $pos.Y; fg = $fgTitle; under = $undTitle }
    $out | ConvertTo-Json -Compress
    `;
      return new Promise((resolve, reject) => {
        const child = spawn(
          "powershell.exe",
          ["-NoProfile", "-NonInteractive", "-Command", ps],
          { windowsHide: true }
        );
        let out = "";
        let err = "";
        child.stdout.on("data", (d) => (out += d.toString()));
        child.stderr.on("data", (d) => (err += d.toString()));
        child.on("error", reject);
        child.on("close", (code) => {
          if (code !== 0) return reject(new Error(`cursor probe failed: ${err}`));
          try {
            const j = JSON.parse(out.trim());
            resolve({
              x: j.x,
              y: j.y,
              foregroundWindow: j.fg || undefined,
              windowUnderCursor: j.under || undefined,
            });
          } catch (e) {
            reject(new Error(`cursor probe parse error: ${(e as Error).message} :: ${out}`));
          }
        });
      });
    }
  • src/index.ts:72-79 (registration)
    Tool registration for cursor_info in the ListToolsRequestSchema handler: defines the tool name, description, and empty input schema.
    {
      name: "cursor_info",
      description:
        "Return the current mouse cursor position, the foreground window title, and the " +
        "title of the window directly under the cursor (Windows only; other platforms " +
        "report position only when available).",
      inputSchema: { type: "object", properties: {} },
    },
  • src/index.ts:185-188 (registration)
    CallToolRequestSchema handler dispatches 'cursor_info' case: calls getCursorInfo() and returns the result as text.
    case "cursor_info": {
      const ci = await getCursorInfo();
      return text(ci);
    }
Behavior4/5

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

Discloses platform-dependent behavior and what data is returned. No annotations provided, so description carries full burden; it does so adequately.

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?

Single sentence with front-loaded main purpose and parenthetical details. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers main functionality and platform constraints. Lacks explicit return format (e.g., coordinates as numbers), but tool is simple; no output schema but description is sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

No parameters exist; schema coverage is 100%. Description adds no param info but none needed. Baseline for 0 params is 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states it returns mouse cursor position, foreground window title, and title under cursor. Includes platform-specific behavior. Distinct from sibling screenshot/stream tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides platform constraints (Windows only for some fields; others report position only). Implicitly differentiates from siblings by describing unique functionality.

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/beekamai/mcp-screenshot'

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