PiKVM Control
Use this skill when the user wants to interact with a PiKVM-managed machine or PiKVM hardware.
What this skill covers
- - Authentication against PiKVM HTTP API
- Device info and health checks
- ATX power state and button actions
- HID typing, key presses, shortcuts, and mouse actions
- Streamer status, screenshots, and OCR
- Mass Storage Device (virtual media) status and image handling
- PiKVM Switch active-port and port-level ATX control
Read references/api-reference.md for endpoint details and parameter notes.
Safety rules
Treat these actions as high impact and get explicit user approval before performing them unless the user already clearly requested the exact action in the current conversation:
- - Power off, hard power off, or reset
- Clicking ATX power/reset buttons
- Connecting or disconnecting virtual media
- Uploading, removing, or replacing MSD images
- Switching active KVM ports in environments that may affect another machine
- Sending destructive keyboard shortcuts or arbitrary typed commands
For read-only requests, proceed without extra confirmation.
Environment and auth
Prefer these environment variables when running the script:
- -
PIKVM_URL — base URL like https://pikvm.local or INLINECODE2 - INLINECODE3
- INLINECODE4
- INLINECODE5 —
true or INLINECODE7 - INLINECODE8 —
true to use HTTP Basic Auth instead of X-KVMD-User / INLINECODE11
Notes:
- - PiKVM requires authentication for all API calls.
- For single-request auth, PiKVM supports either
X-KVMD-User and X-KVMD-Passwd headers, or HTTP Basic Auth. - If 2FA is enabled, append the current TOTP code directly to the password with no spaces.
Default workflow
- 1. Validate that
PIKVM_URL, PIKVM_USER, and PIKVM_PASS are available. - Start with a read-only request such as
info, atx-state, streamer-state, msd-state, or switch-state. - Summarize the current state before taking action.
- For write operations, restate the exact action being taken.
- After any state-changing action, re-read the relevant state endpoint and report the result.
Script
Use scripts/pikvm_api.py.
Common examples:
CODEBLOCK0
When to use which operation
Read-only inspection
- -
info → general PiKVM/device metadata - INLINECODE24 → current power LED/busy state
- INLINECODE25 → stream and capture health
- INLINECODE26 → mounted image and storage availability
- INLINECODE27 → PiKVM Switch overview
Input control
- -
hid-print for plain text entry - INLINECODE29 for combinations like Ctrl+Alt+Delete
- INLINECODE30 for a single key press
- INLINECODE31 /
mouse-move for pointer actions
Screen capture
- -
snapshot to save a JPEG locally - INLINECODE34 to extract visible text from the host screen
- Use OCR bounding box flags when only part of the screen matters
Power and media
- -
atx-power for requested state changes (on, off, off_hard, reset_hard) - INLINECODE40 to emulate case buttons
- INLINECODE41 to choose image and drive flags
- INLINECODE42 to attach or detach the virtual drive from the host
Switch environments
- -
switch-active to select a target port - INLINECODE44 for port-specific power control
Reporting style
When using this skill in an agent workflow:
- - State the PiKVM host being targeted.
- State whether SSL verification is enabled.
- For each action, show the endpoint-level intent in plain English.
- After changes, include the returned PiKVM state that matters most.
- Do not expose passwords, TOTP values, or session cookies.
PiKVM 控制
当用户想要与 PiKVM 管理的机器或 PiKVM 硬件进行交互时,使用此技能。
本技能涵盖范围
- - PiKVM HTTP API 身份验证
- 设备信息与健康检查
- ATX 电源状态与按钮操作
- HID 输入、按键、快捷键与鼠标操作
- 流媒体状态、屏幕截图与 OCR
- 大容量存储设备(虚拟介质)状态与镜像处理
- PiKVM 切换器活动端口与端口级 ATX 控制
端点详情与参数说明请阅读 references/api-reference.md。
安全规则
将以下操作视为高风险操作,除非用户已在当前对话中明确请求具体操作,否则在执行前必须获得用户明确批准:
- - 关机、强制关机或重启
- 点击 ATX 电源/重置按钮
- 连接或断开虚拟介质
- 上传、移除或替换 MSD 镜像
- 在可能影响其他机器的环境中切换活动 KVM 端口
- 发送破坏性键盘快捷键或任意键入命令
对于只读请求,无需额外确认即可执行。
环境与认证
运行脚本时优先使用以下环境变量:
- - PIKVMURL — 基础 URL,如 https://pikvm.local 或 https://10.0.0.7
- PIKVMUSER
- PIKVMPASS
- PIKVMVERIFYSSL — true 或 false
- PIKVMUSEBASICAUTH — 设为 true 以使用 HTTP 基本认证替代 X-KVMD-User / X-KVMD-Passwd
注意:
- - PiKVM 要求所有 API 调用均需认证。
- 对于单次请求认证,PiKVM 支持使用 X-KVMD-User 和 X-KVMD-Passwd 标头,或 HTTP 基本认证。
- 如果启用了双因素认证,请将当前 TOTP 代码直接附加到密码末尾,无需空格。
默认工作流程
- 1. 验证 PIKVMURL、PIKVMUSER 和 PIKVM_PASS 是否可用。
- 从只读请求开始,例如 info、atx-state、streamer-state、msd-state 或 switch-state。
- 在采取操作前总结当前状态。
- 对于写操作,重新说明正在执行的具体操作。
- 执行任何状态更改操作后,重新读取相关状态端点并报告结果。
脚本
使用 scripts/pikvm_api.py。
常见示例:
bash
python scripts/pikvm_api.py info
python scripts/pikvm_api.py atx-state
python scripts/pikvm_api.py atx-power --action on
python scripts/pikvm_api.py atx-click --button reset
python scripts/pikvm_api.py hid-print --text reboot\n --slow
python scripts/pikvm_api.py hid-shortcut --keys ControlLeft,AltLeft,Delete
python scripts/pikvm_api.py snapshot --save-path /tmp/pikvm.jpg
python scripts/pikvm_api.py ocr --langs eng
python scripts/pikvm_api.py msd-state
python scripts/pikvm_api.py msd-set --image debian.iso --cdrom true --rw false
python scripts/pikvm_api.py msd-connect --connected true
python scripts/pikvm_api.py switch-active --port 2
python scripts/pikvmapi.py switch-atx-power --port 2 --action resethard
何时使用何种操作
只读检查
- - info → 常规 PiKVM/设备元数据
- atx-state → 当前电源 LED/忙碌状态
- streamer-state → 流媒体与采集健康状态
- msd-state → 已挂载镜像与存储可用性
- switch-state → PiKVM 切换器概览
输入控制
- - hid-print 用于纯文本输入
- hid-shortcut 用于组合键,如 Ctrl+Alt+Delete
- hid-key 用于单个按键
- mouse-button / mouse-move 用于指针操作
屏幕捕获
- - snapshot 用于本地保存 JPEG 文件
- ocr 用于提取主机屏幕上的可见文本
- 当仅需屏幕部分区域时,使用 OCR 边界框标志
电源与介质
- - atx-power 用于请求的状态变更(on、off、offhard、resethard)
- atx-click 用于模拟机箱按钮
- msd-set 用于选择镜像和驱动器标志
- msd-connect 用于从主机连接或断开虚拟驱动器
切换器环境
- - switch-active 用于选择目标端口
- switch-atx-power 用于端口特定的电源控制
报告风格
在代理工作流中使用此技能时:
- - 说明目标 PiKVM 主机。
- 说明是否启用了 SSL 验证。
- 对于每个操作,用通俗英语说明端点级别的意图。
- 变更后,包含最相关的返回 PiKVM 状态。
- 不要暴露密码、TOTP 值或会话 Cookie。