# 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.

## Before you start

### Intended audience

Responders who run a Diagnosis from an AI client on their own computer, and the platform engineers who own the cluster.

### Required permissions

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


### Prerequisites

- Connect your client first. See [Set up Diagnosis](https://tellagen.com/help/set-up-diagnosis).
- Install Node.js and `kubectl`, and sign in to your cluster as you do today.

## Reference

<a id="step-used-for"></a>

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

<a id="step-reads"></a>

**Reads.** 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.

<a id="step-credential"></a>

**Credential.** 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.

<a id="step-config"></a>

**Config.** 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.

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.

One command:

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

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

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

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

Claude in the terminal:

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

Codex:

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

<a id="step-read-only-by"></a>

**Read-only by.** `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.

<a id="step-check-it"></a>

**Check it.** 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:

```shell
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
```

<a id="step-reaches-tellagen"></a>

**Reaches Tellagen.** 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](https://tellagen.com/help/how-local-diagnosis-uses-your-tools).

<a id="step-read-only-account"></a>

**Optional: a read-only account.** 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](https://tellagen.com/help/assets/tellagen-diagnosis-read-role.yaml) and read it. Then apply it, once for each cluster.

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.

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

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 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.

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.

Or write the kubeconfig by hand each day.

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.

Apply the read-only role:

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

Bind for route A:

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

Route A, on EKS:

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

Route A and B, in kubernetes-mcp.toml:

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

Bind for route B:

```shell
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
```

Route B, with the setup command:

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

Route B, once a day:

```shell
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"
```

## 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

<a id="troubleshooting-an-admin-sees-kubernetes-as-found-no-access-what-do-i-do"></a>

### 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.

<a id="troubleshooting-kubernetes-still-shows-not-found-what-do-i-do"></a>

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

See [Fix a tool that shows Not found](https://tellagen.com/help/fix-a-tool-that-shows-not-found).

## Related articles

- **Recommended next task:** [How a local diagnosis uses your tools](https://tellagen.com/help/how-local-diagnosis-uses-your-tools)
- [Add an evidence tool to your client](https://tellagen.com/help/add-an-evidence-tool)

## External setup references

- [Kubernetes MCP server README](https://github.com/containers/kubernetes-mcp-server) (verified 2026-11-16)


## Continue through the incident lifecycle

- **Previous task:** [Add Grafana to a local diagnosis](https://tellagen.com/help/add-grafana-to-a-local-diagnosis)
- **Next task:** [Add GitHub to a local diagnosis](https://tellagen.com/help/add-github-to-a-local-diagnosis)
- [Back to Support Center](https://tellagen.com/help#help-search)

## Updated

2026-11-26
