k8s AIops

io.github.AIops-tools由 GitHub 账号 AIops-tools 发布v0.16.0更新于 Oct 30, 2026

Governed Kubernetes ops — 55 MCP tools with audit, budget, undo, risk-tier audit labels.

概览

AI 生成的概览

受治理的 Kubernetes 运维 MCP 服务器,提供 55 个工具读写集群资源,并带本地审计日志、预算守卫与撤销令牌。

可以做什么
  • 列出、描述并查看 Pod、Deployment、StatefulSet、DaemonSet、Job、Service、Ingress、ConfigMap、Secret(仅名称与键)、PVC、节点、命名空间与事件
  • 执行滚动更新:查看状态与历史、暂停、恢复、设置镜像、撤销
  • 扩缩容、重启、封锁/解封节点与删除工作负载,支持 dry-run 预览并记录反向操作
  • 读取 Pod 与节点资源用量及集群健康摘要
  • 以只读方式诊断 Pod 健康与工作负载就绪情况,按最严重优先给出根因
  • 将每次调用写入本地审计数据库并标注风险等级
适用场景
适合让助手操作或排查真实 Kubernetes 集群,例如定位异常 Pod、检查滚动更新、执行常规扩缩容与重启,并希望所有操作都有记录可供事后审查。
运行要求
以 Python 包(k8s-aiops)形式本地运行,通过 uv 安装或作为插件安装;需要能访问目标集群的 kubeconfig,认证完全交由 kubeconfig 处理。K8S_AIOPS_CONFIG、K8S_AIOPS_HOME、K8S_AUDIT_APPROVED_BY、K8S_AUDIT_RATIONALE 等环境变量需在 MCP 客户端的 env 配置中设置。
安装前请注意
除读取外还会写入:扩缩容、重启、封锁/解封节点和删除都可能改动或移除工作负载。没有只读开关或审批门禁,安全性取决于所连接 kubeconfig 上下文或 ServiceAccount 的 RBAC 权限。审计记录保存在本地 SQLite 数据库中,存储不可用时真实写入会被中止。集群凭据来自 kubeconfig,工具本身不存储。

安装

在 SourceWeft 中

  1. 打开 控制台中的 k8s AIops,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

k8s-aiops

Audit availability: Real writes require a committed pending audit row and stop before contacting the platform if storage is unavailable. Reads and previews may continue with a warning; new audit rows store outcome summaries rather than full responses.

Disclaimer: This is a community-maintained open-source project and is not affiliated with, endorsed by, or sponsored by the Cloud Native Computing Foundation, the Kubernetes project, or k3s/Rancher. "Kubernetes" and "k3s" are trademarks of their respective owners. Source code is publicly auditable at github.com/AIops-tools/K8s-AIops under the MIT license.

Governed Kubernetes operations for AI agents — 55 MCP tools, every one wrapped with the bundled @governed_tool harness: a local unified audit log under ~/.k8s-aiops/, a token/runaway budget guard, undo-token recording, and a descriptive risk-tier label on every audit row. Coverage spans pods, deployments, statefulsets, daemonsets, replicasets, jobs/cronjobs, services, ingresses, endpoints, configmaps, secrets (names/keys only), PVCs/PVs/storageclasses, nodes, namespaces, events, rollouts (status/history/undo/pause/resume/set-image), pod/node describe, pod/node top, a cluster health summary, and read-only diagnostics / RCA (pod-health and workload-readiness) that flag the root cause worst-first.

Standalone: the governance harness is bundled in the package (k8s_aiops.governance) — k8s-aiops has no external skill-family dependency. Coverage focuses on common cluster operations and is not yet exhaustive.

Verification status: exercised end-to-end against a live kind cluster (v1.36); the diagnostics/RCA tools added in this release are mock-tested only. See docs/VERIFICATION.md.

What works

Any cluster a kubeconfig can reach: standard Kubernetes, k3s, EKS, GKE, AKS, kind, minikube. Authentication (client certs, tokens, EKS/GKE/AKS exec plugins) is delegated entirely to the kubeconfig.

What this tool does, and does not, decide

It delivers Kubernetes operations — reads and writes — accurately and efficiently, and records every one of them. It does not decide whether a write is allowed to happen. That is the agent's judgement, or the permission of the kubeconfig context / ServiceAccount you connect it with: point it at a context bound to a read-only RBAC role and the writes fail at the apiserver — the place that actually owns the permission.

So there is no read-only switch, no policy file, no approval gate to configure. The one thing the tool guarantees is that nothing is silent: every call, over MCP and over the CLI alike, lands an audit row in ~/.k8s-aiops/audit.db, and destructive writes still capture their before-state and record an inverse where one exists. The runaway budget guard is a safety backstop, not authorization.

