ai-bench-psu
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
ai-bench-psu
Experimental. Use at your own risk. This software drives a laboratory power supply that can deliver 60 V or 20 A, enough to start fires, destroy equipment and injure people. Read the code yourself before you point it at real hardware. A software bug, a wrong setting, an agent misreading a tool, a sensor reading wrong, or a firmware quirk can energise the output or change its voltage or current. You are entirely responsible for any damage, injury, data loss or downtime that results from using it. The authors and contributors accept no liability.
Headless control of one bench power supply and the temperature sensors next to it, from a small Linux host, for people and for AI agents. Everything goes through drivers chosen in the config: one PSU driver per daemon, plus any number of sensor drivers (a device may carry several sensors).
Daemon (
bench-psud): the only process that owns the supply's port and the sensors. Polls the supply at 4 Hz, reads each sensor at its own interval, serves a JSON API, a status page and an MCP endpoint, keeps Wh / Ah counters, logs every state change and a periodic sample as JSON lines, and runs the opt-in temperature interlocks, which switch the output off (never on).CLI (
benchctl): talks to the daemon;--directopens the supply when the daemon is stopped.kiprimis the same program under its earlier name.Live display (
benchtop, optional service): big volts and amps, a V/A chart that goes to a fine scale when the values barely move, a temperature chart with the interlock limits, on a terminal or a monitor plugged into the host. It reads the daemon's API only.Drivers:
owon-scpi(OWON SPE/SPS-family SCPI over USB serial; tested on a Kiprim DC620S),temper(PCsensor-type TEMPer USB thermometers over hidraw), and the simulatedsimandsim-tempused by the tests andbench-psud --simulate. Out-of-tree drivers load bymodule:Class. See docs/adding-a-driver.md.
Standard-library Python ≥ 3.11 only: no pyserial, no hidapi, nothing to install on the host but
python3.
Prior art
Several MCP servers for bench supplies existed when this was written (checked 2026-11-27), each for one vendor: labmcp-bench-psu (Rigol, Siglent and Aim-TTi), an MCP server for the OWON SPE6103, siglent-mcp (with gated output), and servers for the Rigol DP832 and the RS3005P. None of them combines one daemon that owns the port, setters verified by readback, host ceilings, a write token, temperature interlocks and a live display, which is what this project is for.
Related MCP server: devpsu-mcp
Disclaimer
Kiprim, OWON and PCsensor are trademarks of their respective owners. This project is an independent effort and is not affiliated with, endorsed by, or connected with Kiprim, Shenzhen Kepurui Business Co., OWON, Lilliput or PCsensor. The names are used only to identify the hardware this software works with.
No warranty. Provided AS IS under the Apache License 2.0 (see LICENSE); liability is disclaimed to the fullest extent permitted by law.
Tested on one supply. A Kiprim DC620S, firmware V2.3.0. Other firmware and other models in the family may answer differently; run
benchctl probefirst.The TEMPer driver is written from the published protocol and has not yet been checked against a stick of our own; see docs/drivers/temper.md.
Assume write access is dangerous. Anyone or anything holding the token (including an AI agent connected over MCP) can switch the output on and change the setpoints within the host ceilings.
An interlock is not a battery protection system. It acts on a temperature probe that lags the cell, through a USB stick, a daemon and a supply that can each fail. It is one more layer, not the only one.
Safety rules
These hold for the software and for the people using it.
The daemon never switches the output on by itself. It switches the output off only on a clean stop with
output_off_on_exit, or when a configured interlock trips. Starting, stopping, restarting or reconnecting sends queries only; a crash leaves the supply as it was.output_off_on_exit(config, default off) switches the output off when the daemon stops cleanly. An unexpected error in the worker is logged and the port reopened; if a thread dies anyway the process exits non-zero and systemd restarts it (queries only again).Identity first. Until the driver has confirmed the device's identity (owon-scpi:
*IDN?matchesexpect_idn_prefix, defaultKIPRIM,DC620S, and, if set,expect_serial), nothing else is sent to the port.Host ceilings (
max_voltage,max_current, default 15 V / 10 A) are checked before anything is sent, and must fit inside the hardware range the driver declares. The output is not switched on while a setpoint (perhaps set from the front panel) is above a ceiling.Protection limits keep a margin. The voltage setpoint must stay at least
ovp_margin(0.1 V) below OVP and the current setpoint at leastocp_margin(0.1 A) below OCP. A request that would break that is refused, not reordered. Switching the output on is refused too while front-panel settings break it.Current and limit changes cycle the output. With the output on, a change to the current setpoint, OVP or OCP goes output OFF → write → output ON, for drivers that ask for it (owon-scpi does). Why: the two drivers that run this firmware family on a bench (lab_Kiprim, kibarra-esp32) report that OCP and the
CURR:LIMvalue are one register and that writing it with the output on and current flowing near the new value tripped OCP. On a DC620S (V2.3.0)CURRandCURR:LIMread back separately and a liveCURRwrite with open terminals leftCURR:LIMalone, but nothing has been tested with current flowing, so the cycle stays the default.--live/"live": trueskips it on explicit request. If a write fails mid-cycle, the output is left off. Voltage setpoint changes apply live.One process owns the port (
flock+TIOCEXCLon the tty,flockon the hidraw node); the CLI's--directmode fails while the daemon runs.Writes need a bearer token, generated on the host by the installer and readable only by root and the service. Without a token file, writes are disabled. Reads are open.
Never connect a battery to the supply directly. The DC620S manual says the supply is not designed for direct battery charging: it has no reverse-current blocking and no remote sense, and its protections act on the supply, not the cells. Battery work needs a blocking element, a fuse, an independent meter and a dead-man disconnect, none of which this project provides.
Never raise OVP to silence an OVP trip.
*RSTis never sent by this software.The probe cleans up. If a probe fails part-way, it still sends
SYST:LOCK OFF,SYST:LOCandOUTP OFFfor whatever it had turned on.Test setters, and interlocks, with open terminals or a resistive load, never a battery.
Interlocks latch. A tripped interlock holds the output off and refuses output-on; after the condition clears it stays latched until a person resets it, and a reset is refused while the condition still holds. A reset switches nothing on. With interlocks configured,
--directrefuses output-on (only the daemon reads the sensors).
Interlocks
An interlock watches one named temperature channel:
[[interlock]]
name = "pack-temperature"
channel = "pack" # a channel name from a [[sensor]] table
max_c = 45.0 # trip above
min_c = 0.0 # trip below
stale_after = 5.0 # no fresh reading for this long counts as a tripTrip when the channel reads above
max_c, belowmin_c, or has had no fresh reading forstale_afterseconds (sensor unplugged, driver error). If the output is on, the daemon sends output OFF at once through the driver (verified by readback, retried; a failure is logged asinterlock_output_off_failedwith"level": "critical"). While the condition holds, an output switched on at the front panel is switched off again.Latched: output-on is refused (HTTP 409
"kind": "interlock", an MCP error, a CLI error) while the condition holds and afterwards, until someone resets it:benchctl interlock reset,POST /api/interlocks/resetor the MCP toolreset_interlocks. A reset is refused while the condition still holds.At daemon start an interlock is
waiting: output-on is refused until its channel has a first reading, but nothing is switched off beforestale_afterhas passed without one, so a restart with a load running does not drop it because the sensor is slow to answer.An interlock on a channel no
[[sensor]]provides is a config error: the daemon will not start.The supply's own OVP/OCP/OTP and the host ceilings are unchanged and independent of this.
States in the status: waiting, ok, tripped, latched. Journal events: interlock_armed,
interlock_trip, interlock_clear, interlock_reset, interlock_output_off,
interlock_output_off_failed.
Install (Debian 12/13 host)
Needs python3 ≥ 3.11 and nothing else. From a checkout on the host, as root:
install/install.sh install # detects the CH340 tty, writes the udev rule
install/install.sh install --tty /dev/ttyUSB0 # if more than one CH340 is present
install/install.sh install --allow-from 192.0.2.0/24 # also open the port in nftables (see below)
install/install.sh install --display # also the live display on the host's monitor (tty8)
install/install.sh upgrade # same as install; keeps config, token, udev port and display
install/install.sh upgrade --no-restart # install, but leave a running bench-psud on its old code
install/install.sh uninstall [--purge]Or from a workstation, deploying the committed HEAD over SSH:
scripts/deploy.sh <ssh-host> installWhat it installs:
Path | What |
| the package |
| launchers ( |
| the CLI under its earlier name, for scripts; one notice line on stderr |
| searched for out-of-tree drivers; never written by the installer |
| config, |
| write token, |
|
|
| system user |
| only with |
| the unit, enabled, sandboxed ( |
| only with |
CH340 bridges carry no USB serial number, so the supply is identified by the port it is plugged
into: move it to another USB port and re-run install.sh install --tty /dev/ttyUSBn.
On Debian, remove brltty if it is installed (it grabs CH340 devices).
--allow-from <CIDR> writes /etc/nftables.d/bench-psu.nft (add rule inet filter input … tcp dport <port> accept) and restarts nftables after a syntax check. It assumes an nftables.conf
with an inet filter table, an input chain and include "/etc/nftables.d/*.nft"; on other
firewalls, open the port yourself.
To try the hardware before installing anything, scripts/bundle.py prints a single-file copy
of the CLI that runs from memory:
python3 scripts/bundle.py | ssh <host> python3 - --direct --device /dev/ttyUSB0 probe.
Upgrading from bench-psu 0.2 / 0.3
This project continues bench-psu under a
device-neutral name. install.sh upgrade on a bench-psu host keeps the unit name
(bench-psud), the user, /etc/bench-psu (config and token) and the supply's USB port: it
reads the ID_PATH from 70-kiprim.rules into 70-bench-psu.rules, replaces
kiprim-top.service with benchtop.service on the same console, and installs kiprim as a
compatibility launcher. A config with [serial] is read as [psu] with driver = "owon-scpi".
/api/status keeps every key it had and adds temperatures, sensors and interlocks.
Live display
benchtop (also benchctl top) is a full-screen view for a screen at the bench, in the style of
nvtop: big volts (yellow) and amps (cyan); a chart of both over the last 10 minutes with volts
on the left axis and amps on the right (like the supply's own front screen); a band with output
ON/OFF, CV/CC, the output-on time, power, the OVP/OCP/OTP trip flags and one chip per temperature
channel; then setpoints and protection limits, the Wh / Ah counters and the daemon's link health.
The V/A chart draws the voltage setpoint and the current limit as dotted lines while the output is on, marks each setpoint change with a ▼ on its top border, and has a mode strip under it (CV green, CC amber, output off grey, fault red).
Fine scale: when the measured values on an axis move less than a quarter of its full scale (0 to a round top), that axis spans just the data on round steps, at least 50 mV or 5 mA wide, so a few millivolts or milliamps of drift are visible. The legend says
↕ fine scale V+A, the axis labels gain a digit, and a setpoint line outside the fine range is not drawn.Under each big readout, while the output is on, a trend: the least-squares slope in mV/min and mA/min over the last 10 minutes, restarting when the output goes on or a setpoint changes (it needs 30 s of data first) and cleared when the output goes off.
With sensors configured, a temperature chart under the V/A chart on the same time axis, one line per channel, with each interlock's
max_candmin_cas dashed red lines. Channel chips turn amber within 5 °C of an interlock'smax_cand red when the reading is not fresh or the interlock is tripped or latched. A red INTERLOCK banner says what tripped and how to reset it.+and-change the chart span (1 minute to 6 hours);qquits.
It reads GET /api/status and nothing else: no token, no writes, no device, so it can run
anywhere (BENCH_URL=http://<host>:8100 benchtop). The charts are the display's own memory of
what it has read, so they start empty when the display starts. When the daemon cannot be reached,
a red NO LINK banner says so and the last reading turns red with its time. A red STALE or
NO LINK banner also appears when the daemon itself has had no fresh poll from the supply for
--stale-after seconds (default 3). benchtop --once prints one frame as text and exits 1 when
the reading is not fresh.
install.sh install --display runs it at boot on a local monitor: benchtop.service on virtual
console 8 (--display-vt N for another), outside the login consoles tty1–6, which keep their
prompts (Ctrl+Alt+F1 to log in, Alt+F8 back to the display). It sets the
Lat15-TerminusBold32x16 console font if the distribution has it (120×37 on a 1920×1200
monitor), runs as a dynamic user that may reach only localhost, and systemd restarts it if it
stops. --no-display removes it.
Config
/etc/bench-psu/config.toml, see install/config.toml. Defaults:
Key | Default | Meaning |
|
| the PSU driver; its own options follow in the same section |
|
| stable symlink from the udev rule |
|
| identity required before anything else is sent |
|
| line timing |
|
| seconds between reopen attempts |
| — / — / | one table per sensor device; |
|
| a reading older than this is not |
| — / — / none / none / | see Interlocks |
|
| 4 Hz measurement poll, fixed rate |
|
| no successful poll for this long: link |
|
|
|
|
| full refresh of setpoints and limits |
|
| API, status page, MCP |
|
| optional CIDR allow-list for writes, on top of the token |
|
| extra |
|
| an idle or stalled connection is dropped after this |
|
| MCP endpoint at |
|
| host ceilings for setpoints |
|
| V / A the protection limits must stay above the setpoints |
|
| switch the output off when the daemon stops |
The plain HTTP API carries the token in the clear on the LAN. Put a TLS proxy in front, or use
write_allow_from, if that matters on your network. Every request, read or write, must carry a
Host header that is an IP literal or one of the host's names, and a browser Origin must match
it: that stops a web page from reaching the daemon through DNS rebinding.
HTTP API
Reads are open. Writes are POST with a JSON body and Authorization: Bearer <token>.
Every write response carries ok, result (the read-back values) and the fresh status.
Method and path | Body | Does |
| status page (refreshes every 2 s) | |
| the state document below | |
| 200 while the supply's link is up, 503 otherwise | |
|
| both, at most one output cycle |
|
| voltage setpoint (live) |
|
| current limit (cycles the output if on) |
|
| output on/off |
|
| over-voltage protection limit (cycles the output if on) |
|
| over-current protection limit (cycles the output if on) |
|
| front-panel lock |
|
| the driver's conformance probe |
|
| reset the Wh / Ah counters (sends nothing to the supply) |
|
| reset latched interlocks (refused while a condition holds; switches nothing on) |
Errors: 401/403 auth, 409 conflict with present setpoints, an interlock ("kind": "interlock")
or a refused probe, 422 above a ceiling or the hardware range, 501 the supply has no such
feature, 502 the supply answered ERR or read back a different value, 503 supply not connected
or the wrong device, 504 timeout. On 401/403/422 nothing is sent to the supply; on 409 the
daemon has read the present values (queries) but sent no setter.
/api/status:
{
"time": "2026-11-11T20:00:00.000+00:00",
"identity": {"manufacturer": "KIPRIM", "model": "DC620S", "serial": "…", "firmware": "V2.3.0", "raw": "…"},
"output": true, "mode": "cv", "mode_code": 1,
"setpoints": {"voltage": 13.8, "current": 4.0},
"protection": {"ovp_limit": 63.0, "ocp_limit": 21.0, "ovp_tripped": false, "ocp_tripped": false, "otp_tripped": false},
"measured": {"voltage": 13.8, "current": 0.0, "power": 0.0},
"energy": {"wh": 0.0, "ah": 0.0, "output_on_s": 0.0, "since": "…"},
"front_panel_lock": null,
"link": {"state": "ok", "ok": true, "device": "/dev/kiprim", "age_s": 0.1, "poll_hz": 4.0,
"reconnects": 0, "worker_alive": true, "…": "…"},
"ceilings": {"max_voltage": 15.0, "max_current": 10.0, "ovp_margin": 0.1, "ocp_margin": 0.1},
"warnings": [],
"daemon": {"version": "0.4.0", "started": "…", "output_off_on_exit": false, "writes_enabled": true,
"driver": "owon-scpi"},
"temperatures": {"pack": {"celsius": 24.3, "last_celsius": 24.3, "sensor": "temper", "channel": "probe",
"age_s": 0.4, "ok": true},
"air": {"celsius": 21.0, "last_celsius": 21.0, "sensor": "temper", "channel": "internal",
"age_s": 0.4, "ok": true}},
"sensors": {"temper": {"driver": "temper", "identity": {"firmware": "…", "…": "…"}, "interval": 1.0,
"channels": {"internal": "air", "probe": "pack"},
"link": {"state": "ok", "ok": true, "age_s": 0.4, "last_error": null, "connects": 1}}},
"interlocks": [{"name": "pack-temperature", "state": "ok", "ok": true, "channel": "pack", "max_c": 45.0,
"min_c": 0.0, "stale_after": 5.0, "since": null, "reason": null}]
}mode is standby, cv, cc or fault. A temperature's celsius is null unless the
reading is fresh (ok); last_celsius is the last value read, however old. The document is
shaped for a Home Assistant RESTful sensor (value_template: "{{ value_json.measured.voltage }}"
and so on). tests/test_status_compat.py checks that every key of a bench-psu 0.2.0 status
document is still there.
MCP
POST /mcp is a Model Context Protocol server (Streamable HTTP transport, JSON responses, no SSE
stream), built into the daemon so the one-owner rule still holds. Without the token it offers
only get_status; with Authorization: Bearer <token> it adds set_voltage, set_current,
set_voltage_current, set_output, set_ovp, set_ocp, set_lock, reset_counters,
reset_interlocks and probe, with the same ceilings, rules and interlocks as the HTTP API. A
wrong token is refused (401/403), not quietly treated as read-only. Its server instructions repeat
the safety rules for the agent, including never resetting an interlock unless the human asked
after checking the cause. Tested with the official MCP Python SDK client.
claude mcp add --transport http bench-psu http://<host>:8100/mcp # read-onlyFor read-write, add --header "Authorization: Bearer <token>", taking the token from
/etc/bench-psu/token on the host without echoing it into shared logs.
CLI
benchctl status full state, with temperatures and interlocks
benchctl idn identity string
benchctl set 13.8 4 [--live] voltage and current limit
benchctl volt 12.5 voltage only
benchctl curr 2 [--live] current limit only
benchctl on | off output
benchctl ovp 15 | ocp 5 [--live] protection limits
benchctl reset-counters zero the daemon's Wh / Ah counters
benchctl lock | unlock front panel
benchctl temps temperatures, sensors, interlocks
benchctl interlock [reset] interlock states, or reset latched ones
benchctl watch [-i 1] measurements until Ctrl-C
benchctl top [--window 10m] the live display (same as benchtop); read-only
benchctl probe [--level L] [--markdown]
benchctl --direct status bypass the daemon (it must be stopped)
benchctl --json status JSON outputOn the host as root the CLI reads the token file itself, so ssh <host> benchctl set 13.8 4
works. Elsewhere set BENCH_URL=http://<host>:8100 and BENCH_TOKEN (KIPRIM_URL and
KIPRIM_TOKEN still work). kiprim … is benchctl … with a one-line notice on stderr: same
subcommands, same stdout, same exit codes. It goes away in a later release.
Probe levels (owon-scpi)
benchctl probe runs the driver's protocol table and prints a conformance table. Each level
includes the previous one.
Level | Sends | Needs |
| every query; changes nothing | nothing |
| each setpoint and limit written back with its present value, | output off |
|
| output off; open terminals or a resistive load |
|
| as above |
The command table and what the DC620S answered are in docs/drivers/owon-scpi.md.
Development
uv sync
uv run pytest
uv run bench-psud --simulate --listen 127.0.0.1 --config install/config.toml # simulated supplyCI (GitHub Actions) runs the tests on Python 3.11–3.13 and shellcheck on the shell scripts.
The simulator (ai_bench_psu.drivers.psu.owon_scpi.simulator) models the verified behaviour,
with switches for the unverified quirks (ocp_quirk, three-field MEAS:ALL?, digit OUTP?,
missing MEAS:ALL:INFO?, SYST:LOCK?, dropped replies, readback offsets) and a resistive load.
sim-temp is a thermometer whose values, absence and failures the tests set.
References
OWON SP/SPE/SPS SCPI programming manual (the protocol family)
Wajalot/lab_Kiprim (the OCP-register quirk report)
urwen/temper (MIT; the TEMPer report layouts)
No code was copied from these projects; they informed the command tables, the report layouts and the quirk list.
License
This project is licensed under the Apache License, Version 2.0.
Copyright 2026 TechBlueprints
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for mandates, delegation, policy-gated execution, credential grants, and audit.
QuLab MCP remote server (Streamable HTTP) for computational science and lab tools.
Guarded MCP server for agent-readable business truth, provenance, readiness, and discovery.
An authenticated remote MCP server for user-owned devices and one-shot capability invocation.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceMCP server for programmable bench power supply control, enabling autonomous bootloader-entry probing via precise power cycling and telemetry.1-
- AlicenseAqualityDmaintenanceMCP server for controlling B&K Precision and Manson bench power supplies, enabling voltage/current setting, output switching, and power cycling.83MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for reading and controlling an OWON SPE6103 programmable DC power supply over USB serial, with safety checks and verified SCPI commands.MIT
- FlicenseBqualityBmaintenanceEnables MCP clients to list PD profiles, probe USB-C devices, audit PDOs, read live power telemetry, trigger PD/PPS voltages with safety defaults, and reset to safe 5V. It runs locally over stdio JSON-RPC with strict tool schemas and dry-run defaults for mutating operations.6-