Add Kubernetes to a local diagnosis

Add a Kubernetes tool to your AI client in one command with its read-only mode on, and add a read-only account if you want the cluster itself to refuse writes.

What you need
You need an active responder seat. The optional read-only account needs a cluster admin.

Before you start

  • Connect your client first. See Set up Diagnosis.
  • Install Node.js and kubectl, and sign in to your cluster as you do today.

Reference

Seeing whether pods restarted, failed to schedule or were rolled out near the start of the incident.

Pods and their logs, events, deployments, replica sets, stateful sets, jobs, services, ingresses, nodes, and pod and node metrics. The config below hides Secrets from the model.

Your current kubeconfig and context. You create nothing new for the default setup.

The server uses every context in that file. If it holds production and staging, the model can read both. To limit that, set kubeconfig in the config file to a copy that holds only the contexts a diagnosis needs.

Run one command. It writes the config file below and asks before it adds the server to your client. Once the server is in your client, it runs four checks of what your account can change and reports them to Tellagen, so you need no Recheck. --context NAME limits the server to one context.

One command

npx -y @tellagen/mcp-server kubernetes setup --client claude-code

Other clients: codex, cursor, claude-desktop. By hand: save this as ~/.config/tellagen/kubernetes-mcp.toml, then run the command below for Claude or Codex.

~/.config/tellagen/kubernetes-mcp.toml

toolsets = ["core"]
read_only = true
disable_destructive = true

[[denied_resources]]
group = ""
version = "v1"
kind = "Secret"

Claude in the terminal

claude mcp add kubernetes --scope user -- \
  npx -y kubernetes-mcp-server@latest --config "$HOME/.config/tellagen/kubernetes-mcp.toml"

Codex

codex mcp add kubernetes -- \
  npx -y kubernetes-mcp-server@latest --config "$HOME/.config/tellagen/kubernetes-mcp.toml"

read_only = true. The server registers only read tools, so delete, exec, run, scale and apply never reach the model. disable_destructive has no effect while read_only is on. It takes over only if read_only is ever turned off. denied_resources hides Secrets from the model. The server's README calls both best effort.

None of these is the credential. Your own account can still write, so a bug in the server or a changed config could write too. That is why the Kubernetes row says "Read-only tools, account can write" until you add the read-only account below. "Can change the cluster" means the client didn't report the server as read-only.

The setup command checks whether your account can create pods, delete pods, exec into pods and read secrets, in the current namespace. With the read-only account all four answers are no. After a pickup alone the row says "Safety not checked", and an admin can select Run a check for a prompt to paste into your client.

To test the read-only account by hand, point kubectl at its kubeconfig. Do not use --as, which needs rights that many engineers lack.

Each answer must match the comment

K="$HOME/.config/tellagen/kubeconfig"
kubectl --kubeconfig "$K" auth can-i list pods -A          # yes
kubectl --kubeconfig "$K" auth can-i delete pods -A        # no
kubectl --kubeconfig "$K" auth can-i create pods --subresource=exec -A   # no
kubectl --kubeconfig "$K" auth can-i get secrets -A        # no

The answers to the four setup checks, the kubectl command behind each evidence reference, and what your client quotes from events or logs in a finding. Your model provider receives every log line the tool returns. See How a local diagnosis uses your tools.

Do this once for each cluster, with a platform engineer, if you want the cluster to refuse writes. The role grants get, list and watch only. It leaves out secrets, configmaps, pods/exec, pods/attach and pods/portforward. Apps print secrets into logs, so a role that includes pods/log lets the model provider see them. Remove pods/log from the role to keep logs away. The diagnosis then works from events and status only.

First download the read-only role and read it. Then apply it, once for each cluster.

Apply the read-only role

kubectl apply -f tellagen-diagnosis-read-role.yaml

Then pick a route. Route A is the better one, because the audit log shows each person.

Route A, a separate read-only identity: map an identity from your single sign-on that holds only this role, such as an EKS IAM role with an access entry in the group tellagen-diagnosis. Then bind the role to that group, once for each cluster.

Bind for route A

kubectl create clusterrolebinding tellagen-diagnosis-read \
  --clusterrole=tellagen-diagnosis-read --group=tellagen-diagnosis

Each responder writes a separate kubeconfig for that identity, so the default context of their own kubeconfig does not change.

Route A, on EKS

aws eks update-kubeconfig --name prod \
  --role-arn arn:aws:iam::123456789012:role/diagnosis-readonly --alias prod-read \
  --kubeconfig "$HOME/.config/tellagen/kubeconfig"

RBAC only adds rights. Binding the role to a group that a responder already belongs to changes nothing if that person is also an admin. Route A works because the second context signs in as an identity with this role and nothing else. Then point the server at that file in kubernetes-mcp.toml. TOML does not expand $HOME, so write the full path.

Route A and B, in kubernetes-mcp.toml

kubeconfig = "/Users/you/.config/tellagen/kubeconfig"

Route B, a shared service account: first create the service account, bind the role to it, and let the group tellagen-diagnosis make its tokens. Run these once for each cluster.

Bind for route B

kubectl create namespace tellagen
kubectl create serviceaccount diagnosis-reader -n tellagen
kubectl create clusterrolebinding diagnosis-reader \
  --clusterrole=tellagen-diagnosis-read --serviceaccount=tellagen:diagnosis-reader
kubectl create role diagnosis-reader-token -n tellagen \
  --verb=create --resource=serviceaccounts/token --resource-name=diagnosis-reader
kubectl create rolebinding diagnosis-reader-token -n tellagen \
  --role=diagnosis-reader-token --group=tellagen-diagnosis

Then each responder runs the setup command with the service account. It makes an 8-hour token, writes a small kubeconfig and points the server at it. Run it again each day.

Route B, with the setup command

npx -y @tellagen/mcp-server kubernetes setup --client claude-code --service-account diagnosis-reader -n tellagen

Or write the kubeconfig by hand each day.

Route B, once a day

OUT="$HOME/.config/tellagen/kubeconfig"; mkdir -p "$(dirname "$OUT")"
SERVER=$(kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}')
CA=$(kubectl config view --minify --raw -o jsonpath='{.clusters[0].cluster.certificate-authority-data}')
TOKEN=$(kubectl create token diagnosis-reader -n tellagen --duration 8h)
cat > "$OUT" <<EOF
apiVersion: v1
kind: Config
clusters: [{name: target, cluster: {server: $SERVER, certificate-authority-data: $CA}}]
users: [{name: diagnosis-reader, user: {token: $TOKEN}}]
contexts: [{name: diagnosis, context: {cluster: target, user: diagnosis-reader}}]
current-context: diagnosis
EOF
chmod 600 "$OUT"

If you write it by hand, add the same kubeconfig line to kubernetes-mcp.toml, as in route A. Without it the server keeps using your own kubeconfig.

The audit log shows the service account, not the person. Never share one long-lived token across the organization: the audit log then loses who acted, and revoking it cuts off everyone.

You are done when

After the setup command, an admin sees "Read-only tools, account can write" on the Kubernetes row, or "Read-only access checked" once you use the read-only account.

FAQs

  • An admin sees Kubernetes as Found, no access. What do I do?

    Your client reported that it can't use the account. With route B the token lasts 8 hours, so run the setup command with the service account again to renew it.

  • Kubernetes still shows Not found. What do I do?

    See Fix a tool that shows Not found.

Related guides

External setup references

Updated . Something out of date? Write to [email protected]. Open Markdown version