Each tool declares a risk_level, kept in agreement with its [READ]/[WRITE] documentation tag by a test, and carried into the audit row as a descriptive tier — so a reviewer can see at a glance that a row was a high-risk delete. It is a label, not a gate.

Running a smaller / local model? See agent-guardrails.md — it lists the guardrails this tool now enforces for you (so you don't spend prompt budget restating them) and gives a ready-made system prompt for what's left.

Quick Start

As a Claude Code plugin

One install gives an agent both the skill and the MCP server:

/plugin marketplace add AIops-tools/marketplace/plugin install k8s-aiops@aiops-tools

The MCP server is fetched with uv and pinned to the package version this plugin declares, so an audit row can be traced back to the code that wrote it. Credentials are still configured with k8s-aiops init — see below.

As an OpenClaw plugin

The same bundle is published on ClawHub, where one install delivers the skill and its MCP server together:

bash
openclaw plugins install clawhub:@zw008/k8s-aiopsopenclaw skills info k8s-aiops          # expect: Visible to model: yes

Restart the OpenClaw gateway afterwards so it loads the plugin. The MCP server is fetched with uv, pinned to this exact release, so uvx has to be on PATH — without it the skill still installs but reports Visible to model: no. Credentials are configured exactly as below.

As a CLI or standalone MCP server

bash
uv tool install k8s-aiops
# Friendly onboarding wizard — registers your kube contexts as named targets:k8s-aiops init
# Or skip it — uses your current kube-context out of the box:k8s-aiops doctork8s-aiops pod listk8s-aiops deployment list -n default
# Read-only RCA — worst-first root-cause findings, no changes made:k8s-aiops diagnose pod-health -n prodk8s-aiops diagnose workload-readiness -n prod

To define named targets (multiple clusters/contexts), create ~/.k8s-aiops/config.yaml:

yaml
targets:  - name: prod          # used as -t prod    context: prod-eks   # a context in your kubeconfig (omit for current-context)    namespace: default  # optional default namespace    # kubeconfig: /path/to/alt/kubeconfig   # optional explicit path  - name: lab    context: k3s-lab

No secrets live in this file — credentials come from the kubeconfig.

MCP

jsonc
{  "command": "k8s-aiops",  "args": ["mcp"],  "env": { "K8S_AIOPS_CONFIG": "~/.k8s-aiops/config.yaml" }}

Note — MCP servers get a clean environment: most MCP clients spawn the server without your shell's exports, so variables like K8S_AIOPS_HOME, K8S_AUDIT_APPROVED_BY, K8S_AUDIT_RATIONALE (and KUBECONFIG, if your kubeconfig is not at ~/.kube/config) must be set in the MCP server config's env block above — values exported only in your terminal may never reach the server.

Audit & Safety

  • Every tool call is logged to ~/.k8s-aiops/audit.db (local SQLite; relocate with K8S_AIOPS_HOME).
  • Reversible writes record an inverse undo descriptor (scale_deployment → scale-back to previous; cordon_node ↔ uncordon_node).
  • Every MCP write tool takes dry_run=True and returns a {"dryRun": true, ...} preview without touching the cluster (no undo recorded for a preview).
  • delete_deployment is risk_level=high; destructive CLI commands require double confirmation, medium-risk ones (deployment scale/restart) a single confirmation, and all write commands support --dry-run.
  • All API text passes through sanitize() (output hygiene: control/format-char stripping + truncation).

See skills/k8s-aiops/SKILL.md and SECURITY.md for details.

Secrets

k8s-aiops deliberately has no encrypted secret store (no secrets.enc, no secret CLI): authentication is delegated entirely to your kubeconfig — client certificates, bearer tokens, or exec plugins (EKS/GKE/AKS) — and the tool never handles or stores cluster credentials itself. This is a documented exception to the AIops-tools line-wide encrypted-secret-store pattern.

Companion Skills

If you want…Use
Kubernetes pods / deployments / nodesk8s-aiops (this)
Hypervisor VM lifecyclea hypervisor ops skill
Backup & restorea backup ops skill

Contributing & feature requests

Coverage is intentionally focused. Missing a device, action, or feature you need? Open an issue or pull request at github.com/AIops-tools/K8s-AIops — feature requests, contributions, and comments are all welcome.

License

MIT — github.com/AIops-tools/K8s-AIops

来源:README.md,提交 9e75a59

工具

0
SourceWeft 曾在隔离沙箱中以无凭据方式启动该软件包一次,以列出其工具,但未能完成:服务器未能启动。

版本历史

4
  1. v0.16.0最新Oct 30, 2026
  2. v0.15.0Oct 15, 2026
  3. v0.14.0Oct 15, 2026
  4. v0.13.3Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分