Skip to content

AI agents

How administrators run AI agents on kubelatch: a bot for an agent, the approval switch, the sessions and approvals in Agents, and cutting an agent off. AI agents in Concepts explains the model and its limits; people who connect their own agent follow AI agents.

The MCP server

kubelatch serves the MCP server at <KUBELATCH_BASE_URL>/mcp, and next to it the endpoints that sign delegated agents in. It's on by default; KUBELATCH_MCP_ENABLED=false turns both off (config.mcpEnabled in the chart).

Variable Default What it sets
KUBELATCH_MCP_RATE_LIMIT 120 Requests per minute to /mcp, per credential; a delegated agent's, per session. Past it, 429 until the minute ends. Each replica counts its own.
KUBELATCH_AGENT_SESSION_TTL 8h The duration the consent page proposes.
KUBELATCH_AGENT_SESSION_MAX_TTL 24h The longest a person may choose; at most KUBELATCH_MAX_TTL_USER.
KUBELATCH_AGENT_APPROVAL_WAIT 50s How long an agent's call waits for a person (a held write, or a role asked for with request_access) before it answers that it is still waiting; 0 to 4m, and 0 answers at once.

All of them are in Configuration. The consent page a person answers to authorize an agent (Let Claude Code act as you?) says who asks, where the answer goes, what the agent gets and until when, and warns whenever the answer would leave that computer; AI agents walks through it.

Besides what it routes today, the deployment must send /mcp, /oauth/ and /.well-known/ to kubelatch. Agents' clients look for /.well-known/oauth-protected-resource/mcp and /.well-known/oauth-authorization-server at the root of the host of KUBELATCH_BASE_URL, even when the base URL has a path. The chart's Ingress already sends every path of its host to kubelatch.

/mcp refuses a request whose Origin header isn't the origin of KUBELATCH_BASE_URL: MCP clients that run inside a web page are not supported. A request body can be 1 MiB at most.

OAuth clients

An agent's client registers itself with kubelatch the first time it signs a person in (anyone can, without an account, 20 times a minute per IP), or identifies itself by the URL of its metadata document. kubelatch keeps 10,000 clients at most:

  • A client that never completes a sign-in (no agent signed in with it, no session uses it and no sign-in with it is under way) is removed 6 hours after it registered; a client an agent signed in with stays. The cleanup runs every hour, the first time one minute after startup.
  • At 10,000, a new client takes the place of the oldest one that never completed a sign-in, so a flood of registrations can't keep new agents out. Clients with a sign-in under way go last: a person signing in keeps their client unless a flood removes some ten thousand clients within their ten minutes. Only when every client is in use (an agent signed in with each) does a new one get 503 (temporarily_unavailable).
  • When a new client leaves 8,000 or more (80 %), the control plane gets an oauth.clients.near_cap event, at most one a day, and the server log a warning each time (Audit and retention). Many oauth.client.register from the same IPs point to someone filling the cap.

A bot for an agent

For an agent that isn't one person's (an on-call agent, a step of a pipeline):

  1. Create a bot in Users and grant it the smallest role that works, on a namespace rather than the whole cluster (Bots, Grant permissions). An agent that diagnoses only needs viewer.
  2. Open the bot's account page from Users. Its AI agent card has:
    • Writes need approval: off by default, so the bot's role alone decides. On, every write of the bot's agents waits until an administrator approves it, unless an access approval it was granted covers it. Turning it on or off asks for confirmation (Require approval, Stop requiring it) and applies from the agent's next write. It covers kubectl with the bot's own tokens too, which then only read; its CI tokens write as before (AI agents).
    • Connect an agent: the MCP endpoint and the commands for Claude Code and Cursor. A disabled bot doesn't offer it.
    • Sessions of this bot: opens Agents narrowed to that bot's sessions.
  3. Issue a credential for the bot (Bots), as short as the task. Where the agent runs, keep its token in the variable KUBELATCH_TOKEN, and add kubelatch to the agent with the commands from Connect an agent:

    claude mcp add --transport http kubelatch https://kubelatch.example.com/mcp --header "Authorization: Bearer $KUBELATCH_TOKEN"
    
    {
      "mcpServers": {
        "kubelatch": {
          "url": "https://kubelatch.example.com/mcp",
          "headers": { "Authorization": "Bearer ${env:KUBELATCH_TOKEN}" }
        }
      }
    }
    

    The dialog never shows a token. Only a bot's own credentials work at /mcp: a person's credential, a kubelatch login session or a CI credential get 401.

