mcp-ht-better-hyperv
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| HYPERV_KEEP_SCRIPTS | No | Set to true to keep temporary scripts that may contain plaintext guest credentials in the system temporary directory. | |
| MCP_HTTP_AUTH_TOKEN | No | Authentication token for the HTTP transport. Set this to a long random string when starting with --transport http. |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
Operate Hyper-V virtual machines on this Windows host. Start with hyperv_vm_list: it reports each VM's power state, generation, CPU, memory, guest heartbeat and whether a credential is stored. Guest commands via hyperv_exec need a live guest OS and a stored credential; listing, lifecycle and hyperv_host_exec do not. A powered-on VM whose heartbeat is NoContact cannot accept PowerShell Direct, and that failure keeps the credential because it is not a password problem. hyperv_vm_screenshot captures the guest's current screen as a PNG without needing a guest OS or a credential; a black image usually means an enhanced session is active or the guest display is asleep.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| hyperv_vm_listA | List Hyper-V virtual machines on this machine with their state, generation, CPU, memory, guest heartbeat, and whether a guest credential is already stored for them. Start here: it tells you which VM to target and whether you need to call hyperv_credential_set first. The HEARTBEAT column is what decides whether hyperv_exec can reach the guest at all: a powered-on VM with no operating system installed, or one still booting or crashed, reports NoContact and cannot accept a PowerShell Direct connection, no matter what credential is stored. Listing, start/stop/restart and hyperv_host_exec never need a guest OS. |
| hyperv_vm_screenshotA | Capture the current screen of a running Hyper-V virtual machine, save it as a PNG, and return both the absolute file path and the image itself. The frame comes from the hypervisor's synthetic video device (GetVirtualSystemThumbnailImage), so it is exactly the guest's current resolution and is decoded from an RGB565 buffer: expect slight color banding compared with a real screenshot, and expect large resolutions (4K) to be noticeably slower to capture and convert. No guest OS, credential or PowerShell Direct is involved; the VM only has to be Running. A NEARLY BLACK IMAGE IS USUALLY NOT A FAILURE: while an Enhanced Session Mode connection is active, or when no basic session is connected at all, the framebuffer the hypervisor exposes is simply empty and the PNG comes out black. A guest whose display has gone to sleep looks the same until something wakes it, and the result text says so when it happens. region is an optional crop rectangle in guest pixels with the origin at the top-left; it must fit inside the current resolution, and an out-of-range region is rejected as INVALID_ARGUMENT instead of being silently clamped. savePath takes any absolute path: an existing directory, or a path with no extension, receives the generated name -.png, while a path ending in .png is used verbatim and overwritten. Any other extension, or a relative path, is rejected as INVALID_ARGUMENT. Without savePath the file goes to /screenshots/, where dataDir is DATA_DIR or the default ~/.mcp/data/dsh-ht-better-hyperv. An existing generated name gets a numeric suffix instead of being overwritten. Errors: VM_NOT_FOUND for an unknown name, VM_NOT_RUNNING when the VM is not Running, HYPERV_UNAVAILABLE when no resolution can be read, and GUEST_ERROR when the capture API returns a non-zero code — the code and its meaning are in the message, and 32775 (Invalid state for this operation) most often means the requested size is larger than the guest's current resolution. |
| hyperv_vm_startA | Start a Hyper-V virtual machine and wait until it is Running. |
| hyperv_vm_stopA | Stop a Hyper-V virtual machine and wait until it is Off. mode=shutdown (default) closes down cleanly; mode=turnoff cuts power and loses unsaved guest data. |
| hyperv_vm_restartB | Restart a Hyper-V virtual machine: stop, wait for Off, start, wait for Running. |
| hyperv_host_execA | Run a PowerShell script on the HOST machine with Hyper-V administrator rights (elevated). Use this instead of a plain shell tool for any Hyper-V work that needs host administrator access, which a non-elevated shell answers with "Access denied": Get-VMHost*, Get-VMHostPartitionableGpu / Get-VMGpuPartitionAdapter / Add-VMGpuPartitionAdapter, Get-VMProcessor / Set-VMProcessor, Get-VMNetworkAdapter*, Mount-VHD / Dismount-VHD / Optimize-VHD / Resize-VHD / Compare-VHD, Import-VM / Export-VM / Move-VM, Get-VMSnapshot / Checkpoint-VM, Get-VMFirmware / Set-VMFirmware, Get-VMHost*, and reading C:\ProgramData\Microsoft\Windows\Hyper-V (including .vmcx/.vmrs files). Runs on the host, not inside a guest — use hyperv_exec for commands inside a VM. stdout and stderr are merged and returned verbatim, with the elevated process exit code. Elevation is silent when UAC allows it; otherwise the user sees a UAC prompt, and declining it is reported as an error instead of being retried. SCOPE — this tool is for Hyper-V and its virtual machines only. It is not a general administrator shell: do not use it for unrelated system changes, software installation, service or registry edits, reading or writing files the caller could reach by itself, or any script that has nothing to do with Hyper-V or its VMs. If a command needs no host administrator rights, or is not about Hyper-V and its virtual machines, use the ordinary shell tool instead. This boundary is an agreement with the user, not a technical control: nothing in the code rejects a command outside Hyper-V, so keeping to it is the caller's responsibility. |
| hyperv_execA | Run a PowerShell command inside a Hyper-V guest as its administrator, over PowerShell Direct. Returns the guest output verbatim plus the guest exit code. Requires a stored credential (hyperv_credential_set). REQUIRES A LIVE GUEST OPERATING SYSTEM — a powered-on VM is not enough: PowerShell Direct has no channel into a guest that has not booted a Windows OS with the Hyper-V integration services running. If the VM is off it is started automatically and waited for, and then the guest heartbeat is waited on; when no guest ever answers, the tool reports GUEST_UNAVAILABLE and KEEPS the stored credential, because that failure is not a password problem. Use hyperv_vm_list to see each VM's heartbeat, and hyperv_host_exec for host-side work that needs no guest at all. The working directory defaults to whatever the remote session inherits, which is stable but not obvious; set workingDirectory when the script uses relative paths, and the resolved directory is reported back with the output. timeoutMs bounds only the host-side wait: a command already running inside the guest keeps running after this call times out, because the guest is a separate machine. hyperv_host_exec behaves differently — it owns a timer inside the elevated process and does stop its script. It is a Session 0 background session: commands run, but GUI windows it opens are not visible to the user. |
| hyperv_mouseA | 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. |
| hyperv_keyboardA | Type text, press a single key or press a key combination inside a running Hyper-V guest. BASIC SESSION ONLY: Msvm_Keyboard events reach a basic session, but not an Enhanced Session Mode (RDP / HvSocket) connection, where they are silently dropped. The tool 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. The clipboard route described below runs entirely inside the guest and is not affected. ROUTING: text that is pure ASCII is typed with Msvm_Keyboard.TypeText; tabs and line breaks in it become real Tab and Enter key presses. text containing ANY non-ASCII character is pasted: the host backs up the guest clipboard with Get-Clipboard, sets the new text, sends Ctrl+V and then restores the original clipboard. That route needs a stored credential (hyperv_credential_set; otherwise NEED_CREDENTIAL) and a logged-on interactive desktop session in the guest (otherwise a clear GUEST_ERROR), and it uses a temporary scheduled task with LogonType = Interactive running powershell.exe -NoProfile -WindowStyle Hidden -STA -EncodedCommand (never -File, which returns -196608 on this guest without executing anything). The temporary task and temp files are always removed. Only TEXT on the clipboard is backed up and restored: if the original clipboard held an image or files, that content is not preserved. SendKeys targets the foreground window, so a higher-integrity foreground window blocks the paste via UIPI. key accepts Enter, Esc, Tab, Backspace, Delete, Insert, Home, End, PageUp, PageDown, arrows (Left/Up/Right/Down), Space, F1-F12, Shift/Ctrl/Alt/Win on their own (useful to wake a blank guest display), a single letter or digit, and common punctuation on a US layout. combo is a modifier combination such as Ctrl+V or Ctrl+Shift+Esc; modifiers are pressed in order and released in reverse. provide at least one of text, key, combo (otherwise INVALID_ARGUMENT). Actions run in the order text, key, combo, and submit presses Enter last when true (default false). settleMs (default 250) is the pause after each action. Errors: VM_NOT_FOUND, VM_NOT_RUNNING, NEED_CREDENTIAL, GUEST_ERROR (enhanced session or no interactive session), INVALID_ARGUMENT for bad arguments. This tool is not concurrency safe: it is serialized with other guest input, screenshots and lifecycle calls. |
| hyperv_sequenceA | Run a whole sequence of mouse and keyboard actions in one call, to save the round trips between the agent and this tool. Each elevated call costs several seconds of process startup, so consecutive actions are compiled into a single guest-side script and executed there; only a text step containing non-ASCII characters breaks the sequence into another segment, because that step has to go through the guest clipboard (see hyperv_keyboard). Step types and their fields: click {x, y, button?, count?}; type {text} — routed exactly like hyperv_keyboard (ASCII via TypeText, non-ASCII via clipboard paste, which needs a credential and a logged-on interactive guest session); key {key}; combo {combo}; scroll {x, y, delta}; drag {x, y, toX, toY, button?}; wait {ms}; waitForChange {timeoutMs = 5000, threshold = 0.01, region?} — captures a baseline frame, then re-captures every 500 ms (plus capture time) and succeeds as soon as the ratio of differing pixels exceeds threshold; on timeout the whole sequence fails; region limits the comparison to a rectangle {x1,y1,x2,y2} in guest pixels; screenshot {savePath?} — saves a PNG using the same naming rules and default directory as hyperv_vm_screenshot. Each step is followed by defaultSettleMs (default 250), which a step can override with its own settleMs; a wait step sleeps ms and then the usual settle applies as well. BASIC SESSION ONLY, like hyperv_mouse and hyperv_keyboard: an Enhanced Session Mode (RDP / HvSocket) connection receives no synthetic input, so the sequence refuses to run when that transport is detected instead of silently doing nothing. FAILURE: the first failing step stops everything. The error names the step number, the step type and the reason, and a screenshot of that moment is saved; a waitForChange timeout is reported as TIMEOUT, out-of-range coordinates as INVALID_ARGUMENT. SUCCESS: the result lists how many steps ran, a summary line per step and the path of the last PNG. Coordinates are guest pixels of the current resolution with the origin at the top-left and are validated against Msvm_VideoHead after it is read. This tool is not concurrency safe: it is serialized with other guest input, screenshots and lifecycle calls. |
| hyperv_credential_setA | Store the guest administrator username and password for a Hyper-V virtual machine. Omit password (or pass an empty string) when the guest account has no password. The password is never returned or logged by this tool; it is written to this plugin's local configuration file under the harness home, so it survives restarts without touching the shared credential store. Ask the user once, store it, and reuse it — do not re-ask on every run. |
| hyperv_credential_clearA | Delete the stored guest credential for a Hyper-V virtual machine. Use it when rotating credentials or when a stored credential is known to be wrong. |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 12 tools
The set is largely distinct: lifecycle (list/start/stop/restart), guest input (mouse/keyboard/sequence), screenshots, credentials, and execution are separate concerns. The only pair an agent could confuse is hyperv_exec (inside guest) vs hyperv_host_exec (host, elevated), and hyperv_sequence vs hyperv_mouse/hyperv_keyboard, but the descriptions make the boundaries explicit and hard to misselect.
All names are lowercase snake_case with a consistent hyperv_ prefix, and the dominant hyperv_vm_<action> and hyperv_credential_<action> patterns are predictable. Minor deviations exist (hyperv_host_exec and hyperv_exec place the verb last, and exec vs host_exec differ by one word), but nothing is ambiguous or chaotic.
12 tools is well within a healthy range and each one earns its place: VM lifecycle, guest execution, input primitives, batching, screenshot, and credential management. There is no filler or trivially redundant tool, and the batching tool (hyperv_sequence) exists for a real round-trip cost rather than convenience alone.
Core workflows are covered end to end: discover VMs, power cycle them, get credentials, run commands, see the screen, and drive input. Gaps like VM creation/deletion, snapshots/checkpoints, and guest file transfer are not native tools, but the elevated hyperv_host_exec escape hatch explicitly covers checkpoints, import/export, and host-side Hyper-V cmdlets, so agents can work around them.