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

mcp-ht-better-hyperv

by HuanTian3365

hyperv_keyboard

Type ASCII text, press single keys, or send key combinations inside a running Hyper-V guest over a basic session. Use it to enter input, trigger shortcuts, or wake a blank guest display.

Instructions

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.

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_keyboard"
  }
}

Input Schema

NameRequiredDescriptionDefault
vmYesName of the Hyper-V virtual machine, as shown by hyperv_vm_list.
keyNoA single key name: Enter, Esc, Tab, Backspace, Delete, Insert, Home, End, PageUp, PageDown, Left/Up/Right/Down, Space, F1-F12, Shift/Ctrl/Alt/Win on their own, a letter or digit, or common punctuation.
textNoText to type. Pure ASCII is typed with TypeText; any non-ASCII character switches the whole string to the clipboard-paste route, which needs a credential and an interactive guest session.
comboNoKey combination such as Ctrl+V or Ctrl+Shift+Esc.
submitNoPress Enter after the text. Default false.
settleMsNoPause in milliseconds after each action. Default 250.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.8/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so thoroughly: enhanced-session silent-drop behavior, the black-frame fallback probe, clipboard backup limitations (images/files lost), UIPI blocking of paste, temporary scheduled-task mechanics and guaranteed cleanup, action ordering, settleMs default, named error codes, and the explicit non-concurrency-safety note. These are exactly the behavioral traits an agent cannot get from schema fields.

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

Conciseness4/5

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

Front-loaded with purpose and routing, and nearly every sentence carries operative detail. It is a dense single block, however, with minor redundancy (the refusal behavior is restated, temp-task details are lengthy), which slightly hurts scanability for such a long definition.

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 six-parameter mutating tool with no annotations and no output schema, the description covers failure modes, prerequisites, side effects, ordering, and concurrency. An agent has everything needed to invoke it correctly or to bail out with the right error expectation.

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%, so the schema already documents each parameter, but the description still adds value: it enumerates the accepted key names and punctuation, explains combo modifier press/release ordering, states actions run in order text-key-combo with submit pressing Enter last, and notes at least one of text/key/combo is required. That is meaning beyond the schema, though some overlaps remain.

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?

States a specific verb set (type text, press key, press combination) and the exact resource (inside a running Hyper-V guest). It is immediately distinguishable from siblings such as hyperv_mouse or hyperv_exec, and the opening sentence tells an agent exactly what the tool will do before any routing detail.

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 routes: pure-ASCII text uses TypeText, any non-ASCII character switches to clipboard paste, and that route requires hyperv_credential_set plus an interactive desktop session. It also names the exact refusal condition (EnhancedSessionTransportType = HvSocket) and what to expect when it occurs, so the agent knows when this tool is the wrong choice.

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