The bot's agent session starts the first time its credential is used at /mcp, one session per credential. Give the agent the rules too, so it uses the tools instead of kubectl.

The Agents page

Agents in the sidebar is for everyone, and shows what is happening now. An administrator sees every account's agents and approvals; anyone else, only their own.

At the top right, Connect an agent adds one for yourself (AI agents). Under the title is one line of facts. An administrator reads, for example, "7 active agents · 2 acting now · 2 are worth a look · 1 waits for you · last call 1 min ago": a part that would be zero is left out, and the part about what is worth a look is Pro's. Anyone else reads "3 wait for you, the first expires in 3:40 · 2 agents of yours active · last call 1 min ago", or "Nothing waits for you". The parts about what waits and what is worth a look lead to their cards.

The cards always come in the same order, and a card with nothing to show isn't drawn. An administrator reads Waiting for you, Worth a look, the approvals waiting on others, Agents at work and Recent decisions; anyone else reads Waiting for you, then Your agents and Your recent decisions.

An administrator's Agents page: the line of facts under the title, Worth a look with two agents, the approvals waiting on others folded, Agents at work with each session's last 24 hours, and Recent decisions.

An agent is named the same everywhere, by its client and the person it acts for: Claude Code to that person (Your agent if the client gave no name), "bob's Claude Code" (or "Agent of bob") to anyone else, and the bot's login, deploy-bot, for a bot's agent. An administrator's Agents page lists everyone's agents, so there your own delegated agent reads Your Claude Code (Your agent if the client gave no name), and nobody takes it for someone else's.

Waiting for you

The approvals you can decide now, the one that expires first on top. For an administrator they are the bots' and those of their own agents; for anyone else, those of their agents. Each item shows:

  • the sentence of the approval, whole: "Claude Code wants to delete 3 jobs.batch in apps (prod-eu-1)";
  • the agent's reason, in quotes;
  • a pill with the time left, "expires in 4:12": amber under 5 minutes and red under 2, always with the number;
  • Review, which opens the approval's page, and Approve….

Writes of one shape (the same agent, cluster, tool, resource and namespace) wait as one item, with the clock of the first to expire. Review unfolds them, Approve 3… approves them all after one confirmation, and its menu has Deny 3…. To approve or deny a mix, press Select: each item gets a checkbox, and the bar the first mark brings up has Approve N (writes of one shape) and Deny N (anything). Without Select there are no checkboxes. An approval nobody decides in time leaves the list, the card says so ("Expired undecided: …"), and it goes on to Recent decisions.

Approve… loads the approval first and then asks the same confirmation as its page: the sentence, the agent's reason, what the change does (for a Secret, that its hidden values may change), what approving means and the time left. Only Approve in that confirmation approves. An approval decided elsewhere or expired meanwhile is not approved, and the page says why. To read the whole diff, open the approval with Review.

An approval is one of two kinds:

  • Write: a change held for approval. Its page shows Changes: the object now against what the cluster's dry run says it becomes, with Secret values hidden. A write waits 15 minutes for a decision; once approved, 15 more to run, once.
  • Access: a role on a namespace (or the whole cluster) for some minutes, with the agent's reason. It waits an hour.

The agent's client usually opens the decision page for the person (Claude Code's terminal, which asks first, with no plugin; its plugin, in the VS Code extension), and the agent's call waits for the decision for up to KUBELATCH_AGENT_APPROVAL_WAIT, then calls again while the approval lasts. Where the client can't open it, or the person declines, the agent hands the link over in text. Calls for a write or a role that is already waiting don't create another approval.

When a delegated agent asks for a role its person doesn't hold, there is no approval yet: the person asks for the role themselves, on the request form the agent opens with its reason (in Free, from whoever the agent names), and the agent's call waits until the role reaches it (AI agents). The person's request is an ordinary access request, shown from an agent.

