green-mcp
Measures CPU energy and LLM token usage of programs to enable cost-efficient refactoring, using real hardware telemetry and a non-blocking token proxy.
README
Green Agent
A pluggable MCP server that measures two efficiency axes of a program and refactors it to be cheaper while preserving behavior:
- CPU energy — joules the code actually consumes, from real hardware telemetry (AMD uProf / Linux RAPL / macOS powermetrics), chosen automatically for the host.
- LLM tokens — the token usage of a program that calls LLMs (input/output/cache/reasoning), measured provider-neutrally and non-blockingly.
Defining principle: measure, never estimate. Every claim is a measurement with the command, the number, and its run-to-run uncertainty — or it's labeled an estimate. The comparison verdict is a real statistical test (Welch's t with the idle-baseline uncertainty folded in), not a heuristic.
Quick start
pipx install green-mcp # provides the `green-mcp` command (stdlib + mcp only)
Mount it in your IDE (configs in deploy/):
| IDE | File |
|---|---|
| Claude Code | .mcp.json |
| Cursor | .cursor/mcp.json |
| OpenAI Codex | ~/.codex/config.toml (codex mcp add green -- green-mcp) |
| Google Antigravity | ~/.gemini/config/mcp_config.json |
Then ask your agent to measure or compare energy/tokens of a command. See
deploy/README.md for the full mount + harness guide.
Tools
measure_energy · compare_energy · measure_tokens · compare_tokens ·
verify_equivalence · energy_backend_info
Requirements (what each part needs to actually work)
No server to host. green-mcp is not a web service — your IDE launches it as a local stdio subprocess. There's no cloud, no account, and no LLM key needed for the measurement server itself.
| To run the server | Python 3.10+, pip install green-mcp. That's it — tools mount immediately. |
|---|
Energy axis — needs a power-sensor backend on the host (the largest prerequisite):
- Windows + AMD → install AMD uProf separately (driver-based; admin to install). Not bundled.
- Linux → reads
/sys/class/powercap(RAPL); no extra install, butenergy_ujis root-only on some distros. - macOS → uses the built-in
powermetrics, which requires root / passwordless sudo. - No reachable sensor (a VM, a container, a locked-down machine) → energy tools report
energy_available: falseand refuse to estimate. Energy generally does NOT work in Docker/CI — containers and VMs have no power-sensor passthrough. Use the token axis there. - The measured command runs locally (arbitrary commands → use in a trusted environment only).
Token axis — no special hardware, works anywhere, but:
- The target program must read its LLM endpoint from an env var (
ANTHROPIC_BASE_URL,OPENAI_BASE_URL, …) so we can route it through the counting proxy. A hardcoded endpoint won't be measured (reports 0 calls). - Measuring runs the target's real LLM calls — the proxy forwards to the real provider, so the target's API key is billed as usual, and network access to the provider is required.
Bundled agent (optional) — pip install green-mcp[agent] adds the Claude Agent SDK and needs
Anthropic credentials. The MCP server alone needs none.
Honest scope
- Energy is CPU package energy (+DRAM on RAPL) — not carbon, not whole-system.
- Numbers from different backends are not comparable.
- Only the AMD/uProf backend is validated for repeatability on real hardware; Linux/macOS are written and unit-tested but unverified on metal, and no backend is yet cross-validated against a wall power meter. The token measurer is validated against a local fake upstream, not a live provider. These gaps are tracked, not hidden.
Development
python -m venv .venv && .venv/Scripts/pip install -e ".[dev]"
.venv/Scripts/python -m pytest -q # unit tests
.venv/Scripts/python -m pytest -m integration # real-hardware (needs AMD uProf)
Architecture and decisions live in North Star.md, Green.md,
and docs/. Licensed under MIT.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器