Mcp K8s Ro

io.github.your-ko由 GitHub 帳號 your-ko 發布v1.2.2更新於 Oct 30, 2026

Read-only Kubernetes MCP server: inspect resources, logs, events, and metrics. Secrets are masked.

概覽

AI 產生的概覽

唯讀的 Kubernetes MCP 伺服器,讓助理列出與檢視資源、讀取 Pod 日誌與事件,並查詢 CPU/記憶體用量。

可以做什麼
  • 列出並檢視叢集資源,支援任意資源類型及其完整 YAML
  • 透過 discovery API 列出可用資源類型,可依 API 群組篩選
  • 讀取 Pod 日誌,支援選擇容器、指定行數以及查看崩潰前的日誌
  • 依命名空間或整個叢集列出 Kubernetes 事件,依時間由新到舊
  • 檢視每個 Pod 與每個節點的 CPU 與記憶體用量,並顯示占可分配容量的百分比
適用情境
適合值班與排錯情境:讓助理在不變更叢集的前提下檢視 Pod 狀態、重啟次數、日誌、事件與資源壓力。也適合希望每個伺服器實例固定對應一個叢集內容的團隊。
執行需求
以 stdio 本機程序執行,可使用預先編譯的執行檔或 Docker 映像。需要 kubeconfig 檔案,透過 KUBECONFIG 指定,預設為 ~/.kube/config,並需具備目標叢集的憑證。指標類工具要求叢集已部署 metrics-server。macOS 執行檔未簽章,需要繞過 Gatekeeper。
安裝前請注意
伺服器透過 kubeconfig 持有叢集憑證,並能讀取日誌、事件與資源 YAML,因此只應指向願意暴露給模型的叢集。Secret 的 data 與 stringData 會被遮蔽,但其他欄位仍會回傳。設計上為唯讀,需要變更時只會印出 kubectl 指令;內容在啟動時固定,切換叢集需重新啟動。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Mcp K8s Ro,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

[Main] [golangci-lint] [Link validation]

mcp-k8s-ro

A read-only MCP server that gives Claude access to Kubernetes clusters. Built in Go, it communicates over stdio using the MCP protocol.

Design

  • Read-only — only get, describe, logs, and top style operations. No create, update, or delete. If a mutating operation is needed, the server prints the equivalent kubectl command for you to run manually. Safe to use while on-call at night: Claude can never accidentally mutate your cluster, even under prompt fatigue.
  • Secret-safe — secret values are masked before being sent to the model, so your secrets cannot leak due to misconfiguration or prompt injection.
  • Token-efficient — responses include only relevant fields (name, status, restarts, etc.) rather than raw Kubernetes API objects, keeping context usage low.
  • Cluster-aware — every response includes the active context and cluster name, so Claude always knows which cluster it is talking to.
  • Context-pinned — the server locks to the active kubeconfig context at startup. Switching contexts in another terminal has no effect on the running server.
  • No extra infra — runs as a local binary or Docker container, connects to whatever kubeconfig context is active at startup.

Redacted fields

Object/FieldReason
Secret.dataSecret leak prevention
Secret.stringDataSecret leak prevention
CertificateSigningRequest.spec.requestLarge base64 PEM blob, no diagnostic value, saves tokens
Certificate (cert-manager) .spec.keystoresCert chain PEM blobs, no diagnostic value, saves tokens
Certificate (cert-manager) status.conditions[].messageCert chain PEM blobs, no diagnostic value, saves tokens
*.managedFieldsNo diagnostic value, saves tokens

Tools

ToolDescription
k8s_list_resourcesList any resource type by name — pods, deployments, CRDs, etc. Accepts optional namespace filter. Returns name, status, readiness, restarts, node, IP, and more depending on resource kind.
k8s_describe_resourceReturn the full YAML of a single resource. Secret data is masked.
k8s_list_resource_typesList all available resource types via the discovery API. Accepts optional API group filter.
k8s_get_logsFetch pod logs. Supports container selector, tail lines, and --previous for crashed containers.
k8s_get_eventsList Kubernetes events for a namespace or the whole cluster, sorted by most recent.
k8s_top_podsCPU and memory usage per pod, with per-container breakdown. Requires metrics-server.
k8s_top_nodesCPU and memory usage per node, with percentage of allocatable capacity. Requires metrics-server.

