An agent that runs Kaio
The Hermes Agent example runs an agent as a stack. This one turns it around: the agent connects to Kaio’s MCP server and looks after the host it runs on, answering “what is broken” from a chat and, once it has earned it, applying the updates itself.
It needs Kaio behind a proxy that names its callers, so the agent has a credential and a level of its own instead of sharing yours.
1. Give the agent a credential
Section titled “1. Give the agent a credential”Start from SSO for people, a credential for machines:
a second name served by the proxy, where each machine logs in with Basic auth
and gets a group named after it. The agent line of that basic_auth block is
this agent’s:
openssl rand -hex 32 > agent.passwordcaddy hash-password --plaintext "$(cat agent.password)"On Kaio, map the agent’s group to read and set the MCP ceiling:
KAIO_GROUPS_READ=kaio-viewers,machine-agentKAIO_MCP=writeKAIO_MCP_ALLOWED_HOSTS=kaio-api.example.netKAIO_MCP=write is the most any caller can reach through /mcp, and the
agent’s group keeps it at read for now. Nobody reaches the destructive tools
this way.
Check the credential before handing it over:
KAIO_ADDR="https://agent:$(cat agent.password)@kaio-api.example.net" kaio-cli whoami2. Point Hermes at Kaio
Section titled “2. Point Hermes at Kaio”Hermes reads its MCP servers from config.yaml in its data volume. Build the
header, then open a shell in the Hermes container:
printf 'agent:%s' "$(cat agent.password)" | base64 -w0kaio-cli container shell <hermes-container>cat >> /opt/data/config.yaml <<'EOF'mcp_servers: kaio: url: "https://kaio-api.example.net/mcp" headers: Authorization: "Basic YWdlbnQ6..." tools: include: - kaio_overview - kaio_stack - kaio_stack_compose - kaio_stack_versions - kaio_stack_plan - kaio_logs - kaio_images - kaio_image_vulnerabilitiesEOFIf config.yaml already has an mcp_servers: key, add kaio under it rather
than appending a second one. The gateway watches the file and connects new
servers by itself, within about a minute; the tools appear to the agent as
mcp_kaio_kaio_overview and so on.
tools.include is the agent’s side of the ladder: Kaio decides what the
credential may call, and the list decides what Hermes even offers the model.
3. Ask it things
Section titled “3. Ask it things”From Telegram, Discord or whatever the gateway answers on:
- Which stacks are not fully up, and why?
kaio_overview, thenkaio_logson the stack it names. - Which images have critical CVEs, and which stacks use them?
kaio_images, thenkaio_image_vulnerabilities. - What changed in the blog stack since last week?
kaio_stack_versionsandkaio_stack_composeon two versions.
None of these can change anything: at read, no tool in the agent’s list
writes, and Kaio would refuse one that did.
4. Let it act
Section titled “4. Let it act”When the answers have been right for long enough, move the agent’s group up a rung and widen its list to the tools you want it to use:
KAIO_GROUPS_WRITE=kaio-devs,machine-ci,machine-agent tools: include: - kaio_overview - kaio_stack - kaio_stack_versions - kaio_stack_plan - kaio_logs - kaio_stack_check_updates - kaio_stack_update - kaio_stack_rollback - kaio_scanLeaving kaio_stack_deploy out is deliberate. It refuses a file asking for the
socket or privileged: true until the agent repeats the call with
accept_risks, but an agent can repeat a call, so it is still the one write
tool to grant last. An update pulls the images a stack already names,
and a rollback goes back to a version a person deployed.
Now check the stacks for updates, show me what each would change, and apply
the ones that are only a patch release is a task the agent can carry out:
kaio_stack_plan lays out each update before it runs, and kaio_stack_update
with wait: true answers only once the stack is up again, putting back the
images it ran before when it does not get there.
The agent is not alone on the host: you deploy, and so does CI. Two changes to
one stack never run at once, the second is refused with code busy and the
agent tries again later. And a rollback given the expected_version the agent
read is refused with version_moved when someone deployed in between, so it
reads the stack again instead of undoing a deploy it never saw.
5. Read what it did
Section titled “5. Read what it did”Every write call lands in the audit log
under the agent’s name, refused ones included:
kaio-cli audit --limit 50To take it back: drop machine-agent from KAIO_GROUPS_WRITE, or delete its
line in the proxy to cut it off entirely. Nothing on the agent’s side has to
change for either to hold.
Kaio, built by Régis Gaidot