MCP server
Kaio speaks the Model Context Protocol at
/mcp, on the same port as the API and the web UI. An agent that connects there
gets Kaio’s state as tools it can call, so “why is the media stack partial”
becomes something it answers by itself.
The endpoint is off until you turn it on.
Turning it on
Section titled “Turning it on”KAIO_MCP=readKAIO_MCP_ALLOWED_HOSTS=kaio.example.netKAIO_MCP is a ladder, and each rung adds tools to the one below it:
| Value | What the agent can do |
|---|---|
off |
Nothing. /mcp is not routed at all (the default) |
read |
Read the state of the host: no tool changes anything |
write |
Act on stacks and containers: deploy, copy, update, restart, apply |
admin |
The destructive ones too: delete a stack, prune, remove an image. And kaio_audit, which reads who did what |
KAIO_MCP is the ceiling for the server. Each caller then gets the tools of
KAIO_MCP or of its own level,
whichever is lower: an agent the proxy maps to read sees read tools only on a
server set to admin, and a person with admin sees no destructive tool on a
server set to write. Without a proxy that names callers, every caller of the
loopback or of an allowed network has admin, so KAIO_MCP alone decides.
Only the tools a caller reaches appear in its tools/list, so an agent never
proposes what it cannot run, and a rung it was not granted is not merely
refused: it is invisible. A call to a tool above it anyway is refused with an
error naming both levels, and written to the
audit log like every write and
admin tool call. Start at read and move up when an agent has earned it.
The server logs the mode it settled on at startup:
INFO kaio_server: Serving MCP over streamable HTTP at /mcp in read modeConnecting an agent
Section titled “Connecting an agent”claude mcp add --transport http kaio https://kaio.example.net/mcpAny MCP client that speaks streamable HTTP works the same way. To try it by hand, point the inspector at the endpoint:
npx @modelcontextprotocol/inspectorTo give the agent these docs as well, point it at
/llms.txt: it lists the whole documentation as plain text, and a
smaller set for agents and automation alone, MCP, CLI, API, CI and the security
model around them.
Stateless by design
Section titled “Stateless by design”The transport runs with sessions off and JSON responses on. An agent posts a
request and gets an answer: there is no session to establish first, nothing
breaks when the server restarts, and nothing needs sticky routing if you put
several Kaio behind one address. The cost is that a tool cannot stream, which is
why log tools take a bounded tail rather than following.
The tools
Section titled “The tools”Every tool is prefixed kaio_, takes JSON and answers JSON, and carries the
annotations a client uses to decide what needs a human: the read rung is marked
read-only, the write rung is marked non-destructive, the admin rung is marked
destructive.
Reading, in read
Section titled “Reading, in read”| Tool | What it answers |
|---|---|
kaio_overview |
The state of the host in one call: container counts, every stack with its aggregated status, the version it runs, whether an update or an env change is pending, CVE totals, host_access for a stack whose deployed file hands the host to a service, external for one started outside Kaio, and the containers of a stack that are not running |
kaio_stack |
One stack in full: status, deployed version, every container with its image and resource use, the variables it carries, which images are outdated, what the last update check said, and the risks of its deployed file |
kaio_stack_compose |
The Compose file of a stack: the deployed one, or the one a past version holds |
kaio_stack_versions |
The deploy history: every version kept, newest first, with the variables it was deployed with |
kaio_stack_plan |
What a deploy, apply, rollback or update would change, without running it: the services it adds, removes or recreates, the images it pulls or stops using, the variables that move, secrets never shown, the risks of the resulting file, and port_clashes: each port it publishes that another stack or container already does, with a free one to try. For an update, it asks the registry there and then, unless a check of the last five minutes, started after the stack last changed, can answer, records nothing, and fails rather than answer “nothing” when an image could not be checked |
kaio_logs |
The last lines of a stack or of one container, bounded by tail |
kaio_images |
Every image with its size, the stacks that use it and the CVE summary of its last scan |
kaio_image_vulnerabilities |
The findings of an image’s last scan, worst first, cut to a severity floor (high by default) and a count |
kaio_volumes |
Every volume with its driver, mountpoint and the stacks that use it |
kaio_networks |
Every network with its driver, scope and the stacks that use it |
kaio_nodes |
The servers that joined this one: name, address, whether they answer, the version they run, release_differs when it is not this server’s and, for one that stopped answering, why. Empty on a server nothing joined |
On a control plane, every tool but kaio_nodes and kaio_stack_copy takes a
node: the name kaio_nodes gives, to run on that server instead of this one.
See across a cluster.
kaio_overview leaves out what is not worth an agent’s context: a clean CVE
summary is omitted rather than sent as zeroes, and a healthy stack carries no
container list. Start there, then reach for a narrower tool.
A stack with external: true was brought up with docker compose outside Kaio:
it has no version, kaio_stack reads it, its logs and scans work, and every
tool that acts on a stack refuses it with a message that says so.
A secret variable is never sent back. kaio_stack and kaio_stack_versions
name the key and mark it secret, with no value, exactly as the API does.
Acting, in write
Section titled “Acting, in write”| Tool | What it does |
|---|---|
kaio_stack_deploy |
Write a Compose file and bring the stack up, creating it if it is new. Keeps a numbered version. Refuses a file that hands the host to a service unless accept_risks is set, and one that publishes a port another stack or container already does with code port_taken, naming the holder and a free port, before anything is created, unless allow_port_clash is set. With wait, answers once every container runs and passes its healthcheck, and otherwise rolls the stack back to the version it ran before and fails with code unhealthy |
kaio_stack_copy |
Copy a stack to a node kaio_nodes names, or onto this server under a new name, with its variables, its version history and optionally its volumes. dry_run returns the plan first: the ports that clash, the host paths left behind and the risks, which block it unless accept_risks is set. A copy stopped by its risks alone fails with code host_access |
kaio_stack_update |
Pull the images of a stack and recreate the containers that changed. With wait, answers once every container runs and passes its healthcheck, and otherwise puts back the images the stack ran before and fails with code unhealthy |
kaio_stack_apply |
Redeploy with the stored variables, closing an env_pending. Keeps a numbered version. Checked for risks and taken ports like a deploy, allow_port_clash included. With wait, answers once every container runs and passes its healthcheck, and otherwise goes back to the version it ran before and fails with code unhealthy |
kaio_stack_env |
Store the variables of a stack. Nothing runs until kaio_stack_apply |
kaio_stack_action |
start, restart, pause, unpause or recreate every container of a stack. A restart of a stack with no containers yet brings it up, and is checked for risks and taken ports like a deploy; a taken port has no override there, it has to move |
kaio_stack_rollback |
Redeploy a stack from a stored version, variables included. Checked for risks and taken ports like a deploy, allow_port_clash included. With wait, answers once every container runs and passes its healthcheck, and otherwise goes back to the version it ran before and fails with code unhealthy |
kaio_stack_check_updates |
Ask the registry whether the images of a stack moved, and record the answer. An image that could not be checked, behind a registry that does not answer for instance, fails the call with code upstream naming it, and the images that do have an update, rather than reporting the stack up to date. A service with build: is skipped: its image comes from the stack itself |
kaio_container_action |
start, stop, restart, pause or unpause one container |
kaio_scan |
Scan one image, the images of a stack, or every image on the host |
kaio_stack_env replaces the stored set, so send the whole set. A variable sent
without a value keeps the value and the secret flag already stored, which is
how an agent edits one variable of a stack whose secrets it cannot read, and why
writing a secret back cannot unmask it.
No tool in this rung is a delete call, and a deploy that fails restores the
Compose file it replaced, so a bad edit is one kaio_stack_rollback away.
An agent that should show what it is about to do calls kaio_stack_plan
first. It is a read tool: it runs nothing and writes nothing, so even an agent
that may not act can lay out what a deploy, an apply, a rollback or an update
would change, and a person can say yes before the write call is made.
A deploy whose compose up goes through can still leave a container crashing
or failing its healthcheck. Pass wait: true to kaio_stack_deploy and the
call answers only once every container runs and passes its healthcheck, or has
exited with 0 for a one-shot service. When the stack does not get there
within wait_timeout seconds (120 by default, 600 at most), Kaio rolls it back
to the version it ran before and the call fails with code unhealthy, naming
each container at fault with what its healthcheck printed or its last log
lines. kaio_stack_apply, kaio_stack_rollback and kaio_stack_update take
the same wait: an update has no new version to leave, so it puts back the
images the stack ran before instead. The version that failed stays in the history, so the agent can read it
back with kaio_stack_compose, fix it and deploy again, without a second call
to find out whether the first one worked. A new stack has no earlier version
and is left as deployed.
Two callers never change a stack at the same time. While a deploy, apply,
rollback, update, restart, start, pause, recreate or delete runs on a stack,
any other of them on the same stack is refused at once with code busy,
naming what holds it and for how long; the agent tries again once it is done.
And an agent that read a stack before acting can pass expected_version to
kaio_stack_deploy, kaio_stack_apply, kaio_stack_rollback or
kaio_stack_update: when a person or a pipeline deployed in between, the call
is refused with code version_moved and changes nothing, so the agent reads the
stack again instead of overwriting what it never saw. 0 stands for a stack
that must not exist yet.
Every tool that brings a Compose file up, kaio_stack_deploy,
kaio_stack_apply, kaio_stack_rollback and kaio_stack_copy, first reads it
for what makes a container root on the host: a bind mount of the Docker, Podman
or containerd socket or of a directory holding one (/run, /var/run,
/run/user/<uid>), a bind mount of /, privileged: true, a host namespace,
or the ALL, SYS_ADMIN or SYS_MODULE capability. Variables are resolved
as Compose would resolve them, relative paths from the stack’s directory, and
YAML merge keys are followed, so neither ${SRC} set through kaio_stack_env
nor a <<: *base hides one. A file with any of them is refused, nothing
deployed, with each one named as it is written in the file, until the call is
repeated with accept_risks: true. That second call is a deliberate act, the
answer lists what was accepted, and the event log records a warn naming
them. A client that asks before a tool call shows the flag to a human; one that
does not still has to have chosen it.
That is where the guarantee stops. The check reads the Compose file, not the
images, so an image that escapes on its own is not caught, a file pulled in
with extends: {file: ...} is not read, and a file that drops a service still
removes its containers.
So write is worth what an API call is worth, no less: it is the rung for an
agent you would already trust with curl against /api. read is the only
rung that cannot change the machine.
Destroying, in admin
Section titled “Destroying, in admin”| Tool | What it removes |
|---|---|
kaio_stack_delete |
A whole stack: containers, Compose file and version history. Named volumes survive |
kaio_stack_version_delete |
One stored version. The deployed one cannot be deleted |
kaio_container_delete |
One container, with its anonymous volumes |
kaio_image_delete |
One image and the scan Kaio holds for it |
kaio_volume_delete |
One volume and the data it holds |
kaio_network_delete |
One network |
kaio_prune |
Unused images, tagged or not, stopped containers, unused volumes, named ones included, or unused networks |
These are the calls with no undo. admin is the rung to hand out last, and a
client that asks before running a destructive tool is the point of the
annotation.
One more tool sits at admin and changes nothing:
| Tool | What it returns |
|---|---|
kaio_audit |
The audit log, newest first: limit entries (50 by default, 1000 at most), optionally only those whose actor, action or target contains contains. Each entry carries its time, actor, source, kind of caller, level, action, target, outcome and the reason of a refusal |
It is read-only, annotated so, and at admin because the log is: it names who
did what, and GET /api/audit asks the same. Reading it is not itself written
to the log; a refused call to it is.
Naming a container, an image or a network
Section titled “Naming a container, an image or a network”A tool that acts on one container takes the name or an id prefix, as
kaio_overview and kaio_stack report them: an agent does not have to carry
full ids around. A prefix that matches two containers is refused rather than
guessed. Images answer to a tag or to an id prefix the same way.
There is deliberately no shell tool. The container terminal is an interactive WebSocket that does not fit a request/response tool, and handing an agent arbitrary execution inside every container is not something a mode flag makes safe.
What reaches the endpoint
Section titled “What reaches the endpoint”/mcp is sorted like every other route: from an address Kaio does not accept it
answers 403, and a caller below read cannot open it. Your reverse proxy
remains the layer that decides who a caller is, and
Hardening has the setups: the
client configuration per host, the credential it carries, and the group that
gives it its level. Two more guards apply, and both are about browsers rather
than agents:
KAIO_MCP_ALLOWED_HOSTS is the list of Host values /mcp answers, on top
of the loopback names it always accepts. Left unset, only loopback is
accepted, so a remote agent is refused: that is the variable to set first when
the handshake fails with 403. Set it to * to accept any Host, which turns
the guard off.
KAIO_MCP_ALLOWED_ORIGINS is the list of browser origins allowed to call
/mcp. Left unset, every request carrying an Origin header is refused,
while requests without one (every agent, every CLI) pass. This is what stops a
web page open in your browser from reaching a Kaio on localhost and driving
your Docker daemon through it. Set it only if a browser app of your own needs
the endpoint.
Note that these are separate from KAIO_ALLOWED_ORIGINS, which governs the REST
API’s browser policy and does not apply to /mcp.
Across a cluster
Section titled “Across a cluster”Point the agent at the control plane only: one MCP entry for the whole cluster.
kaio_nodes lists the servers that joined it, and any other tool given a node
runs on that server, with the same output it gives for the control plane.
kaio_stack_copy takes its from and to the same way. Only a control plane
and a server on its own serve /mcp: a node closes its own, even with
KAIO_MCP set, and answers an agent with the control plane’s address and the
name to pass in node. It needs no KAIO_MCP for the control plane to reach it.
The control plane holds the caller to the tool’s rung first, then signs the call
with the level the caller has there. The node holds it again to that level,
capped by its own KAIO_CLUSTER_LEVEL, so a node set to
read stays read-only whatever the control plane runs at. A refusal on either
side lands in that side’s audit log, and an error from the node starts with its
name.
A change made this way is written down twice: on the control plane as the
mcp. tool with the node in front of its target, and on the node under the
same user, as a cluster call.
Kaio, built by Régis Gaidot