Skip to main content
Glama
mcp-ht-better-hyperv

mcp-ht-better-hyperv

by HuanTian3365

hyperv_mouse

Sends mouse moves, clicks, drags and scrolls into a running Hyper-V guest via the synthetic mouse, requiring no guest OS cooperation or credentials. Works only in basic sessions.

Instructions

Move, click, drag or scroll the mouse inside a running Hyper-V guest, using the hypervisor's synthetic mouse (Msvm_SyntheticMouse). No guest OS cooperation and no credential are needed; the VM only has to be Running. BASIC SESSION ONLY: synthetic mouse events reach a basic session, but not an Enhanced Session Mode (RDP / HvSocket) connection — the click is silently dropped there. The tool therefore refuses to run when Get-VM reports EnhancedSessionTransportType = HvSocket, and when that property cannot be read it falls back to a black-frame probe (non-zero Msvm_VideoHead resolution but a near-black screen) and refuses with the same explanation. Disconnect the enhanced session (switch vmconnect back to a basic session) and retry. Coordinates are guest pixels of the guest's CURRENT resolution with the origin at the top-left (read from Msvm_VideoHead). Valid x is 0..width-1 and y is 0..height-1; out-of-range values are rejected as INVALID_ARGUMENT after the resolution is read, never clamped. action=click moves the pointer first, then calls ClickButton; count=2 is a double click (two ClickButton calls about 100 ms apart). action=drag presses the button at x,y, moves through five interpolated points and releases at toX,toY, pausing briefly on the end point before release. action=scroll moves to x,y and calls SetScrollPosition with delta; -120 is approximately two lines, so delta is approximate and its exact effect is guest- and application-specific. settleMs (default 250) is the pause after the action, before the call returns. The result text states what was done, the target coordinates, the guest resolution, the detected session type and the observed elapsed time. Errors: VM_NOT_FOUND, VM_NOT_RUNNING — the VM must be Running; HYPERV_UNAVAILABLE when the per-VM mouse device or the resolution cannot be resolved; INVALID_ARGUMENT for bad arguments or out-of-range coordinates; GUEST_ERROR when an enhanced session (or a suspected one) was detected. This tool is not concurrency safe: it is serialized with other guest input, screenshots and lifecycle calls.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "vm": "<vm>",
      "action": "<action>"
    },
    "name": "hyperv_mouse"
  }
}

Input Schema

NameRequiredDescriptionDefault
xNoTarget horizontal guest pixel (origin top-left). For drag this is the start point. Must be 0..width-1 of the guest's current resolution.
yNoTarget vertical guest pixel (origin top-left). For drag this is the start point. Must be 0..height-1 of the guest's current resolution.
vmYesName of the Hyper-V virtual machine, as shown by hyperv_vm_list.
toXNoDrag end horizontal pixel. Required when action=drag.
toYNoDrag end vertical pixel. Required when action=drag.
countNoNumber of clicks for action=click. Default 1; 2 means double click.
deltaNoScroll delta for action=scroll; negative scrolls down. -120 is about two lines, so the value is an approximation.
actionYesmove = position the pointer; click = click count times with button; drag = press at x,y and release at toX,toY; scroll = wheel delta at x,y.
buttonNoMouse button for click and drag. Default left.
settleMsNoPause in milliseconds after the action. Default 250.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.5/5.0
Behavior4/5

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

No annotations are supplied, so the description carries the full behavioral burden, and it does so thoroughly: no guest cooperation or credentials, out-of-range coordinates rejected rather than clamped, the black-frame probe heuristic, the ~100 ms double-click timing, drag interpolation, and the full error taxonomy. It stops short of only minor details such as the exact result string format and whether it returns before or after settleMs in edge cases.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose is front-loaded and nearly every sentence carries information, but it is delivered as one dense block of prose with no breaks between the session-mode rule, coordinate rules, action semantics, result format, error list and concurrency note. An agent must parse a wall of text to extract the operational constraints, and a few clauses (e.g., repeating the black-frame probe condition) could be tightened.

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

Completeness5/5

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

For a 10-parameter, no-output-schema input tool this is essentially complete: preconditions, session-type detection and refusal, coordinate domain, per-action semantics, settle timing, result contents, named error codes, and concurrency serialization behavior are all present. Nothing an agent needs in order to invoke it correctly or interpret failure is missing.

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?

Schema coverage is 100%, but the description still adds real meaning beyond it: coordinate origin and the non-clamping rejection rule, count=2 as two ClickButton calls ~100 ms apart, drag as five interpolated points with a pause before release, delta's approximate -120 ≈ two lines caveat, and settleMs as a post-action pause. Slightly redundant with the schema's own wording in places, but materially additive.

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?

Opens with a specific verb set (move, click, drag, scroll) and a precise resource (the mouse inside a running Hyper-V guest via Msvm_SyntheticMouse). That clearly distinguishes it from hyperv_keyboard and the lifecycle siblings without needing their schemas.

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

Usage Guidelines5/5

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

Explicitly states the precondition (VM must be Running), the hard exclusion (Enhanced Session Mode / HvSocket connections silently drop events), the detection fallbacks, and the remedy ('Disconnect the enhanced session and retry'). Both when-to-use and when-not-to-use are covered.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.