hyperv_vm_screenshot
Capture the current screen of a running Hyper-V VM as a PNG, returning the image and file path, with optional region cropping and a custom save location.
Instructions
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.
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>"
},
"name": "hyperv_vm_screenshot"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vm | Yes | Name of the Hyper-V virtual machine, as shown by hyperv_vm_list. | |
| region | No | Optional crop rectangle in guest pixels, origin at the top-left of the guest's current resolution. It must fit inside that resolution: x2 > x1, y2 > y1, x2 <= width, y2 <= height. Out-of-range values are an error, never clamped. | |
| savePath | No | Where to write the PNG. Absolute path only, no directory restriction. A directory (or a path without an extension) gets the generated file name <vm>-<yyyyMMdd-HHmmss>.png; a path ending in .png is used as-is and overwritten. Any other extension is an error. Defaults to <dataDir>/screenshots/. |