Skip to main content
Glama

Docker Explorer

by jar285

🐳 Docker Explorer MCP 服务器

Docker 资源管理器Python执照

📋 概述

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 或更高版本
  • MCP Python SDK
  • 所需的 Python 包: requestspydantic

设置

  1. 克隆此存储库
git clone https://github.com/yourusername/docker-mcp-server.git cd docker-mcp-server
  1. 创建虚拟环境
python -m venv .venv310 source .venv310/bin/activate # On Windows: .venv310\Scripts\activate
  1. 安装依赖项
pip install -r requirements.txt

或者安装单独的包:

pip install anthropic-mcp requests pydantic

💻 使用方法

运行服务器

您可以直接从命令行运行服务器:

python docker_explorer.py

这将在默认端口(5000)上启动 MCP 服务器。

与 Claude Desktop 集成

要将 Docker Explorer MCP 服务器与 Claude Desktop 一起使用:

  1. 更新 Claude 桌面配置
    • 在 Claude Desktop 配置目录中打开或创建claude_desktop_config.json文件
    • 添加 Docker Explorer 服务器配置
{ "mcp_servers": [ { "name": "docker-explorer", "command": ["python", "/path/to/mcpIS421/docker_explorer.py"], "cwd": "/path/to/mcpIS421" } ] }
  1. 重新启动 Claude Desktop以加载新配置

使用工具

与 Claude Desktop 集成后,您可以通过向 Claude 询问以下问题来使用 Docker Explorer 工具:

核心工具
  1. 搜索 Docker 镜像
    Can you search for Python Docker images?
  2. 获取图像详细信息
    What are the details of the python:3.11-slim image?
  3. 查找可用标签
    What tags are available for the nginx image?
高级工具
  1. 安全扫描器
    Scan the security of the nginx image
  2. 图像尺寸优化器
    How can I reduce the size of my python:3.9 image?
  3. Docker Compose 生成器
    Generate a docker-compose file for nginx with port 8080:80
  4. 容器运行时分析器
    Analyze the runtime behavior of mysql:5.7 as a database

👷 开发

项目结构

docker-explorer-mcp/ ├── docker_explorer.py # Main server implementation with all tools ├── requirements.txt # Project dependencies ├── .gitignore # Git ignore file └── docs/ # Documentation ├── server_guide.md # Guide for setting up and using the server ├── new_tools_suggestions.md # Ideas for additional tools └── docker_mcp_server_project.md # Project overview

添加新功能

要向 Docker Explorer MCP 服务器添加新工具:

  1. 使用 MCP 工具装饰器实现docker_explorer.py中的工具功能:
@mcp.tool() def my_new_tool( param1: str = Field(description="Description of param1"), param2: int = Field(default=10, description="Description of param2") ) -> str: """Description of what your tool does""" try: # Implementation logic here result = f"Your formatted result" return result except Exception as e: return f"Error in my_new_tool: {str(e)}"
  1. 请遵循以下工具实施的最佳实践:
    • 保持输出简洁并格式化为 Claude Desktop
    • 优雅地处理异常
    • 提供清晰的参数描述
    • 返回结构良好的结果

测试

  1. 手动测试
    • 运行服务器: python docker_explorer.py
    • 通过询问相关问题使用 Claude Desktop 进行测试
  2. 调试
    • 检查终端输出是否有任何错误
    • 在 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 存储库的完整 URL
    • tag (字符串,默认值为“latest”):要分析的 Docker 镜像的标签
  • 返回:尺寸优化建议
generate_docker_compose
  • 描述:根据镜像生成docker-compose.yml文件
  • 参数
    • repository_url (字符串):Docker Hub 存储库的完整 URL
    • tag (字符串,默认值为“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 请求,添加新工具或改进现有功能。

-
security - not tested
A
license - permissive license
-
quality - not tested

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 资源。

  1. 📋 概述
    1. ✨ 特点
      1. 核心功能
      2. 高级工具
    2. 🚀 安装
      1. 先决条件
      2. 设置
    3. 💻 使用方法
      1. 运行服务器
      2. 与 Claude Desktop 集成
      3. 使用工具
    4. 👷 开发
      1. 项目结构
      2. 添加新功能
      3. 测试
    5. 📚 API 文档
      1. 核心工具
      2. 高级工具
    6. 🔒 安全注意事项
      1. 📌 许可证
        1. 👥 贡献

          Related MCP Servers

          • A
            security
            A
            license
            A
            quality
            A powerful Model Context Protocol (MCP) server for Docker operations, enabling seamless container and compose stack management through Claude AI.
            Last updated -
            4
            160
            Python
            MIT License
            • Apple
          • A
            security
            F
            license
            A
            quality
            A Model Context Protocol server that enables Docker container management through natural language interactions using a custom GPT interface.
            Last updated -
            7
            7
            TypeScript
          • -
            security
            F
            license
            -
            quality
            A Model Context Protocol server that provides a comprehensive interface for interacting with the ConnectWise Manage API, simplifying API discovery, execution, and management for both developers and AI assistants.
            Last updated -
            46
            2
            Python
            • Linux
            • Apple
          • -
            security
            F
            license
            -
            quality
            A Model Context Protocol server that connects AI assistants like Claude to Notion workspaces, enabling them to view, search, create, and update Notion databases, pages, and content blocks.
            Last updated -
            275
            JavaScript
            • Apple

          View all related MCP servers

          MCP directory API

          We provide all the information about MCP servers via our MCP API.

          curl -X GET 'https://glama.ai/api/mcp/v1/servers/jar285/mcp-docker'

          If you have feedback or need assistance with the MCP directory API, please join our Discord server