内容
<div align="center">
<img src="https://raw.githubusercontent.com/GreenerPlatform/greenerplatform-mcp/main/docs/banner.svg" alt="greenerplatform-mcp" width="100%"/>
[](https://pypi.org/project/greenerplatform-mcp/)
[](https://pypi.org/project/greenerplatform-mcp/)
[](LICENSE)
</div>
# 工具概述
MCP 服务器,暴露 GreenerPlatform 的确定性可靠性工具给任何支持 MCP 的代理 — **Cursor, Claude Desktop, VS Code, Windsurf, 或您自己的客户端.** 安装一次;工具在任何地方都可使用.
> **可在 PyPI 上获取:** `pipx install greenerplatform-mcp`
它封装了两个命令行工具:
- **`sentinel_snapshot`** — 确定性的 15 维集群健康快照
([kubectl-sentinel](https://github.com/GreenerPlatform/kubectl-sentinel)).
- **`triage_incident`** — 将警报与集群发现相关联,构建因果链,并返回 P1/P2/P3 修复计划
([incident-triage](https://github.com/GreenerPlatform/incident-triage)).
这两个工具都不包含 LLM 或任何供应商耦合。此服务器是一个薄的、中立的适配器。代理根据工具生成的证据进行推理 — 它受证据限制,不会猜测集群状态。
## 前置条件
- Python 3.10+
- `kubectl-sentinel` 和 `incident-triage` 在您的 `PATH` 上
(或设置 `SENTINEL_BIN` / `TRIAGE_BIN` 到它们的位置)
- `kubectl` + `jq` 用于实时集群快照
## 安装
```bash
pipx install greenerplatform-mcp
# 或: pip install greenerplatform-mcp
```
## 配置您的代理
**Cursor** — `~/.cursor/mcp.json` (或项目 `.cursor/mcp.json` ):
```json
{
"mcpServers": {
"greenerplatform": { "command": "greenerplatform-mcp" }
}
}
```
**Claude Desktop** — `claude_desktop_config.json`:
```json
{
"mcpServers": {
"greenerplatform": { "command": "greenerplatform-mcp" }
}
}
```
任何其他 MCP 客户端都使用相同的模式:通过 stdio 运行 `greenerplatform-mcp`。
## 工具
| 工具 | 参数 | 返回 |
|---|---|---|
| `sentinel_snapshot` | `namespace?`, `context?`, `resource?` | 集群健康 JSON |
| `triage_incident` | `alert`, `sentinel_json?`, `namespace?`, `context?` | 诊断 JSON (原因 + 修复计划) |
如果 `triage_incident` 在没有 `sentinel_json` 的情况下被调用,它会首先收集一个新的快照
(需要集群访问)。
## 版本保护
过时的 CLI 会静默地发出较少的检查 — 例如,`kubectl-sentinel` 1.1.0
返回 15 个健康维度中的 10 个。为了防止代理根据不完整的快照进行推理,服务器会检查每个 CLI 的 `--version`,如果它低于预期的最小值,则在工具的 JSON 输出中添加一个非破坏性的 `warnings` 数组:
```json
{ "warnings": ["kubectl-sentinel 1.1.0 比预期的 1.2.1 更旧;输出可能缺少检查 — 更新 kubectl-sentinel"] }
```
发现结果仍然返回;警告只是标志它们可能是部分的。设置
`MIN_SENTINEL_VERSION` / `MIN_TRIAGE_VERSION` 以更改预期的最小值。
## 环境
| 变量 | 默认值 | 目的 |
|---|---|---|
| `SENTINEL_BIN` | `kubectl-sentinel` 在 PATH 上 | sentinel 二进制文件的路径 |
| `TRIAGE_BIN` | `incident-triage` 在 PATH 上 | triage 二进制文件的路径 |
| `GP_MCP_TIMEOUT` | `90` | 每个命令的超时(秒) |
| `MIN_SENTINEL_VERSION` | `1.2.1` | 如果安装的 sentinel 较旧,则警告 |
| `MIN_TRIAGE_VERSION` | `1.2.1` | 如果安装的 triage 较旧,则警告 |
## 发布
发布会自动通过 GitHub Actions 使用 **Trusted Publishing**
(OIDC)发布到 PyPI — 不会在任何地方存储 API 令牌。
一次性设置(在 [pypi.org](https://pypi.org) 上):
1. 登录 → *您的项目* → *发布* → *添加待处理发布者*。
2. 项目名称 `greenerplatform-mcp`,所有者 `GreenerPlatform`,仓库 `greenerplatform-mcp`,
工作流 `publish.yml`,环境 `pypi`。
要发布版本:
```bash
# 在 pyproject.toml 中增加版本号,提交,然后:
git tag v0.1.0 && git push origin v0.1.0
gh release create v0.1.0 --generate-notes
```
`发布到 PyPI` 工作流会构建、运行 `twine check` 并发布。首次发布后,`pipx install greenerplatform-mcp` 可用于任何人。
## 许可证
Apache-2.0. 查看 `LICENSE`、`NOTICE` 和项目
[商标政策](https://github.com/GreenerPlatform/kubectl-sentinel/blob/main/TRADEMARKS.md)。