Kubernetes MCP Server (containers)

Go-native Kubernetes and OpenShift MCP server that talks to the API server directly, no kubectl required.

By defaultCan delete
With our presetRead-only
Flagssecretsexec

Labels are provisional (from the project README/docs, checked Nov 3, 2026). Not yet tested in our sandbox.

Read-only switch

Set read_only = true in a TOML file passed with --config. The project moved runtime settings from CLI flags to TOML; old --read-only style flags are documented as replaced.

Preset

Read-onlyRead-only setting from the project's docs. Not sandbox-tested yet.
What the preset changes
  • Pins @0.1.1: the read-only switch needs 0.0.44 or later.
  • Added --config /absolute/path/to/kubernetes-mcp-readonly.toml
  • Replace /absolute/path/to/ with the real folder. Use an absolute path: a relative path is resolved from the client's working directory, which differs between Claude Code, Codex and Cursor. (Cursor and VS Code can use ${workspaceFolder}/kubernetes-mcp-readonly.toml.)
  • Settings from environment variables and command-line flags beat the config file, so keep read_only out of both. Keep the file in a folder of its own: releases 0.0.56 to 0.0.67 also load a conf.d folder next to it.

Claude Code

.mcp.json
{
  "mcpServers": {
    "kubernetes": {
      "command": "npx",
Removed:       "args": ["-y", "kubernetes-mcp-server"]
      "args": [
        "-y", "kubernetes-mcp-server@0.1.1", "--config",
        "/absolute/path/to/kubernetes-mcp-readonly.toml"
      ]
    }
  }
}

Optional third layer: add "deny": ["mcp__kubernetes__<write tool>"] under permissions in .claude/settings.json.

kubernetes-mcp-readonly.toml
read_only = true

# Optional: hide Secrets from the agent entirely
[[denied_resources]]
group = ""
version = "v1"
kind = "Secret"

Replace /absolute/path/to/ with the folder where you saved the file. Codex and Claude Code don't expand ${workspaceFolder}.

Codex

~/.codex/config.toml
# Generated by redpresets.dev on 2026-11-03. Unverified preset. Also use a read-only credential. Not a security guarantee.

[mcp_servers.kubernetes]
command = "npx"
Removed: args = ["-y", "kubernetes-mcp-server"]
args = ["-y", "kubernetes-mcp-server@0.1.1", "--config", "/absolute/path/to/kubernetes-mcp-readonly.toml"]
default_tools_approval_mode = "writes"

default_tools_approval_mode = "writes" asks before any tool the server does not mark read-only.

kubernetes-mcp-readonly.toml
read_only = true

# Optional: hide Secrets from the agent entirely
[[denied_resources]]
group = ""
version = "v1"
kind = "Secret"

Replace /absolute/path/to/ with the folder where you saved the file. Codex and Claude Code don't expand ${workspaceFolder}.

Cursor

.cursor/mcp.json
{
  "mcpServers": {
    "kubernetes": {
      "type": "stdio",
      "command": "npx",
Removed:       "args": ["-y", "kubernetes-mcp-server"]
      "args": [
        "-y", "kubernetes-mcp-server@0.1.1", "--config",
        "${env:workspaceFolder}/kubernetes-mcp-readonly.toml"
      ]
    }
  }
}

Don't add write tools to mcpAllowlist in .cursor/permissions.json. Leave them on approval. Cursor's docs say the allowlist is not a security boundary.

kubernetes-mcp-readonly.toml
read_only = true

# Optional: hide Secrets from the agent entirely
[[denied_resources]]
group = ""
version = "v1"
kind = "Secret"

Lines marked + are what we added to the vendor's install command. Struck-through lines marked − are what they replaced; Copy leaves those out.

Credential layer

Bind the kubeconfig/service account the agent uses to a read-only ClusterRole (e.g. the built-in view role). view excludes Secrets; do not grant get secrets to agents.

Gotchas

  • Exposes pod exec and resource create/delete tools unless read-only is set.
  • If you already pass --config, add read_only = true to that file instead.
  • Needs 0.0.44 or later: 0.0.43 and earlier read --config but ignore read_only. We pin one exact release, kubernetes-mcp-server@0.1.1, so npx can't reuse an older cached copy.
  • 0.0.56 to 0.0.67 also load a conf.d folder next to the TOML file, and a file there can set read_only = false. On an exact pin below 0.0.68 we add --read-only, which beats it; 0.0.68 and later stop on --read-only, so we drop it there. A range or latest that can reach below 0.0.68 is denied until you pin one exact release.

Facts

Vendor
containers (Red Hat-led)
Source
containers/kubernetes-mcp-server
License
Apache-2.0
GitHub stars
2.2k
Latest release
v0.1.1 (Oct 29, 2026)
Last push
Nov 3, 2026
Status
Active
Last checked
Nov 3, 2026

Sources

Spotted something wrong? Labels change when vendors change. Suggest a correction

Read-only alternatives in Kubernetes