Skip to content
Kaiov0.8.0

Pi

An agent that runs Kaio is a gateway that lives on the host and answers from a chat. Pi is the other kind: a coding agent in your terminal, started when you need it, gone when you close it. It speaks MCP out of the box, so it reaches Kaio the same way, with a credential and a level of its own instead of yours.

It needs Kaio behind a proxy that names its callers, as in SSO for people, a credential for machines.

Add a pi line to the basic_auth block of the machine name, next to ci and agent:

Terminal window
openssl rand -hex 32 > pi.password
caddy hash-password --plaintext "$(cat pi.password)"
/etc/caddy/Caddyfile
basic_auth {
ci $2a$14$8rC1sKpQ2mWdF4yT6uVbXeJ9nL0pR3hG5kD7fA1cZ8oY2vB6mN4qS
agent $2a$14$Q1c9kPz7mN3vB5xR8tY2uW4eL6oA0sD3fG5hJ7kL9zX1cV3bN5mQ2
pi $2a$14$...
}

The proxy hands it the group machine-pi. Map that group to read:

/etc/kaio/kaio.env
KAIO_GROUPS_READ=kaio-viewers,machine-agent,machine-pi
KAIO_MCP=write
KAIO_MCP_ALLOWED_HOSTS=kaio-api.example.net

Check it before handing it over:

Terminal window
KAIO_ADDR="https://pi:$(cat pi.password)@kaio-api.example.net" kaio-cli whoami

Install Pi on your workstation, sign in to a model provider with /login or ANTHROPIC_API_KEY, then keep the credential in an environment variable:

Terminal window
curl -fsSL https://pi.dev/install.sh | sh
export KAIO_PI_AUTH="$(printf 'pi:%s' "$(cat pi.password)" | base64 -w0)"

Pi reads its MCP servers from ~/.pi/agent/mcp.json, and expands ${NAME} in a header from the environment, so the file itself holds no secret:

~/.pi/agent/mcp.json
{
"mcpServers": {
"kaio": {
"url": "https://kaio-api.example.net/mcp",
"headers": { "Authorization": "Basic ${KAIO_PI_AUTH}" },
"description": "The Docker host: stacks, logs, images, CVEs, versions",
"exposure": "direct"
}
}
}

exposure: direct declares each Kaio tool to the model like a built-in one, which suits a server with a few dozen tools at most. Check the connection without starting a session:

Terminal window
pi mcp list
kaio: connected, 11 tools (direct, global)
https://kaio-api.example.net/mcp
tools: kaio_image_vulnerabilities, kaio_images, kaio_logs, kaio_networks, kaio_nodes, kaio_overview, kaio_stack, kaio_stack_compose, kaio_stack_plan, kaio_stack_versions, kaio_volumes

The model sees them as mcp__kaio__kaio_overview and so on. Kaio does not list a rung the credential was not granted, so nothing that writes shows up.

Pi starts with read, bash, edit and write. With bash, the agent can run anything your shell can, kaio-cli with your own KAIO_ADDR included, and the level of its credential stops meaning much. When the task is the host, start it with Kaio’s tools and nothing else:

Terminal window
pi --tools 'mcp__kaio__*'

A --tools entry starting with mcp__ makes the list an allowlist for MCP tools too, so this session holds Kaio’s tools alone: no shell, no file on your disk.

  • Which stacks are not fully up, and why? kaio_overview, then kaio_logs on the stack it names.
  • Which images have critical CVEs, and which stacks use them? kaio_images, then kaio_image_vulnerabilities.
  • Diff the blog stack’s last two versions. kaio_stack_versions, then kaio_stack_compose on each.

Pi has no plan mode and no sub-agents, and asks before nothing: it runs the tool it picks. At read that costs nothing, since no tool it can see writes.

pi -p runs a prompt, prints the final answer and exits, which makes the same question a cron job. Cron’s PATH rarely holds Pi, so give its full path, as command -v pi prints it:

crontab -e
KAIO_PI_AUTH=cGk6...
ANTHROPIC_API_KEY=sk-ant-...
PI=/home/you/.local/bin/pi
0 7 * * 1-5 $PI mcp list >/dev/null && $PI -p --model anthropic/claude-sonnet-5-5 --tools 'mcp__kaio__*' "Report on the Docker host in ten lines: stacks not fully up and why, pending updates, critical CVEs and the stacks they touch. Say so in one line if everything is fine." | mail -s "kaio" ops@example.net

The pi mcp list in front is not decoration. When the server cannot be reached, or KAIO_PI_AUTH is missing, pi -p still runs and exits 0, with no Kaio tool at all, and the model writes a report anyway from nothing. pi mcp list exits 1 instead, so no mail goes out and cron reports the error.

--mode json writes the whole run as JSONL events instead, every tool call and its answer, for a pipeline that wants to keep them.

When its answers have been right for long enough, move machine-pi from KAIO_GROUPS_READ to KAIO_GROUPS_WRITE. Pi then sees the write tools on its next connection, and toolExposure decides which of them it may reach:

~/.pi/agent/mcp.json
{
"mcpServers": {
"kaio": {
"url": "https://kaio-api.example.net/mcp",
"headers": { "Authorization": "Basic ${KAIO_PI_AUTH}" },
"exposure": "direct",
"toolExposure": {
"kaio_stack_deploy": "hidden",
"kaio_stack_copy": "hidden",
"kaio_stack_env": "hidden",
"kaio_stack_apply": "hidden"
}
}
}
}

That leaves updates, rollbacks, restarts and scans, and keeps out every tool that brings up a Compose file the agent wrote. hidden is Pi’s side of the ladder, the way tools.include is for Hermes: Kaio decides what the credential may call, Pi what the model is even offered.

Now check every stack for updates, show me what each would change, and apply the patch releases is a task Pi carries out, and it fits in a pi -p too: kaio_stack_plan lays out each update first, and kaio_stack_update with wait: true answers only once the stack is up and healthy again, and puts back the images it ran before when it does not get there.

Every write call lands in the audit log under pi, refused ones included:

Terminal window
kaio-cli audit --limit 50

To take it back, move machine-pi back to KAIO_GROUPS_READ, or delete its line in the proxy to cut it off. Nothing on your workstation has to change for either to hold.

Kaio, built by Régis Gaidot