Who decides:

  • A bot's approvals: any administrator. Approving a bot's access grants an ordinary permission with that expiry, under the usual rules (it appears in Permissions), for 8 hours at most.
  • A delegated session's approvals: only the person the agent acts for. An administrator sees them but can't decide them.

While approvals wait for someone, Agents in the sidebar carries their count and the bell shows a notice, to whoever can decide them: one approval links to its page, several to Waiting for you. One account can have at most 20 approvals waiting.

Waiting on others

The approvals an administrator sees but another person decides are folded into one line: "5 approvals waiting on others · bob (3), alice (1) decide · the first to expire, in 4:12". Open it and they are grouped by who decides, each with its sentence, its clock and View, which opens its page. There is no Approve here: the line is for knowing who is holding what.

Worth a look

In Pro, for administrators. Worth a look lists the agents that did something out of the ordinary, one line each, the most recent first: a sentence of what happened ("bob's Cursor asked for 38 approvals in the last hour") and, in grey under it, its context ("usually asks 2 per hour · 12 refused for having 20 queued · bob decides"). It describes what happened and judges nobody. The line has View agent, which opens the page of its most recently used session, and Cut; with several reasons it shows the most recent and "and 2 more reasons" unfolds the rest.

An agent here is a person's client or a bot, counted over all its sessions, so connecting again doesn't clear a line. Four reasons turn one on, with fixed thresholds:

Reason It turns on when
A flood of requests The agent made 20 requests or more in the last hour, counting those kubelatch refused. The context says how many it usually makes per hour, from the previous 7 days.
A sensitive access it wasn't given In the last 24 hours it asked for admin, cluster-admin or a role that reads Secrets, opens a shell in a container, adds an ephemeral container or forwards ports, and didn't get it: kubelatch refused it, a person denied it or it expired. An approved one doesn't count, and neither does a write.
Insistence In the last 24 hours it asked again, three times or more, for what had already been refused, denied or expired.
Denials from the cluster The cluster denied (401 or 403) 20 calls or more of the agent in the last hour.

A reason stays on while it holds inside its window (an hour for the flood and the denials, 24 hours for the other two) and goes off by itself. A line needs an active session: cutting the agent clears it, and it returns if the agent connects again inside the window.

The bell tells an administrator once per agent: one notice, "bob's Cursor is worth a look: 38 approvals in the last hour", which leads to the agent's line and goes when its reason does. It's never one notice per request and there is no e-mail. Someone who works with an agent isn't told about their own agent.

In Free the card is one line, "With Pro, kubelatch tells you when an agent is worth a look and shows what each one did in the last day", with See Pro, and the bell has no such notice.

Agents at work

