ProxmoxMCP-Plus includes tools that require direct CLI access to the Proxmox host via SSH to interact with LXC containers:
execute_container_command: Run shell commands inside a running LXC container.update_container_ssh_keys: Inject or replace SSH authorized_keys for therootuser inside a container.
Under the hood, both tools use pct exec, the official Proxmox CLI tool for executing commands
within container namespaces.
This feature requires a one-time SSH setup on your Proxmox nodes. It is entirely opt-in: if
you do not add an ssh section to your MCP config, these tools are not registered and will not
appear in the MCP tool list. Everything else continues to work normally.
Both SSH-backed tools run in a dedicated pool of at most four concurrent workers, so a slow command does not block MCP tool discovery or unrelated requests. Target selection, read-only restrictions and command/approval policy still apply.
Each command uses GNU coreutils /usr/bin/timeout inside the container:
60 seconds, then TERM to the command process group, followed by KILL after a
5-second grace period. Install coreutils in minimal images before using these
tools; a missing watchdog is an execution error, never an unbounded fallback.
Passwordless sudo is still required; sudo -n fails instead of prompting.
Paramiko drains stdout and stderr together with a 70-second wall-clock read limit; OpenSSH has a 70-second local process limit. SSH setup and API discovery have their own timeouts, so total request duration can be longer than 70 seconds. Closing a connection does not undo changes. Deliberately detached processes or commands escaping their process group are outside the watchdog's guarantee. This tool is intended for bounded foreground commands, not background job management.
execute_container_command returns success: false, code: COMMAND_TIMEOUT,
timed_out: true, exit_code: 124 and any captured output on a timeout
(including remote watchdog exit statuses 124/137). Inspect partial state before
retrying package installations or other mutations. SSH-key updates report an
operation failure if either of their commands fails.
The Proxmox REST API exposes a QEMU guest agent endpoint that lets you run commands inside virtual machines:
POST /nodes/{node}/qemu/{vmid}/agent/exec
LXC containers have no equivalent REST endpoint. pct exec is the official mechanism, and it is a
CLI tool that runs on the Proxmox host itself. It uses lxc-attach internally to enter the
container's Linux namespaces.
In a multi-node cluster, containers can be on any node. The MCP server resolves which node a container is on through the Proxmox API first, then SSHes to that node, so the correct node is targeted automatically.
execute_container_command and update_container_ssh_keys are only registered when an ssh
section is present in the config.
No ssh section -> no tool registration -> no SSH connection -> no container command execution.
Rather than granting the MCP server SSH access as root, create a dedicated unprivileged
mcp-agent user on each Proxmox node. This user:
- Has no password
- Authenticates only through an SSH key
- Has passwordless
sudoaccess scoped exclusively to/usr/sbin/pct exec
The sudoers rule that enforces this is:
mcp-agent ALL=(root) NOPASSWD: /usr/sbin/pct exec *
This means mcp-agent can run pct exec as root, which is required by lxc-attach, but cannot
run other commands through sudo.
The Paramiko execution path uses strict host key checking. Unknown hosts are rejected unless the
host key is present in the system known_hosts file or in the configured known_hosts_file.
strict_host_key_checking=false does not make Paramiko auto-trust unknown hosts. If you need host
key behavior controlled by your local OpenSSH client configuration, set prefer_ssh_client=true.
Container command execution also passes through the configured command_policy. The default mode is
deny_all, so commands are blocked unless you either:
- Add matching
allow_patterns, or - Set
command_policy.modetoaudit_onlyfor a trusted lab environment
Production deployments should prefer an allowlist.
Proxmox VE is Debian-based but may not have sudo installed. On each Proxmox node, as root:
apt update
apt install sudoOn each Proxmox node, as root:
useradd -m -s /bin/bash mcp-agent
passwd -l mcp-agent-m creates /home/mcp-agent, which is needed for authorized_keys. The locked password keeps
the account key-only.
On each Proxmox node, as root:
echo 'mcp-agent ALL=(root) NOPASSWD: /usr/sbin/pct exec *' > /etc/sudoers.d/mcp-agent
chmod 440 /etc/sudoers.d/mcp-agent
visudo -c -f /etc/sudoers.d/mcp-agentExpected validation output:
/etc/sudoers.d/mcp-agent: parsed OK
Run this as the same OS user that starts the MCP server:
ssh-keygen -t ed25519 -f ~/.ssh/proxmox_key -N ""
chmod 600 ~/.ssh/proxmox_key
cat ~/.ssh/proxmox_key.pubCopy the full public key line that starts with ssh-ed25519.
On each Proxmox node, as root:
mkdir -p /home/mcp-agent/.ssh
chmod 700 /home/mcp-agent/.ssh
echo "ssh-ed25519 AAAA...your key here..." >> /home/mcp-agent/.ssh/authorized_keys
chmod 600 /home/mcp-agent/.ssh/authorized_keys
chown -R mcp-agent:mcp-agent /home/mcp-agent/.sshThe permissions matter. sshd can ignore authorized_keys if the directory or file is writable by
the wrong user.
From the machine running ProxmoxMCP-Plus:
ssh-keyscan -H pve1 >> ~/.ssh/known_hosts
ssh-keyscan -H pve2 >> ~/.ssh/known_hostsReplace pve1 and pve2 with your node names or IP addresses. If node names do not resolve from
the MCP host, use the IPs here and configure host_overrides in the next step.
From the machine running ProxmoxMCP-Plus:
ssh -i ~/.ssh/proxmox_key mcp-agent@pve1 "echo SSH OK"
ssh -i ~/.ssh/proxmox_key mcp-agent@pve1 "sudo /usr/sbin/pct exec 101 -- uname -a"Replace 101 with a real running container ID. Both commands should complete without a password
prompt.
Add this to proxmox-config/config.json:
{
"ssh": {
"user": "mcp-agent",
"port": 22,
"key_file": "/home/<your-user>/.ssh/proxmox_key",
"use_sudo": true,
"known_hosts_file": "/home/<your-user>/.ssh/known_hosts",
"strict_host_key_checking": true
}
}If Proxmox node names do not resolve from the MCP host, add host_overrides:
{
"ssh": {
"user": "mcp-agent",
"port": 22,
"key_file": "/home/<your-user>/.ssh/proxmox_key",
"use_sudo": true,
"known_hosts_file": "/home/<your-user>/.ssh/known_hosts",
"host_overrides": {
"pve1": "192.168.1.101",
"pve2": "192.168.1.102"
}
}
}The host_overrides keys must match the node names returned by get_nodes.
With the default command_policy.mode=deny_all, add allow patterns for the commands you want agents
to run. Example:
{
"command_policy": {
"mode": "allowlist",
"allow_patterns": [
"^uname(?:\\s+-a)?$",
"^df\\s+-h$",
"^cat\\s+/etc/os-release$",
"^systemctl\\s+status\\s+[a-zA-Z0-9_.@-]+$"
],
"deny_patterns": [
"(^|\\s)rm\\s+-rf(\\s|$)",
":\\(\\)\\{:\\|:\\&\\};:"
],
"require_approval_token": false,
"approval_token": null
}
}For a private lab, you can temporarily use:
{
"command_policy": {
"mode": "audit_only"
}
}Restart ProxmoxMCP-Plus after changing the config. The startup log should include:
Container command execution enabled (SSH configured for user 'mcp-agent')
Then verify that the tool list includes:
execute_container_commandupdate_container_ssh_keys
When execute_container_command is called with a selector such as 101:
- The server resolves the selector to a container and node through the Proxmox API.
- It verifies the container is running.
- It checks the configured command policy.
- It opens an SSH connection to the node, or to the configured
host_overridesvalue. - It runs
sudo /usr/sbin/pct exec 101 -- sh -c '<command>'. - It returns stdout, stderr, and exit code.
Successful response shape:
{
"success": true,
"output": "Linux ct-101 ...",
"error": "",
"exit_code": 0
}When update_container_ssh_keys is called:
- The server identifies the target node and verifies the container is running.
- It SSHes to the Proxmox host.
- It executes
pct execcommands to create/root/.ssh, writeauthorized_keys, and set file permissions. - It returns a success or failure payload.
update_container_ssh_keys is also classified as a high-risk operation. If command_policy.high_risk_require_approval_token=true, callers must pass approval_token.
Most likely causes:
- The running config has no
sshsection. - The MCP server was not restarted after editing
config.json. - The client cached an older tool list.
Check the server log for either:
Container command execution enabled (SSH configured for user 'mcp-agent')
Container command execution disabled (no [ssh] section in config)
Paramiko does not automatically inherit every OpenSSH behavior. Use one of these fixes:
- Add the node host key to the system
known_hosts. - Set
ssh.known_hosts_fileto the file that contains the host key. - Set
ssh.prefer_ssh_client=trueif you need your local OpenSSH config to control host key behavior.
Run this manually from the MCP host:
ssh -i ~/.ssh/proxmox_key mcp-agent@pve1 "sudo -n /usr/sbin/pct exec 101 -- true"If it fails, re-check /etc/sudoers.d/mcp-agent on that Proxmox node.
If the response mentions CMD_POLICY_NOT_ALLOWLISTED, your command_policy blocked the command.
Add a precise allow pattern or use audit_only only in a trusted lab.
pct exec only works for running containers. Start the container first, or select a different
container.
If get_nodes returns node names such as pve1, but DNS does not resolve those names from the MCP
host, configure ssh.host_overrides with node-name-to-IP mappings.