ContainMind 🐋🧠(可译为“包含思维🐋🧠”或根据上下文意译为“心智容器🐋🧠”,具体翻译需结合语境)
一个面向智能集装箱运营的通用集装箱管理MCP服务器
ContainMind是一个MCP(模型上下文协议)服务器,它为AI助手提供了跨多个容器运行时的强大容器管理能力。它能够通过自然语言交互,实现对容器化环境的无缝检查、监控和分析。
🎯 什么是ContainMind?
ContainMind填补了AI助手(如Claude)与容器运行时之间的鸿沟,使您能够通过对话界面管理和分析容器。它是一个统一的API,可与多个容器引擎配合使用,提供实时洞察和自动化功能。
🔥 它解决的问题
挑战
现代容器化应用常常面临这些问题:
- 零散的工具Docker、Podman 及其他运行时的不同命令
- 复杂的调试穿越多个容器的日志和指标进行深入分析
- 性能可见性难以快速了解资源使用情况
- 人工检查耗时的手动检查容器健康状况和配置
- 上下文切换在CLI工具和监控仪表板之间切换
解决方案
ContainMind提供:
- 统一界面 在Docker和Podman之间(未来将支持更多运行时)
- 基于人工智能的分析 通过自然语言查询
- 实时监控 带有易于解析的指标
- 自动化诊断 用于解决容器问题
- 单一入口点 对于所有集装箱操作
🚀 特性
多运行时支持
- ✅ Docker - 完全支持 Docker 引擎
- ✅ Podman - 完全兼容 Podman
- 🔄 旋转(表示循环、重复或刷新的动作) 自动检测 - 自动检测并连接到可用的运行时
- 🔌(电源插头) 可插拔架构 - 容易扩展以支持更多运行时
综合集装箱运营
📦 资源发现
- 列出所有容器(运行中的和已停止的)
- 列出容器镜像
- 列出卷及其挂载点
- 列出网络和已连接的容器
🔍 深入检查
- 详细的容器分析(配置、环境、挂载点)
- 实时资源统计(CPU、内存、网络I/O)
- 容器日志,可配置尾部长度
- 全系统信息与能力
⚡ 性能监控
- CPU使用率百分比
- 内存使用情况和限制
- 网络吞吐量(接收/发送)
- 为多个容器并行收集统计信息
🛠️ 可用工具
| 工具 | 描述 | 使用场景 |
|---|---|---|
initialize_connection | 连接到容器运行时 | 初始设置,自动检测或指定运行时 |
list_all_containers | 列出容器 | 快速查看所有/正在运行的容器 |
list_all_images | 列出图片 | 检查可用图片及尺寸 |
list_all_volumes | 列出卷 | 确定存储使用情况和孤立卷 |
list_all_networks | 列出网络 | 网络拓扑和连通性 |
analyze_container | 深层集装箱检查 | 调试配置,检查挂载点和环境变量 |
get_container_stats | 资源使用指标 | 性能监控与优化 |
get_container_logs | 获取容器日志 | 排查应用程序问题 |
get_system_info | 系统信息 | 检查总体容量和利用率 |
💡 ContainMind如何提供帮助
1. 问题分析
场景;情境你的应用程序正在崩溃
You: "Why is my mongo_local_standard container showing high memory usage?"
AI: [Uses get_container_stats + analyze_container]
"The container is using 89% of its 2GB memory limit.
Checking the configuration... no memory limit set in docker-compose.
Recommendation: Set explicit memory limits and check for memory leaks."2. 性能调优
情景;场景;情形优化资源配置
You: "Which containers are using the most CPU?"
AI: [Uses get_container_stats with all_running=True]
"Analysis of running containers:
1. kafka-1: 45% CPU - consider adding more brokers
2. redis-server: 12% CPU - within normal range
Recommendation: Kafka is CPU-bound, consider horizontal scaling."3. 快速诊断
场景;情景容器无法启动
You: "Check why weaviate_db failed to start"
AI: [Uses get_container_logs + analyze_container]
"Log analysis shows port 8080 binding failure.
Inspecting configuration... port already in use by another service.
Recommendation: Change port mapping or stop conflicting service."4. 资源清理
场景磁盘空间管理
You: "Show me unused volumes taking up space"
AI: [Uses list_all_volumes + list_all_containers]
"Found 45 anonymous volumes not attached to any containers.
Total reclaimable space: ~3.2 GB
Safe to remove: [lists volume IDs]"5. 健康监测
场景;情景主动监控
You: "Give me a health report of my container environment"
AI: [Uses get_system_info + get_container_stats]
"System Health Report:
- 7 total containers (1 running, 6 stopped)
- Memory: 8.2GB / 16GB used (51%)
- CPU: Normal load across running containers
- Network: No bottlenecks detected
Alerts: 6 stopped containers may need attention."6. 配置审计
情景;场景安全与最佳实践
You: "Check environment variables for containers with sensitive data"
AI: [Uses analyze_container for each container]
"Security audit complete:
- mongo_local_standard: Contains DB credentials in env vars
- redis-server: No authentication configured
Recommendation: Use Docker secrets or external secret management."📋 安装与设置
先决条件
- Python 3.8及以上版本
- 已安装Docker或Podman
- 访问容器运行时套接字
安装依赖项
pip install -r requirements.txt运行服务器
python containmind.py服务器启动于 http://127.0.0.1:8081 默认情况下。
使用Claude Desktop进行配置
添加到您的Claude桌面配置中(claude_desktop_config.json):
{"mcpServers": {
"docker-Mcp": {
"command": "uv",
"args": [
"run",
"--with",
"fastmcp",
"fastmcp",
"run",
"path\to\proxy.py"
],
"env": {},
"transport": "stdio"
}
}
}🔧 使用示例
自动检测运行时
# ContainMind automatically detects Docker or Podman
initialize_connection()指定运行时
# Force Docker
initialize_connection(backend="docker")
# Force Podman
initialize_connection(backend="podman")
# Custom socket
initialize_connection(base_url="unix:///run/podman/podman.sock")获取容器统计信息
# Single container
get_container_stats(container_id="mongo_local_standard")
# All running containers
get_container_stats(all_running=True, parallel=True)🏗️ 建筑学
┌─────────────────────────────────────────┐
│ AI Assistant (Claude) │
└────────────────┬────────────────────────┘
│ MCP Protocol
┌────────────────▼────────────────────────┐
│ ContainMind Server │
│ ┌─────────────────────────────────┐ │
│ │ Tool Interface Layer │ │
│ └──────────────┬──────────────────┘ │
│ ┌──────────────▼──────────────────┐ │
│ │ Container Inspector │ │
│ └──────────────┬──────────────────┘ │
│ ┌──────────────▼──────────────────┐ │
│ │ Backend Abstraction Layer │ │
│ │ ┌────────┐ ┌────────┐ │ │
│ │ │ Docker │ │ Podman │ │ │
│ │ └───┬────┘ └───┬────┘ │ │
│ └──────┼───────────────┼──────────┘ │
└─────────┼───────────────┼──────────────┘
│ │
┌─────▼─────┐ ┌────▼─────┐
│ Docker │ │ Podman │
│ Engine │ │ Runtime │
└───────────┘ └──────────┘🔐 安全考量
- ContainMind 需要访问容器运行时套接字
- 以执行它的用户/进程的相同权限运行
- 没有认证层(依赖于MCP传输安全)
- 建议:在受信任的环境中使用或添加身份验证
🚧 路线图/发展路线
- \[ \] 容器生命周期管理(启动/停止/重启)
- \[ \] 形象塑造与管理
- \[ \] 卷管理操作
- \[ \] 网络配置工具
- \[ \] 容器健康检查
- \[ \] 网页用户界面仪表板
🤝 贡献
欢迎贡献!改进方向包括:
- 额外的容器运行时支持
- 增强的指标收集
- 性能优化
- 文档改进
📄 许可证
此项目采用MIT许可证授权。
🙏 致谢
构建于:
- FastMCP - MCP服务器框架
- 容器API客户端
- Anthropic Claude(注:此处“Anthropic”为公司名,“Claude”为该公司开发的AI模型名,直接翻译为“安萨里克·克劳德”可能不符合中文表达习惯,通常我们会保留原名以体现其特定含义) - 人工智能助手集成
______________________________________________________________________
ContainMind(可译为“心智容器”或根据具体语境调整,如“思维控制”等,但直接翻译保持原样为“心智包含”可能不够贴切,需结合具体上下文) - 使集装箱管理变得对话化、智能化和高效化。 🚀(火箭、快速前进等意象的符号,无直接对应中文,可理解为“嗖”或“飞速前进”等表达快速移动的词汇,具体根据上下文确定)
