finops-copilot
一个让你的集群规模恰到好处的 AI — 以及一个不会让它破坏生产环境的平台
问题:“让 AI 触碰我们的基础设施”是让一个 自信的模型在凌晨 3 点把生产环境缩容到 1 个副本的好方法。有趣的 智能体运维的工程难点不在于模型——而在于护栏。解决 方案:通过 MCP 给 AI 一个类型化、有界的集群接口, 并把安全逻辑放在服务端,让模型无法绕过 它。AI 决定改什么;平台决定它允许做什么——并拒绝其余部分, 即使被直接要求也不行。
一个 Model Context Protocol (MCP) 服务器 在实时
Kubernetes 集群上暴露五个 FinOps 工具。Claude(或任何 MCP 客户端——Claude Desktop 等)使用
它们来发现过度配置的工作负载并提出合理的缩容建议。每个
修改性调用都会在任何事情发生之前根据策略进行检查,并
默认进行试运行;不安全的更改——受保护的 prod 命名空间、
资源下限、过于激进的削减——会被服务器拒绝并写入
审计日志。
完全在笔记本电脑上运行:一个 kind 集群中预置了刻意浪费的
工作负载,一个约 120 行的 MCP 服务器,以及一个 copilot 驱动,它默认
离线运行(一个确定性 mock,因此无需 API key 即可在 CI 中运行),或当
设置 ANTHROPIC_API_KEY 时使用真实的 Claude。
它的功能
Claude / MCP client
│ calls typed tools
▼
┌─────────────── MCP server (finops-copilot) ───────────────┐
│ list_namespaces list_workloads estimate_cost │
│ recommend_rightsizing get_audit_log │
│ │
│ apply_rightsizing(…, dry_run=True) │
│ │ │
│ ▼ ┌─────────── policy.py (guardrails) ────────┐ │
│ every │ protected namespaces? resource floors? │ │
│ apply ─┤ max single-step cut? → REFUSE + audit │ │
│ └───────────────────────────────────────────┘ │
└────────────────────────┬──────────────────────────────────┘
│ kubectl (read specs / patch)
▼
kind cluster: staging (waste) · prod (protected)环节 | 为何重要 | 在此处如何运作 |
MCP,而非原始 kubectl | AI 获得类型化、可审计的操作,而不是一个开放的 shell | 五个带 schema 的工具;服务器是唯一接触集群的部分 |
服务端护栏 | 模型无法通过提示词绕过的安全机制 |
|
默认试运行 | 安全的事情就是默认的事情 |
|
一切皆审计 | “AI 试图做什么?”有答案 | 每次应用——允许、拒绝或试运行——都会追加到客户端可读的审计日志中 |
运行它
make up # kind cluster seeded with waste + Python env (MCP deps)
make demo # the copilot finds & cuts waste — OFFLINE, no API key needed
make demo-claude # real Claude drives the same MCP tools (needs ANTHROPIC_API_KEY)
make test # unit-test the guardrail policy (no cluster needed)
make down # delete the clustermake demo 在真实的 MCP 服务器上运行一个确定性 mock copilot——与 Claude 路径相同的工具、相同的护栏——因此无需密钥即可在 CI 中运行。make demo-claude 将 mock 换成 Claude,以智能体方式驱动这些工具(官方 Anthropic SDK + 其 MCP 工具运行器)。
演示证明了什么(真实输出)
针对一个预置了四个工作负载的 staging 命名空间(三个严重过度配置,一个健康)以及一个受保护的 prod:
发现浪费。 按当前请求计算,
staging每月花费 约 138 美元/月;该工具标记了三个 CPU 利用率仅为 1–4% 的工作负载,并提出 CPU 和副本削减——预计节省 约 102 美元/月(73%)。先试运行。 每次更改都是一次试运行,显示确切的差异及其每月节省。没有明确的非试运行调用,就不会应用任何更改。
平台拒绝生产环境。 当被要求也缩减
prod时,服务器拒绝——namespace 'prod' is protected。AI 提出了请求;护栏说了不。没有任何更改,甚至没有试运行。平台拒绝过于激进的削减。 当被要求将 CPU 请求骤减到
10m时,服务器拒绝——低于下限,且单步削减超过 90%。
AI 发现了浪费并提出了削减方案。平台决定了它 被允许做什么。这种分工就是全部重点。
从 Claude Desktop 使用它(真实 MCP)
这是一个真实的 MCP 服务器——让任何 MCP 客户端指向它。对于 Claude Desktop,添加到 claude_desktop_config.json:
{
"mcpServers": {
"finops": {
"command": "/path/to/mcp-finops-copilot/.venv/bin/python",
"args": ["-m", "finops.server"],
"env": { "FINOPS_CTX": "kind-mcp-finops" }
}
}
}然后问 Claude:“我的 staging 命名空间花费是多少,我可以在哪些方面安全地调整规模?”
如何映射到生产环境
演示 | 生产环境 |
kind、 | EKS / AKS / GKE 以及你的真实 Deployments |
来自预置注解的利用率 | Prometheus / metrics-server(唯一变化的是 |
| 你组织的护栏——RBAC 范围、PodDisruptionBudgets、变更窗口 |
内存中的审计日志 | 你的审计接收端(stdout → Loki、事件表等) |
示例性成本费率 | 你的提供商的真实每 vCPU / 每 GB 定价 |
布局
finops/policy.py the guardrail layer — pure, unit-tested (make test)
finops/cost.py cost model + right-sizing heuristic
finops/kube.py kubectl read/patch helpers
finops/server.py the MCP server: 5 tools, dry-run-by-default, audited
copilot/mock_agent.py deterministic offline copilot (CI-safe)
copilot/llm_agent.py real Claude via the Anthropic SDK's MCP tool-runner
copilot/driver.py picks mock vs Claude by ANTHROPIC_API_KEY
k8s/ staging (seeded waste) + prod (protected)MIT 许可。一个小的、可在笔记本电脑上运行、NDA 安全的演示,证明了一个鲜明的观点:智能体运维是一个护栏问题。给 AI 真实的操作,但让平台成为说“不”的一方。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Hosted MCP server for agent governance: MCP config audits, injection scans, scope-policy checks.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/hanumanthvendra/mcp-finops-copilot'
If you have feedback or need assistance with the MCP directory API, please join our Discord server