/ Diretório / Playground / k8s-mcp-server
● Comunidade alexei-led ⚡ Instantâneo

k8s-mcp-server

por alexei-led · alexei-led/k8s-mcp-server

Give Claude kubectl, helm, istioctl, and argocd — with command validation, non-root execution, and scoped kubeconfig — so you can ops your cluster by chat.

k8s-mcp-server runs as a Docker container that mounts your kubeconfig read-only. It wraps kubectl/helm/istioctl/argocd plus Unix utilities (jq, grep, sed) for pipelines. Two security modes (default restrictive, permissive) and a command validator so Claude can't accidentally kubectl delete namespace your prod.

Por que usar

Principais recursos

Demo ao vivo

Como fica na prática

k8s.replay ▶ pronto
0/0

Instalar

Escolha seu cliente

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "k8s": {
      "command": "uvx",
      "args": [
        "k8s-mcp-server"
      ],
      "_inferred": true
    }
  }
}

Abra Claude Desktop → Settings → Developer → Edit Config. Reinicie após salvar.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "k8s": {
      "command": "uvx",
      "args": [
        "k8s-mcp-server"
      ],
      "_inferred": true
    }
  }
}

Cursor usa o mesmo esquema mcpServers que o Claude Desktop. Config de projeto vence a global.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "k8s": {
      "command": "uvx",
      "args": [
        "k8s-mcp-server"
      ],
      "_inferred": true
    }
  }
}

Clique no ícone MCP Servers na barra lateral do Cline, depois "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "k8s": {
      "command": "uvx",
      "args": [
        "k8s-mcp-server"
      ],
      "_inferred": true
    }
  }
}

Mesmo formato do Claude Desktop. Reinicie o Windsurf para aplicar.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "k8s",
      "command": "uvx",
      "args": [
        "k8s-mcp-server"
      ]
    }
  ]
}

O Continue usa um array de objetos de servidor em vez de um map.

~/.config/zed/settings.json
{
  "context_servers": {
    "k8s": {
      "command": {
        "path": "uvx",
        "args": [
          "k8s-mcp-server"
        ]
      }
    }
  }
}

Adicione em context_servers. Zed recarrega automaticamente ao salvar.

claude mcp add k8s -- uvx k8s-mcp-server

Uma linha só. Verifique com claude mcp list. Remova com claude mcp remove.

Casos de uso

Usos do mundo real: k8s-mcp-server

Morning cluster health check via chat

👤 SRE, platform engineers ⏱ ~5 min intermediate

Quando usar: Daily, before stand-up — anything red? Any pods crashlooping?

Pré-requisitos
  • kubeconfig on host — Usually ~/.kube/config
Fluxo
  1. Start the MCP container
    Start k8s-mcp-server via Docker mounting ~/.kube read-only.✓ Copiado
    → Container up
  2. Run the checks
    Across all namespaces, list pods not in Running state, nodes not Ready, and recent (last 1h) events of type Warning.✓ Copiado
    → Three-part health report
  3. Triage
    For each crashlooping pod, get last 50 log lines and propose most likely cause.✓ Copiado
    → Log excerpts + diagnoses

Resultado: 5-minute daily cluster pulse check.

Armadilhas
  • Running kubectl get events cluster-wide floods context — Always filter by time and type

Debug a failed Helm release

👤 Devs shipping Helm charts ⏱ ~15 min intermediate

Quando usar: helm upgrade failed and you want to know why without copying error messages back and forth.

Fluxo
  1. Get history
    helm history my-app -n production. What changed between v4 (working) and v5 (failed)?✓ Copiado
    → Version diff
  2. Diff templates
    Render the template for v5 with current values and compare against v4. Highlight differences.✓ Copiado
    → Diff of rendered manifests
  3. Roll back if needed
    Roll back to v4. Confirm all pods become Ready.✓ Copiado
    → Rollback + health check

Resultado: Fast recovery with understanding, not just luck.

Armadilhas
  • Rolling back without capturing the failure first means you can't fix forward — Always save helm get all v5 to a file before rolling back
Combine com: filesystem

Audit Argo CD apps for drift

👤 GitOps practitioners ⏱ ~20 min advanced

Quando usar: You suspect someone kubectl'd something into prod that Argo CD doesn't know about.

Fluxo
  1. List out-of-sync apps
    argocd app list --output json. Filter to apps where sync status isn't Synced.✓ Copiado
    → Out-of-sync list
  2. Diff each
    For each drifted app, run argocd app diff and summarize what's different from Git.✓ Copiado
    → Per-app diff summary

Resultado: Clear picture of manual drift to reconcile.

Combinações

Combine com outros MCPs para 10× de alavancagem

k8s + github

When an app is broken in cluster, open GitHub issue with pod logs

If any pod in 'payments' namespace is crashlooping, fetch logs and open a GitHub issue with them attached.✓ Copiado

Ferramentas

O que este MCP expõe

FerramentaEntradasQuando chamarCusto
kubectl command: str (full kubectl args) General cluster ops free
helm command: str Release management free
istioctl command: str Service mesh ops free
argocd command: str GitOps ops (requires argocd login in container) free

Custo e limites

O que custa rodar

Cota de API
None
Tokens por chamada
kubectl get -o yaml can be huge; prefer -o json | jq to trim
Monetário
Free, MIT
Dica
Always use -o wide or -o jsonpath=... to trim. kubectl get all is a token-bomb.

Segurança

Permissões, segredos, alcance

Escopos mínimos: Kubeconfig scoped to a least-privilege ServiceAccount
Armazenamento de credenciais: Mount ~/.kube read-only into the container
Saída de dados: Traffic to your cluster API server only
Nunca conceda: cluster-admin ServiceAccount to the kubeconfig used by the MCP

Solução de problemas

Erros comuns e correções

The connection to the server localhost:8080 was refused

kubeconfig not mounted or KUBECONFIG env var wrong in the container.

Verificar: docker exec ... kubectl config view
Command blocked in restrictive mode

Either craft a narrower command, or explicitly opt into permissive mode for that session.

Timeout on long-running command

Raise K8S_MCP_TIMEOUT. For truly long ops, run async via a Job and poll.

Alternativas

k8s-mcp-server vs. outros

AlternativaQuando usarTroca
Direct kubectl via ssh-managerYou prefer running kubectl on a jump hostLess structured; no command validation
Kagent / AIOps SaaS MCPsYou want managed service rather than self-hostedCosts money; less control

Mais

Recursos

📖 Leia o README oficial no GitHub

🐙 Ver issues abertas

🔍 Ver todos os 400+ servidores MCP e Skills