🐳 Docker Explorer MCP 服务器
📋 概述
Docker Explorer 是一个强大的模型上下文协议 (MCP) 服务器,提供与 Docker 镜像、容器和镜像仓库交互的工具和资源。该服务器使 Claude 等 AI 助手能够通过标准化界面搜索、分析和与 Docker 资源交互,从而更轻松地管理和探索容器。
✨ 特点
核心功能
跨注册表搜索 Docker 镜像
搜索 Docker 镜像的特定标签
搜索 Docker Hub 用户/组织
获取有关 Docker 镜像的详细元数据
分析 Dockerfile 内容
比较 Docker 镜像
高级工具
🔒 安全扫描器:分析 Docker 镜像中已知的漏洞和安全问题
📦 图像大小优化器:获取有关减少 Docker 图像大小的建议
📄 Docker Compose Generator :为你的应用程序生成 docker-compose.yml 文件
📊 容器运行时分析器:获取有关容器运行时行为和资源使用情况的见解
🔍 镜像比较工具:比较两个 Docker 镜像并突出显示它们的差异
📜 Dockerfile Generator :根据自然语言应用程序描述创建 Dockerfile
🚀 安装
先决条件
Python 3.10 或更高版本
所需的 Python 包:
requests
、pydantic
设置
克隆此存储库:
创建虚拟环境:
安装依赖项:
或者安装单独的包:
💻 使用方法
运行服务器
您可以直接从命令行运行服务器:
这将在默认端口(5000)上启动 MCP 服务器。
与 Claude Desktop 集成
要将 Docker Explorer MCP 服务器与 Claude Desktop 一起使用:
更新 Claude 桌面配置:
在 Claude Desktop 配置目录中打开或创建
claude_desktop_config.json
文件添加 Docker Explorer 服务器配置
重新启动 Claude Desktop以加载新配置
使用工具
与 Claude Desktop 集成后,您可以通过向 Claude 询问以下问题来使用 Docker Explorer 工具:
核心工具
搜索 Docker 镜像:
Can you search for Python Docker images?获取图像详细信息:
What are the details of the python:3.11-slim image?查找可用标签:
What tags are available for the nginx image?
高级工具
安全扫描器:
Scan the security of the nginx image图像尺寸优化器:
How can I reduce the size of my python:3.9 image?Docker Compose 生成器:
Generate a docker-compose file for nginx with port 8080:80容器运行时分析器:
Analyze the runtime behavior of mysql:5.7 as a database
👷 开发
项目结构
添加新功能
要向 Docker Explorer MCP 服务器添加新工具:
使用 MCP 工具装饰器实现
docker_explorer.py
中的工具功能:
请遵循以下工具实施的最佳实践:
保持输出简洁并格式化为 Claude Desktop
优雅地处理异常
提供清晰的参数描述
返回结构良好的结果
测试
手动测试:
运行服务器:
python docker_explorer.py
通过询问相关问题使用 Claude Desktop 进行测试
调试:
检查终端输出是否有任何错误
在 Claude Desktop 中验证工具响应
如果 Claude 有容量限制,请调整输出格式
📚 API 文档
核心工具
search_images
描述:跨注册表搜索 Docker 镜像
参数:
query
(字符串):Docker 镜像的搜索查询limit
(整数,默认值=10):返回的最大结果数
返回:带有元数据的 Docker 镜像列表
search_tags
描述:搜索 Docker 镜像的特定标签
参数:
image_name
(字符串):Docker 镜像的名称tag_pattern
(字符串,默认值为“”):用于匹配标签的模式limit
(整数,默认值=25):返回的最大结果数
返回:匹配标签的列表
get_image_details
描述:获取有关 Docker 镜像的详细信息
参数:
image_name
(字符串):Docker 镜像的名称tag
(字符串,默认值为“latest”):Docker 镜像的标签
返回:详细的图像信息
高级工具
scan_security
描述:分析 Docker 镜像中已知的漏洞和安全问题
参数:
image_name
(字符串):Docker 镜像的名称tag
(字符串,默认为“latest”):要扫描的 Docker 镜像的标签
返回:带有建议的证券分析报告
optimize_image_size
描述:分析 Docker 镜像并提出减少其大小的方法
参数:
repository_url
(字符串):Docker Hub 存储库的完整 URLtag
(字符串,默认值为“latest”):要分析的 Docker 镜像的标签
返回:尺寸优化建议
generate_docker_compose
描述:根据镜像生成docker-compose.yml文件
参数:
repository_url
(字符串):Docker Hub 存储库的完整 URLtag
(字符串,默认值为“latest”):Docker 镜像的标签port_mapping
(字符串,默认值=“”):可选端口映射(例如,'8080:80')environment_variables
(字符串,默认值为“”):可选的环境变量include_db
(布尔值,默认值=false):是否包含数据库服务
返回:生成的docker-compose.yml内容
analyze_runtime
描述:分析容器在运行时的行为
参数:
image_name
(字符串):Docker 镜像的名称tag
(字符串,默认值为“latest”):Docker 镜像的标签app_type
(string, default="web"): 应用程序类型 (web, database, cache, api, batch)
返回:运行时分析,包括资源使用情况预测和建议
compare_images
描述:比较两个 Docker 镜像并突出显示差异
参数:
image1
(字符串):要比较的第一个 Docker 镜像(例如“nginx:1.21”或“user/repo:tag”)image2
(字符串):要比较的第二个 Docker 镜像(例如,'nginx:1.22' 或 'user/repo:tag')
返回:详细的比较报告,重点介绍尺寸、层、配置和兼容性方面的差异
generate_dockerfile
描述:根据自然语言描述的应用需求生成Dockerfile
参数:
app_description
(字符串):要容器化的应用程序的描述(例如,“带有 Redis 的 Python Flask Web 应用程序”)app_type
(string, default="web"): 应用程序类型 (web, api, database, worker, static)base_image
(字符串,默认值为“”):可选使用的基础图像(例如,'python:3.9-alpine')include_comments
(布尔值,默认值=true):是否在 Dockerfile 中包含解释性注释
返回:生成的 Dockerfile 及使用说明
🔒 安全注意事项
Docker Explorer MCP 服务器专为教育和开发目的而设计。使用时:
不要暴露敏感凭证或 API 密钥
生成和运行 Docker Compose 文件时要小心谨慎
实施前务必审查安全建议
📌 许可证
麻省理工学院
👥 贡献
欢迎贡献!欢迎提交 Pull 请求,添加新工具或改进现有功能。
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
模型上下文协议服务器,提供与 Docker 镜像、容器和注册表交互的工具,使 AI 助手能够通过标准化界面搜索、分析和管理 Docker 资源。
Related MCP Servers
- AsecurityAlicenseAqualityA powerful Model Context Protocol (MCP) server for Docker operations, enabling seamless container and compose stack management through Claude AI.Last updated -4390MIT License
- AsecurityFlicenseAqualityA Model Context Protocol server that enables Docker container management through natural language interactions using a custom GPT interface.Last updated -12
- -securityAlicense-qualityA Model Context Protocol server that enables AI applications to interact with Dropbox, providing tools for file operations, metadata retrieval, searching, and account management through Dropbox's API.Last updated -4MIT License
- -securityFlicense-qualityA comprehensive Model Context Protocol server implementation that enables AI assistants to interact with file systems, databases, GitHub repositories, web resources, and system tools while maintaining security and control.Last updated -331