内容
# dive-mcp
[](https://github.com/codenio/dive-mcp/actions/workflows/ci.yml)
[](https://github.com/codenio/dive-mcp/actions/workflows/dive-compat.yml)
[](LICENSE)
[](https://go.dev/)
[](https://github.com/codenio/dive-mcp/releases)
[](https://pkg.go.dev/github.com/codenio/dive-mcp/cmd/dive-mcp)
[](https://modelcontextprotocol.io)
[](https://github.com/wagoodman/dive)
[](https://codenio.github.io/dive-mcp/)
用于 [`dive`](https://github.com/wagoodman/dive) 的 MCP 服务器 — 检查容器镜像层,查找浪费的空间,并运行 AI 编码助手中的 CI 样式效率检查。
**dive 兼容性:** [`dive`](https://github.com/wagoodman/dive) v0.12.0 – v0.13.x(CI 测试)。使用您已安装的 `dive` 二进制文件 — 不捆绑。[详情 →](docs/dive-compatibility.md)
## 快速开始
**1. 安装前提条件**
```sh
# dive — https://github.com/wagoodman/dive
brew install dive # macOS
# 或:https://github.com/wagoodman/dive#installation
# Docker 或 Podman 必须运行以进行镜像分析
docker info >/dev/null
```
**2. 安装 dive-mcp**
```sh
go install github.com/codenio/dive-mcp/cmd/dive-mcp@latest
dive-mcp --version
```
**3. 添加到您的 MCP 客户端**
**Cursor** — `.cursor/mcp.json`:
```json
{
"mcpServers": {
"dive-mcp": {
"command": "dive-mcp",
"args": []
}
}
}
```
**Claude Code**:
```sh
claude mcp add dive-mcp -- dive-mcp
```
**Codex** — `~/.codex/config.toml`:
```toml
[mcp_servers.dive-mcp]
command = "dive-mcp"
args = []
```
Claude Desktop 和环境变量:[docs/configuration.md](docs/configuration.md) · [`examples/`](examples/)
**4. 分析镜像**
重启您的 MCP 客户端,然后询问您的助手:
> 使用 dive-mcp 分析 `alpine:latest` 并告诉我效率得分和最浪费的文件。
助手可以调用 `analyze_image`、`list_layers`、`get_wasted_space` 和 `ci_check`。有关完整的工具参考,请参见 [docs/tools.md](docs/tools.md)。
## 工具
- `analyze_image` — 镜像大小、效率得分、浪费字节、层数
- `list_layers` — 每层的摘要、大小和构建命令
- `get_wasted_space` — 跨层的顶部重复文件
- `ci_check` — 根据效率和浪费阈值进行通过/失败
有关参数和输出字段,请参见 [docs/tools.md](docs/tools.md)。
从源代码构建:`git clone` → `make build` — 请参见 [docs/development.md](docs/development.md)。
## 文档
完整文档站点:**[codenio.github.io/dive-mcp](https://codenio.github.io/dive-mcp/)**
| 文档 | 内容 |
|---|---|
| [configuration.md](docs/configuration.md) | 客户端设置和环境变量 |
| [tools.md](docs/tools.md) | MCP 工具参考 |
| [development.md](docs/development.md) | 构建、测试、预提交钩子 |
| [architecture.md](docs/architecture.md) | dive-mcp 如何调用和解析 dive |
| [dive-compatibility.md](docs/dive-compatibility.md) | 支持的 dive 版本 |
| [releasing.md](docs/releasing.md) | 维护者发布工作流 |
本地预览:`pip install -r requirements-docs.txt && make docs`
## 贡献
请参见 [CONTRIBUTING.md](CONTRIBUTING.md)。
## 许可证
MIT — 请参见 [LICENSE](LICENSE)。