vsphere-console-mcp
# vsphere-console-mcp
<!-- mcp-name: io.github.Razer0028/vsphere-console-mcp -->
**Let an AI agent see and use the console of your VMware vSphere or Proxmox VE VMs — screen, mouse and
keyboard — with nothing installed in the guest.**
[日本語](https://github.com/Razer0028/vsphere-console-mcp/blob/main/README.ja.md)
An [MCP](https://modelcontextprotocol.io) server with one tool, `vm`, that works the way the vSphere Client's
console window or Proxmox's noVNC console does. Because it never touches the guest OS, it reaches the places SSH,
RDP and in-guest agents cannot: sign-in and lock screens, the BIOS/UEFI setup, OS installers, a VM whose network is
down, a Windows VM stuck on a blue screen or "Preparing to configure Windows".
```
You: web-02 stopped answering. Look at its console.
Agent: [vm look web-02] It is in emergency mode: "Give root password for maintenance".
The journal line above says /data failed to mount. Do you want me to log in and check /etc/fstab?
```
It is meant for **an agent working with a person**, not for unattended automation: the person decides, the agent
looks, reads and types. See [Good to know before you use it](#good-to-know-before-you-use-it).
Two commands come with it: `vsphere-console-mcp` for vCenter, and `proxmox-console-mcp` for Proxmox VE.
Both offer the same tool.
## Why this one
- **Zero dependencies.** Python standard library only — no pyVmomi, no `websockets`, no `requests`, no image
library. It speaks vSphere SOAP, the console screenshot endpoint and WebMKS, and the Proxmox API, its console
websocket and the VNC protocol itself, in about 2,500 lines you can read in an afternoon. Installing it pulls in
exactly one package.
- **Least privilege, verified.** On vSphere the service account needs Read-only plus **one** privilege, *Console
interaction*; typing works through the console connection, so it does **not** need
`VirtualMachine.Interact.PutUsbScanCodes`. On Proxmox VE an API token with only `VM.Audit` and `VM.Console` is
enough.
- **No power button.** There is no code to power on/off, reset, snapshot or reconfigure a VM. (Keys still reach the
guest, and `ctrl+alt+delete` reboots a Linux text console, a boot menu or a BIOS screen — see below.)
- **Correct symbols on non-US keyboards.** Keys go as scan codes for the guest's layout (`us`, `jis`), not as
keysyms that the hypervisor would remap as US, so `@ : _ \` arrive as typed.
- **Guardrails on the MCP side too**: an allow-list of VM names, a read-only mode, a JSON audit log that never
records typed text, and a guard that stops retrying a rejected password or API token.
## Use cases
| Situation | What the agent does |
|---|---|
| A VM is unreachable over the network | Reads the console: kernel panic, emergency-mode prompt, full disk, a hung boot; tells you what it sees |
| Incident triage | Screenshots several VMs in turn and summarizes which are at a login prompt and which are stuck |
| Windows VM stuck before sign-in | Reads update/repair screens, sends `ctrl+alt+delete`, walks recovery menus — you approve each step |
| OS installation, first boot, OOBE | Goes through screens that have no network or automation hook yet |
| BIOS / UEFI | Reads firmware screens and changes settings with the keyboard |
| Labs, training, homelabs | Drives disposable VMs end to end, including the part before SSH works |
| Runbooks and tickets | Captures the exact console screen |
## Quick start (vSphere)
### 1. Install
```bash
pipx install git+https://github.com/Razer0028/vsphere-console-mcp
# or: uv tool install git+https://github.com/Razer0028/vsphere-console-mcp
# pip install git+https://github.com/Razer0028/vsphere-console-mcp
```
Or run it without installing: `uvx --from git+https://github.com/Razer0028/vsphere-console-mcp vsphere-console-mcp`.
### 2. Give it an account
Create a dedicated vCenter account with the role in [Permissions](#permissions-for-vcenter-administrators), and
put its details in a file only you can read:
```bash
install -m 600 /dev/null ~/.config/vsphere-console-mcp.env
cat >> ~/.config/vsphere-console-mcp.env <<'EOF'
VSPHERE_SERVER=https://vcenter.example.com
VSPHERE_USER=svc-ai-console@vsphere.local
VSPHERE_PASSWORD=...
EOF
VSPHERE_CREDENTIALS_FILE=~/.config/vsphere-console-mcp.env vsphere-console-mcp check
```
`check` logs in and prints how many VMs the account can use. `vsphere-console-mcp vms` and
`vsphere-console-mcp look <vm> -o screen.png` work from the shell too.
### 3. Add it to your MCP client
**Claude Code**
```bash
claude mcp add vsphere-console -e VSPHERE_CREDENTIALS_FILE=$HOME/.config/vsphere-console-mcp.env -- vsphere-console-mcp
```
**Claude Desktop, Cursor, VS Code and other clients** (`mcpServers` JSON):
```json
{
"mcpServers": {
"vsphere-console": {
"command": "vsphere-console-mcp",
"env": { "VSPHERE_CREDENTIALS_FILE": "/home/me/.config/vsphere-console-mcp.env" }
}
}
}
```
If only another machine can reach vCenter, run the server there over SSH:
`"command": "ssh", "args": ["jump-host", "vsphere-console-mcp"]`.
**Docker**: build the image from this repository (`docker build -t vsphere-console-mcp .`). The image runs as an
unprivileged user, so run it as your own user to let it read the credentials file you created with mode 600, and
give it a lock directory you own (create it first):
```bash
mkdir -p ~/.cache/vsphere-console-mcp
docker run -i --rm --user "$(id -u):$(id -g)" \
-v ~/.config/vsphere-console-mcp.env:/run/creds.env:ro -e VSPHERE_CREDENTIALS_FILE=/run/creds.env \
-v ~/.cache/vsphere-console-mcp:/lock vsphere-console-mcp
```
For Proxmox, add `--backend proxmox` after the image name, pass the file as `PROXMOX_CREDENTIALS_FILE`, and mount
the CA file too: `-v ~/.config/pve-root-ca.pem:/run/pve-root-ca.pem:ro -e PROXMOX_CA_FILE=/run/pve-root-ca.pem`
(variables in the environment win over the host path in the file). Every container that uses the same account
should share the lock directory; see [Accounts and lockout](#accounts-and-lockout).
## Quick start (Proxmox VE)
Install the same package (above); it also installs the `proxmox-console-mcp` command.
On a Proxmox node, create a role with the two privileges the tool needs, a user without a password, and an API
token, and grant the role on the VMs the agent may use (`/vms` for all of them, or a pool, `/pool/<name>`):
```bash
pveum role add AIConsole --privs "VM.Audit,VM.Console"
pveum user add ai-console@pve --comment "AI agent: VM consoles only"
pveum acl modify /vms --users ai-console@pve --roles AIConsole
pveum user token add ai-console@pve mcp --privsep 1 # prints the secret once
pveum acl modify /vms --tokens 'ai-console@pve!mcp' --roles AIConsole
```
With privilege separation (`--privsep 1`) the token gets only what both the user and the token are granted, so the
role is granted to both. Then, on the machine that runs the MCP server, copy the cluster's CA certificate
(`/etc/pve/pve-root-ca.pem` on any node) and write the settings:
```bash
install -m 600 /dev/null ~/.config/proxmox-console-mcp.env
cat >> ~/.config/proxmox-console-mcp.env <<'EOF'
PROXMOX_SERVER=https://pve.example.com:8006
PROXMOX_TOKEN_ID=ai-console@pve!mcp
PROXMOX_TOKEN_SECRET=...
PROXMOX_CA_FILE=/home/me/.config/pve-root-ca.pem
EOF
PROXMOX_CREDENTIALS_FILE=~/.config/proxmox-console-mcp.env proxmox-console-mcp check
claude mcp add proxmox-console -e PROXMOX_CREDENTIALS_FILE=$HOME/.config/proxmox-console-mcp.env -- proxmox-console-mcp
```
Any node of a cluster can be `PROXMOX_SERVER`: it reaches VMs on the other nodes itself. If the node serves its own
certificate (ACME or an uploaded one) instead of the cluster's, leave `PROXMOX_CA_FILE` unset and the system CAs are
used. Instead of a CA you can pin the certificate with `PROXMOX_FINGERPRINT` (its SHA-256 fingerprint, as shown
under *Certificates* in the node's settings); a pin has to be updated whenever the certificate is renewed.
## The `vm` tool
| action | What it does |
|---|---|
| `vms` | Lists the VMs the account can see (and the allow-list permits): power state, and guest OS and IP address (vSphere) or node (Proxmox) |
| `look` | Returns a PNG of the screen (scaled to `max_width`, default 1568 px) and the real screen size |
| `click` / `move` / `drag` / `scroll` | Mouse at `rx`,`ry` (0–1000 across and down; survives resolution changes) or `x`,`y` (real screen pixels, as reported by `look` — not pixels of the scaled picture) |
| `type` | Types text with scan codes for the guest's `layout` (`us` or `jis`). If any character is not on that keyboard, nothing is sent |
| `key` | Key combinations: `"ctrl+alt+delete"`, `"win+r"`, `"alt+f4"`, `"tab tab enter"` |
`vm` names a VM by its name, or by its id — the managed object id (`vm-123`) or IP address on vSphere, the numeric
VM id (`vmid`) on Proxmox — and is required on every call except `vms`. There is no default VM, so an agent cannot
act on a machine nobody named. `then_look: true` returns a fresh screenshot after an input action; if only that
picture fails, the result still says that the input was sent.
## Configuration
All settings are environment variables. `VSPHERE_CREDENTIALS_FILE` may hold any of them as `KEY=VALUE` lines;
variables set in the environment win.
| Variable | Default | Meaning |
|---|---|---|
| `VSPHERE_SERVER` | — | vCenter address, e.g. `https://vcenter.example.com` (a port may follow; IPv6 in brackets) |
| `VSPHERE_USER` / `VSPHERE_PASSWORD` | — | The account. Prefer the credentials file to putting the password in client config |
| `VSPHERE_CREDENTIALS_FILE` | — | Path to a `KEY=VALUE` file with the settings above |
| `VSPHERE_CA_FILE` | system CAs | CA bundle for vCenter's certificate (e.g. your VMCA root certificate) |
| `VSPHERE_INSECURE` | off | `1` skips verification of vCenter's certificate. For labs only |
| `VSPHERE_VM_ALLOW` | all | Comma-separated name patterns (`lab-*,web-0?`); other VMs are hidden and refused |
| `VSPHERE_READ_ONLY` | off | `1` offers only `vms` and `look`; input actions are not advertised to the client |
| `VSPHERE_KEYBOARD` | `us` | Default guest keyboard layout: `us` or `jis` (the caller can override per call) |
| `VSPHERE_AUDIT_LOG` | off | File to append a JSON line per call to (`-` = stderr) |
| `VSPHERE_LOCKOUT_MINUTES` | `15` | After vCenter rejects the password, do not try again for this long (`0` = never pause) |
| `VSPHERE_LOCK_DIR` | `~/.cache/vsphere-console-mcp` | Where the login-failure mark is kept |
| `VSPHERE_TIMEOUT` | `20` | Seconds per request |
vCenter's certificate is verified unless `VSPHERE_INSECURE=1`. The certificate of each ESXi host (used for
keyboard and mouse input) is always checked against the SHA-1 or SHA-256 thumbprint that vCenter puts in the
WebMKS ticket, independently of `VSPHERE_INSECURE`.
**Proxmox VE** (`proxmox-console-mcp`, or `vsphere-console-mcp --backend proxmox`) reads the same settings with
the prefix `PROXMOX_` instead of `VSPHERE_` (`PROXMOX_VM_ALLOW`, `PROXMOX_READ_ONLY`, `PROXMOX_KEYBOARD`,
`PROXMOX_AUDIT_LOG`, `PROXMOX_CREDENTIALS_FILE`, ...), except for these. In `PROXMOX_VM_ALLOW`, a pattern of digits
(`101`, `10?`) or `qemu/<pattern>` matches the VM id; other patterns match the name. `PROXMOX_TIMEOUT` is at
least 6 seconds, because Proxmox delays every rejected login by 3 seconds.
| Variable | Default | Meaning |
|---|---|---|
| `PROXMOX_SERVER` | — | A node's API address, e.g. `https://pve.example.com:8006` (the port defaults to 8006) |
| `PROXMOX_TOKEN_ID` / `PROXMOX_TOKEN_SECRET` | — | The API token: `user@realm!tokenname` and its secret (there is no password login) |
| `PROXMOX_CA_FILE` | system CAs | The cluster's CA certificate (`/etc/pve/pve-root-ca.pem` on a node) |
| `PROXMOX_FINGERPRINT` | — | Instead of a CA: the SHA-256 fingerprint of the API certificate; any other certificate is refused |
The API certificate is checked (against the CA, or the fingerprint) before the token is sent, unless
`PROXMOX_INSECURE=1`.
## Permissions (for vCenter administrators)
Create a **dedicated service account** for the agent; do not reuse a person's account or an administrator's.
### The role
| Privilege (UI name) | Privilege ID | Needed for |
|---|---|---|
| Read-only (part of every role) | `System.Anonymous`, `System.View`, `System.Read` | Login, listing VMs |
| Virtual machine → Interaction → **Console interaction** | `VirtualMachine.Interact.ConsoleInteract` | `look` (the screen) **and** mouse/keyboard (the WebMKS ticket) |
That is all. Tested with vCenter 8.0.3: a Read-only account lists VMs but gets HTTP 401 for the screen and
`NoPermission (VirtualMachine.Interact.ConsoleInteract)` for input; with Console interaction added, everything
works, without `VirtualMachine.Interact.PutUsbScanCodes`.
With PowerCLI:
```powershell
New-VIRole -Name "AI Console Operator" -Privilege (Get-VIPrivilege -Id System.Anonymous,System.View,System.Read,VirtualMachine.Interact.ConsoleInteract)
New-VIPermission -Entity (Get-Folder "AI-Managed") -Principal "VSPHERE.LOCAL\svc-ai-console" -Role "AI Console Operator" -Propagate:$true
```
With govc:
```bash
govc role.create "AI Console Operator" System.Anonymous System.View System.Read VirtualMachine.Interact.ConsoleInteract
govc permissions.set -principal svc-ai-console@vsphere.local -role "AI Console Operator" -propagate=true /Datacenter/vm/AI-Managed
```
### Scope it
- **Grant the role on a VM folder (or a resource pool), not on the vCenter root.** The account then sees only the
VMs there; nothing else exists for it. This is the main control, and vCenter enforces it.
- vSphere has **no privilege that allows the screen but not input** — Console interaction covers both.
`VSPHERE_READ_ONLY=1` makes this server refuse input, but the server enforces it, not vCenter.
- `VSPHERE_VM_ALLOW` is a second, client-side filter (for example to keep production VMs out of reach even inside a
shared folder). Treat it as defense in depth, not as the boundary.
- If your organization manages permissions through SSO or AD groups, grant the role to a group and put the
service account in it.
- vCenter records the account's logins and console tickets in its events. `VSPHERE_AUDIT_LOG` adds what the agent
looked at and did on the screen.
### Accounts and lockout
vCenter Single Sign-On locks an account after a few failed logins (5 by default). When vCenter **rejects the
password** (`InvalidLogin`), this server writes a mark and does not try that account again for
`VSPHERE_LOCKOUT_MINUTES` (15) — in this process and in every process that shares `VSPHERE_LOCK_DIR` — so a wrong
password in a config file does not lock the service account for everyone. Network errors, timeouts and an
overloaded vCenter do **not** set the mark. In containers, put `VSPHERE_LOCK_DIR` on a shared volume, or each new
container starts without the mark. The server keeps one session for its lifetime and logs out on exit (including
SIGTERM).
## Permissions (for Proxmox VE administrators)
| Privilege | Needed for |
|---|---|
| `VM.Audit` | every action: the server finds a VM in the VM list, which shows only the VMs the token may audit |
| `VM.Console` | `look` **and** mouse/keyboard (the VNC console) |
Tested with Proxmox VE 9.2: a token with only these two privileges, on `/vms`, lists the VMs and uses their
screens. Like vSphere, Proxmox has **no privilege that allows the screen but not input**: `VM.Console` covers both,
and `PROXMOX_READ_ONLY=1` is enforced by this server, not by Proxmox.
- **Grant the role on a pool (`/pool/<name>`) or on single VMs (`/vms/<vmid>`)** rather than on `/` — the token
then sees only those VMs. This is the main control, and Proxmox enforces it. The role needs no `Sys.*`
privilege.
- Use an **API token with privilege separation** (`--privsep 1`) on a user without a password; do not use
`root@pam`. A token can be revoked on its own (`pveum user token remove`).
- Every console connection is a *Console* task (type `vncproxy`, user `<token id>`) in the task list of the node
named in `PROXMOX_SERVER` and in the cluster's task list. For a VM on another node it does not appear in that VM's
own task history. `PROXMOX_AUDIT_LOG` adds what the agent looked at and did on the screen.
- When Proxmox rejects the token (HTTP 401) the server does not try again for `PROXMOX_LOCKOUT_MINUTES` (15), the
same way as for vCenter: failed logins are logged on the node and may be counted by tools such as fail2ban.
## Good to know before you use it
- **Typing into a VM is full control of that VM.** No power privilege does not mean safe: if a shell is open, the
agent can type anything a person could. Keep a human approving input actions (most MCP clients ask before each
tool call; do not auto-approve this tool for production VMs), and scope the account to the VMs it may touch.
- **Prefer the keyboard to the mouse.** Vision models estimate positions in a screenshot only roughly; a click can
land a few pixels off. `tab`, arrow keys, `enter` and shortcuts are deterministic. After a click, `then_look`
and check.
- **Screens move faster than an agent.** Look → think → act takes seconds, so a boot menu with a 3-second timeout
or a progress bar will not wait. This is a tool for screens that wait for input.
- **`layout` must match the guest's current keyboard layout.** Keys are sent as scan codes and the guest maps them.
BIOS screens, installers and Linux text consoles usually use `us` until configured otherwise.
- **Each tool call opens one console connection**, sends all its events (a whole `type` or `drag`), and closes it.
If the connection breaks in the middle, the server releases any keys it was holding; if it cannot, the result
says so, so you can look and press the key once.
- **Screenshots are sent to your AI provider** as part of the conversation. Do not point the agent at consoles that
show data you may not send there.
- Passwords and API token secrets are used only to authenticate and are never put in tool results, errors, the
audit log or command lines; neither are WebMKS tickets, VNC tickets or one-time VNC passwords. The audit log
records the length of typed text, not the text, and records single-character keys as `*`.
## How it works
```
MCP client ──stdio──▶ vsphere-console-mcp
├─ SOAP https://vcenter/sdk Login, CreateContainerView + RetrievePropertiesEx (list),
│ AcquireTicket("webmks")
├─ HTTPS https://vcenter/screen?id=vm the console screenshot (PNG, scaled by vCenter)
└─ WSS wss://esxi/ticket/<ticket> RFB over a websocket: pointer events and VMware's
key-scancode message; connects, sends, closes
MCP client ──stdio──▶ proxmox-console-mcp
├─ HTTPS GET /api2/json/cluster/resources?type=vm the VM list
├─ HTTPS POST /api2/json/nodes/<node>/qemu/<id>/vncproxy a one-time VNC password and ticket
└─ WSS /api2/json/nodes/<node>/qemu/<id>/vncwebsocket RFB to QEMU: VNC Authentication,
the framebuffer (look), pointer
events and QEMU extended key events
```
- The RFB connection asks for a shared session, so it does not disconnect anyone else's console window. It never
changes the guest's resolution. On vSphere it never asks for screen updates; on Proxmox, `look` reads the
framebuffer once, uncompressed, and scales and encodes it as PNG itself.
- Keys go as PC scan codes: VMware's key-scancode message on vSphere, QEMU's extended key event on Proxmox. QEMU
uses the keysym it carries only when the VM has a keyboard layout set (`keyboard:`). On Proxmox the server also
reads the guest's Caps Lock: `type` switches it off while typing and on again, so letters come out as written.
- On Proxmox, mouse actions need an absolute pointing device (the USB tablet Proxmox adds by default, `tablet: 1`).
Without one, a click would land wherever the guest's pointer happens to be, so the server refuses and sends
nothing.
- The screen size can change under you (another console window may resize it). Relative coordinates always point
at the same place; pixel coordinates are mapped from the size seen at the last `look`.
## Limitations
- Keyboard layouts: `us` and `jis`. Other layouts are welcome as pull requests (`keyboard.py`).
- Text that is not on the keyboard (e.g. CJK, emoji) has to be entered with the guest's input method.
- vSphere: tested with vCenter 8.0.3 and Debian and Windows 11 guests. A standalone ESXi host without vCenter is
untested.
- The WebMKS wire protocol (RFB over a websocket, plus VMware's own key-scancode message) is not publicly
documented; VMware only published a JavaScript SDK on top of it. The SOAP calls have been stable for many vSphere
releases, but a future version could change the console protocol; please open an issue with the version if it
stops working.
- Proxmox VE: tested with Proxmox VE 9.2 (QEMU VMs with Debian and VyOS guests). Containers (LXC) are not
supported, nor VMs without a VNC display (`vga: none`); VMs with a serial console as display (`vga: serial0`) are
untested. Mouse actions need the USB tablet (`tablet: 1`, the default). A `look` transfers the whole framebuffer
(about 4 MB for 1280×800), so it takes about a second on a LAN.
## Related projects
This server only does the console. For inventory, power and configuration, use it alongside a management MCP
server — for vSphere for example [InfraMCP/vsphere-mcp-server](https://github.com/InfraMCP/vsphere-mcp-server)
(VMs, hosts, datastores, networks, power on/off) or VMware's own tooling — giving each its own account and role.
## Development
```bash
python -m venv .venv && .venv/bin/pip install -e '.[test]' && .venv/bin/pytest
```
The tests use no network: SOAP, WebMKS, the Proxmox API and QEMU's VNC server are faked.
## License
MIT. See [LICENSE](https://github.com/Razer0028/vsphere-console-mcp/blob/main/LICENSE). VMware, vSphere, vCenter and
ESXi are trademarks of Broadcom; Proxmox is a trademark of Proxmox Server Solutions GmbH. This project is not
affiliated with or endorsed by either. Security issues:
[SECURITY.md](https://github.com/Razer0028/vsphere-console-mcp/blob/main/SECURITY.md).
TDQS
Scored across 1 tool
With a single tool, the real disambiguation burden falls on the action enum, and those actions are well-differentiated: look, click, move, drag, scroll, type and key each map to a distinct console input or observation. Minor overlap exists between move and click (a click inherently moves the pointer) and between type and key, but the descriptions make the intended use of each clear.
Action names are uniformly short lowercase words (vms, look, click, move, drag, scroll, type, key), plus a consistent then_look modifier. The lone tool name 'vm' is a bare noun rather than a verb_noun form, and 'vms'/'look' mix noun and verb styles slightly, but with one tool there is no convention clash to speak of.
Everything lives behind one multiplexed 'vm' tool, which is thin for a surface this broad — an agent must read a long action list and cannot discover capabilities from tool names alone. The multiplexing is a defensible way to avoid power-operation confusion, but 1 tool for the whole vSphere console domain sits at the borderline end of the scale.
The console-interaction domain is well covered: VM enumeration with power/IP metadata, screen capture with scaling, full mouse (click/move/drag/scroll), and keyboard (type/key) input, all with then_look feedback. Gaps are minor and explicitly scoped out (no power on/off or reconfiguration), though clipboard/file transfer and waiting-for-screen-change helpers are absent.