Configuration

Environment variableDefaultDescription
KUBECONFIG~/.kube/configPath to kubeconfig file

Usage with Claude

Docker (recommended)

bash
claude mcp add --scope user --transport stdio k8s-ro \  -- docker run --rm -i -v ~/.kube:/home/nonroot/.kube:ro ghcr.io/your-ko/mcp-k8s-ro:latest

Pinning a specific version (check the latest release ) is recommended for production use:

bash
claude mcp add --scope user --transport stdio k8s-ro \  -- docker run --rm -i -v ~/.kube:/home/nonroot/.kube:ro ghcr.io/your-ko/mcp-k8s-ro:1.1.0

Binary

Download a pre-built binary from GitHub Releases:

bash
# macOS Apple Silicon — change ARCH for other platforms: darwin-amd64, linux-amd64, linux-arm64ARCH=darwin-arm64VERSION=$(curl -fsSL https://api.github.com/repos/your-ko/mcp-k8s-ro/releases/latest | grep tag_name | cut -d'"' -f4)curl -fsSL "https://github.com/your-ko/mcp-k8s-ro/releases/download/${VERSION}/mcp-k8s-ro-${VERSION}-${ARCH}" -o ~/.local/bin/mcp-k8s-rochmod +x ~/.local/bin/mcp-k8s-roxattr -d com.apple.quarantine ~/.local/bin/mcp-k8s-ro 2>/dev/null  # macOS only: remove Gatekeeper quarantineclaude mcp add --scope user --transport stdio k8s-ro ~/.local/bin/mcp-k8s-ro

macOS Gatekeeper: The binary is not code-signed, so macOS will block it. The xattr command above removes the quarantine flag. Alternatively, go to System Settings → Privacy & Security and click "Allow Anyway" after the first blocked attempt. [img.png]

Or build from source:

bash
make buildclaude mcp add --scope user --transport stdio k8s-ro ./bin/mcp-k8s-ro

Custom kubeconfig location

If your kubeconfig is not at ~/.kube/config, set the KUBECONFIG environment variable:

bash
# Binaryclaude mcp add --scope user --transport stdio -e KUBECONFIG=/path/to/kubeconfig k8s-ro ~/.local/bin/mcp-k8s-ro
# Dockerclaude mcp add --scope user --transport stdio k8s-ro \  -- docker run --rm -i -e KUBECONFIG=/config/kubeconfig -v /path/to/kubeconfig:/config/kubeconfig:ro ghcr.io/your-ko/mcp-k8s-ro:latest

Single-cluster design

The server intentionally operates on one kubeconfig context and provides no tool to switch clusters at runtime. The reasons are:

  • Prompt injection isolation — a malicious value in one cluster's resources (e.g. a pod annotation) cannot instruct Claude to pivot to a different cluster, including production.
  • Explicit audit boundary — every tool response includes the context and cluster name, so there is never ambiguity about which cluster was queried.

To point the server at a different cluster, stop the server, switch context, and restart:

bash
kubectl config use-context my-other-cluster# then restart the MCP server / reload Claude Desktop

To work with multiple clusters simultaneously, register a separate server instance per cluster in your MCP config:

json
{  "mcpServers": {    "k8s-staging": {      "type": "stdio",      "command": "/path/to/bin/mcp-k8s-ro",      "env": { "KUBECONFIG": "/path/to/.kube/config" }    },    "k8s-prod": {      "type": "stdio",      "command": "/path/to/bin/mcp-k8s-ro",      "env": { "KUBECONFIG": "/path/to/.kube/config-prod" }    }  }}

Claude will address each server by name and each instance only ever sees its own cluster.

MCP registry

This server is published on registry.modelcontextprotocol.io

來源:README.md,提交 d083672

工具

0
SourceWeft 曾在隔離沙箱中以無憑證方式啟動該軟體包一次,以列出其工具,但未能完成:該軟體包類型無法在沙箱中執行。

版本歷史

2
  1. v1.2.2最新Oct 30, 2026
  2. v1.2.1Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分