The active sessions of every account, one row each, so an agent with two sessions has two rows. The agents worth a look come first, marked ▲, then those acting now (a call less than 5 minutes ago), then the rest by last call. On a wide screen it's a table, on a phone a list of rows:

  • Agent: its name, and under it its mode and since when ("delegated · since Thursday").
  • Scope: its strongest permission first ("developer in apps · prod-eu"), then the rest summed up ("+ viewer in 3 clusters"), and "writes without approval" when its writes don't wait for one. For a bot, the bot's own permissions.
  • Last 24 h (Pro): its calls hour by hour as a small line, with "512 calls · 41 denied".
  • Last call: when, and in Pro the verb and resource of that call ("never" if it hasn't called). A session that has gone unused for 7 days or more adds "idle 16 d" under it.
  • Until: when the session ends, as a plain pill without colour. What matters in an agent is what it can do and whether it is used, not that it ends soon. For a bot, "its credential's".
  • Cut, and a menu with Open.

Above the rows, chips filter them, each with its count: Acting now, Idle 7 d or more, Write without approval and, from two clusters on, a Cluster select. They are kept in the page's URL. Sessions of this bot, on a bot's page, opens the list narrowed to that account, with Remove to lift it.

To cut several sessions at once, tick their rows: the bar that the first tick brings up has Cut N…, for up to 50. One confirmation lists the agents and what cutting does, and it's all or none: if one of the sessions has ended meanwhile, nothing is cut and the message names its agent, so you can untick its row. Ended 23 opens the ended sessions in the same card, each with who cut it and when ("Cut by ana on 20 Oct") or when it expired; Back to the active ones returns.

Anyone else sees Your agents: their own, one row each, with its name, since when and until when, in Pro its calls of the last day and its last call, and Cut; Ended 4 opens the ended ones.

A bot's session has no expiry of its own: it lasts as long as its credential. A delegated session lasts what the person chose.

In Free there is no Last 24 h column, Last call is only the time of the call, and no row is marked ▲.

A session's page

The agent's name in a row opens its session. The page carries the agent's name, with its mode and state as pills. It starts with Waiting for a decision when approvals wait on this session, each as its sentence linking to its page. Then it shows Session (On behalf of, Agent, Started, Last used, Expires, the Credential or the OAuth client, Writes need approval and, once cut, Cut by), Permissions in effect (what counts now) and, for a delegated session, its Ceiling: Later permissions (what it takes of the permissions the person receives later: Leave out, Read only or Same role), then each permission it has, the one it came from, and whether it still counts.

Timeline lists the agent's tool calls, newest first, one line each: the time, the tool, what it did (patch deployments web, plus +1 more write when the call made other writes), the result and the duration. The button 3 requests unfolds the requests the call sent to the cluster, oldest first, and each opens the same panel as in Audit. A call is named after its last write, or else its last real request, never after a dry run: a write held for approval is named after what it read, and its dry run is marked dry run among the requests. Discovery requests (/api, /apis, /version) stay out until you check Include API discovery. For administrators, Open in Audit opens the same rows in Audit.

Recent decisions and the history

Recent decisions (Your recent decisions for anyone else) shows the five latest closed requests you can see, each with its time and what became of it: "bob approved changing deployments/api · the cluster answered 200", "You denied deleting configmaps/coredns in kube-system", "bob denied Cursor developer in payments · staging" (a decided access says which agent it was for), "Expired undecided: …", "kubelatch refused Claude Code asking for …: …". All opens the Approval history, with Resolved, Refused and Expired and how many each holds; Back returns. Each row is the sentence of the approval, which links to its page, with when it was asked, its Kind and its Status.

Refused holds the requests kubelatch turned down when the agent made them: cluster-admin for a delegated agent, a role an agent can't ask for, a write that a bot's rules don't allow, or a request while 20 already wait. The agent got the error at once; the history keeps the request with the same reason, as Refused. A delegated agent's ask for a role its person doesn't hold is kept there too, with the reason that the person has to ask for it first, while the agent waits for the person to get it. Nobody decides one and it never waits in Waiting for you. They are kept as long as the other closed approvals (Audit and retention), and an agent that keeps trying shows in Worth a look.

The decision page

The page of an approval, the link the agent gives the person, is titled by what is asked: "deploy-bot wants to change configmaps/feature-flags in apps (kind-local)", or "deploy-bot asks for the role developer in apps (kind-local) for 2 h". Under the title are its status pill, who asked and when ("Asked 3 min ago by the agent node") and, while it waits, a countdown ("expires in 11:42"). Opening the page decides nothing: only a click on Approve or Deny does.

For a write, Changes starts with one line of what it does ("Creates the object (12 lines)", "Changes 2 lines of data", "Deletes the object") and then the diff: lines that go start with −, lines that come start with +. The metadata the API server manages (creationTimestamp, uid, resourceVersion, managedFields, generation, selfLink) stays folded behind Show the 7 lines of metadata, and on a phone long lines wrap rather than scroll. For a Secret the line never says nothing changes: its values aren't shown, and a value the write changes reads <redacted, N bytes, changed> in what it becomes, so it shows as a changed line even when its size stays the same. A change too large to compare line by line is shown whole, with a warning to compare it yourself. If the agent gave a reason, the page quotes it.

Deny and Approve come after the diff, and stay fixed at the foot of a phone's screen. Each asks for confirmation with the sentence of the change. Approve the write adds that it runs once, as the agent's call for it comes back; Deny the approval adds that the agent gets a refusal and nothing runs. The page of an access approval warns what approving it means, and Approve the access repeats it: while it lasts, the agent's writes there run without approval, with everything its other permissions there allow.

Once decided or expired, the page says what became of it ("Approved by alex at 17:21 · ran once, the cluster answered 201.", "Expired at 17:34 without running; the agent has to ask again.") and the buttons go. Under Details, folded, are the session, the agent, the tool, the id, the request and the exact times it was asked, expires, was decided and ran.

Cut an agent off

In Agents, press Cut on the agent's row or on its Worth a look line (which cuts every active session of that agent, up to 50 at once), or open its session and press Cut there. To cut several, tick their rows and press Cut N…. Either way you confirm first:

  • A bot's session: the bot's credential is revoked, its pending approvals are closed, and the permissions it was granted by approval are revoked. Connecting the agent again takes a new credential.
  • A delegated session: its tokens are revoked, its pending approvals are closed, and the permissions the person gave it end.

The next call of the agent fails. A cut of several sessions is all or none, and leaves one agent.session.revoke event for each. Disabling the bot or the person also ends everything their agents had. Revoking a person's permission takes from their agents whatever came from it, at once.

Native roles and the cluster's own names

A delegated agent always enters a cluster as its person's kubelatch name, user:<login>, with the groups of the permissions it got. It never takes the name the cluster's identity template gives the person, such as oidc:ana@acme.com: whatever the cluster binds to that name, a RoleBinding to admin or a ClusterRoleBinding to cluster-admin, stays the person's. A binding someone writes by hand to user:<login> does reach the agent, but never privileged access: while the cluster gives user:<login> privileged access, the reconciliation leaves that name out of what the proxy may impersonate whatever the agent's expiry, and the cluster goes to Error saying so.

Native roles are never delegated: kubelatch can't know what a group of the cluster allows (Native roles). The consent page offers nothing for a native permission, Later permissions takes nothing from a native permission the person receives later, and an agent's request_access for a native role answers agent.role_not_requestable.

Audit

Every request an agent sends to a cluster is an audit row with its agent session and its tool. In Audit, More filters has Tool and Agent session, What ends in the tool, and the detail of a request shows MCP tool and Agent session (Audit and retention). A delegated agent's rows have the person as their subject. whoami and request_access reach no cluster and leave no audit row; their session and approvals are in the control plane.

Troubleshooting

What happens Why, and what to do
The agent gets 401 with invalid token: the MCP endpoint accepts a bot's credential, or an agent's token from kubelatch's sign-in It was given a person's credential, a kubelatch login session or a CI credential. Use a bot's credential, or connect it without a token so the person authorizes it.
Claude Code reports the kubelatch server as failed instead of opening the browser It sends an Authorization header that kubelatch refuses, so it doesn't fall back to signing in. Remove the header from its configuration for a person's agent.
The agent's client can't find where to sign in /.well-known/ doesn't reach kubelatch: check the Ingress or the reverse proxy in front. curl https://kubelatch.example.com/.well-known/oauth-protected-resource/mcp must answer kubelatch's JSON.
403 with cross-origin requests are not accepted from /mcp itself The request carried an Origin other than that of KUBELATCH_BASE_URL: an MCP client inside a web page, which is not supported.
429 with too many requests for this credential Over KUBELATCH_MCP_RATE_LIMIT. Raise it, or ask the agent to make fewer calls.
A call answers agent.still_waiting after about a minute Not a failure: nobody decided within KUBELATCH_AGENT_APPROVAL_WAIT. The agent calls again while the request lasts, or goes on with something else. If a proxy in front of kubelatch cuts requests sooner, lower the value.
The agent's client gets invalid_client when it signs in kubelatch removed its registration: it never completed a sign-in within 6 hours, or it made room for a new client at the cap (OAuth clients). Remove the kubelatch server from the agent's client and add it again, so the client registers again.
A write answers agent.approval_executed The approval already ran, for example because the agent's client reconnected as the person approved. Read the object to see the result.
A write answers agent.too_many_pending 20 approvals already wait for that account: decide them in Agents, or let them expire.
An agent's write fails with 409 after approval The object changed after the request was held, or was created again; the approval shows as run once with that answer. The agent asks again.

Every message is in Errors.