finops-copilot
MCP server for Kubernetes FinOps that finds over-provisioned workloads, proposes right-sizing, and enforces safety guardrails with dry-run by default and audit logging.
README
An AI that right-sizes your cluster — and a platform that won't let it break prod
The problem: "let an AI touch our infrastructure" is a great way to get a confident model to scale prod to one replica at 3am. The interesting engineering in agentic ops isn't the model — it's the guardrails. The fix: give the AI a typed, bounded interface to your cluster over MCP, and put the safety logic server-side, where the model can't route around it. The AI decides what to change; the platform decides what it's allowed to do — and refuses the rest, even when asked directly.
A Model Context Protocol (MCP) server exposes five FinOps tools over a live
Kubernetes cluster. Claude (or any MCP client — Claude Desktop, etc.) uses
them to find over-provisioned workloads and propose right-sizing. Every
mutating call is checked against a policy before anything happens and
defaults to a dry-run; unsafe changes — a protected prod namespace, a
resource floor, an over-aggressive cut — are refused by the server and
written to an audit log.
Runs entirely on a laptop: a kind cluster seeded with deliberately wasteful
workloads, a ~120-line MCP server, and a copilot driver that runs offline by
default (a deterministic mock, so it works with no API key and in CI) or with
real Claude when ANTHROPIC_API_KEY is set.
What it does
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)
| Piece | Why it matters | How it works here |
|---|---|---|
| MCP, not raw kubectl | The AI gets typed, auditable actions, not an open shell | Five tools with schemas; the server is the only thing that touches the cluster |
| Guardrails server-side | Safety the model can't prompt its way around | apply_rightsizing runs every request through policy.py first; a refusal is a refusal |
| Dry-run by default | The safe thing is the default thing | apply_rightsizing(dry_run=True) shows the diff + saving; real applies are opt-in |
| Everything audited | "What did the AI try to do?" has an answer | Every apply — allowed, refused, or dry-run — is appended to an audit log the client can read |
Run it
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 cluster
make demo runs a deterministic mock copilot over the real MCP server —
same tools, same guardrails as the Claude path — so it works with no key and in
CI. make demo-claude swaps the mock for Claude driving the tools agentically
(official Anthropic SDK + its MCP tool-runner).
What the demo proves (real output)
Against a staging namespace seeded with four workloads (three grossly
over-provisioned, one healthy) and a protected prod:
- Finds the waste.
stagingcosts ~$138/mo at current requests; the tool flags the three workloads sitting at 1–4% CPU utilisation and proposes CPU + replica cuts — ~$102/mo (73%) in projected savings. - Dry-runs first. Every change is a dry-run showing the exact diff and its monthly saving. Nothing is applied without an explicit non-dry-run call.
- The platform refuses prod. Asked to trim
prodtoo, the server refuses —namespace 'prod' is protected. The AI asked; the guardrail said no. No change, not even a dry-run. - The platform refuses an over-aggressive cut. Asked to slash a CPU request
to
10m, the server refuses — below the floor, and a >90% single-step cut. - Every action is logged. The audit trail shows all five attempts — three dry-runs, two refusals — with reasons.
The AI found the waste and proposed the cuts. The platform decided what it was allowed to do. That division of labour is the whole point.
Use it from Claude Desktop (real MCP)
This is a real MCP server — point any MCP client at it. For Claude Desktop, add
to 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" }
}
}
}
Then ask Claude: "What's my staging namespace costing, and what can I safely right-size?"
How it maps to production
| Demo | Production |
|---|---|
kind, pause workloads |
EKS / AKS / GKE with your real Deployments |
| utilisation from a seeded annotation | Prometheus / metrics-server (the kube.py read is the only thing that changes) |
policy.py floors + protected namespaces |
your org's guardrails — RBAC scope, PodDisruptionBudgets, change windows |
| in-memory audit log | your audit sink (stdout → Loki, an events table, etc.) |
| illustrative cost rates | your provider's real per-vCPU / per-GB pricing |
Layout
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-licensed. A small, laptop-runnable, NDA-safe demo that proves one sharp idea: agentic ops is a guardrails problem. Give the AI real actions, but make the platform the thing that says no.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。