Docker Explorer
A Model Context Protocol server that provides tools for interacting with Docker images, containers, and registries, enabling AI assistants to search, analyze, and manage Docker resources through a standardized interface.
README
🐳 Docker Explorer MCP Server
<div align="center">
</div>
📋 Overview
Docker Explorer is a powerful Model Context Protocol (MCP) server that provides tools and resources for interacting with Docker images, containers, and registries. This server enables AI assistants like Claude to search for, analyze, and interact with Docker resources through a standardized interface, making container management and exploration more accessible.
✨ Features
Core Features
- Search for Docker images across registries
- Search for specific tags of Docker images
- Search for Docker Hub users/organizations
- Get detailed metadata about Docker images
- Analyze Dockerfile content
- Compare Docker images
Advanced Tools
- 🔒 Security Scanner: Analyze Docker images for known vulnerabilities and security issues
- 📦 Image Size Optimizer: Get recommendations for reducing Docker image size
- 📄 Docker Compose Generator: Generate docker-compose.yml files for your applications
- 📊 Container Runtime Analyzer: Get insights about container runtime behavior and resource usage
- 🔍 Image Comparison Tool: Compare two Docker images and highlight their differences
- 📜 Dockerfile Generator: Create Dockerfiles from natural language application descriptions
🚀 Installation
Prerequisites
- Python 3.10 or higher
- MCP Python SDK
- Required Python packages:
requests,pydantic
Setup
- Clone this repository:
git clone https://github.com/yourusername/docker-mcp-server.git
cd docker-mcp-server
- Create a virtual environment:
python -m venv .venv310
source .venv310/bin/activate # On Windows: .venv310\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
Or install individual packages:
pip install anthropic-mcp requests pydantic
💻 Usage
Running the Server
You can run the server directly from the command line:
python docker_explorer.py
This will start the MCP server on the default port (5000).
Integrating with Claude Desktop
To use the Docker Explorer MCP server with Claude Desktop:
- Update the Claude Desktop configuration:
- Open or create the
claude_desktop_config.jsonfile in your Claude Desktop configuration directory - Add the Docker Explorer server configuration
- Open or create the
{
"mcp_servers": [
{
"name": "docker-explorer",
"command": ["python", "/path/to/mcpIS421/docker_explorer.py"],
"cwd": "/path/to/mcpIS421"
}
]
}
- Restart Claude Desktop to load the new configuration
Using the Tools
Once integrated with Claude Desktop, you can use the Docker Explorer tools by asking Claude questions like:
Core Tools
-
Search for Docker images:
Can you search for Python Docker images? -
Get image details:
What are the details of the python:3.11-slim image? -
Find available tags:
What tags are available for the nginx image?
Advanced Tools
-
Security Scanner:
Scan the security of the nginx image -
Image Size Optimizer:
How can I reduce the size of my python:3.9 image? -
Docker Compose Generator:
Generate a docker-compose file for nginx with port 8080:80 -
Container Runtime Analyzer:
Analyze the runtime behavior of mysql:5.7 as a database
👷 Development
Project Structure
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
Adding New Features
To add a new tool to the Docker Explorer MCP server:
- Implement the tool function in
docker_explorer.pyusing the MCP tool decorator:
@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)}"
- Follow these best practices for tool implementation:
- Keep output concise and formatted for Claude Desktop
- Handle exceptions gracefully
- Provide clear parameter descriptions
- Return well-structured results
Testing
-
Manual Testing:
- Run the server:
python docker_explorer.py - Test with Claude Desktop by asking relevant questions
- Run the server:
-
Debugging:
- Check terminal output for any errors
- Verify tool responses in Claude Desktop
- Adjust output formatting if Claude has capacity constraints
📚 API Documentation
Core Tools
search_images
- Description: Search for Docker images across registries
- Parameters:
query(string): Search query for Docker imageslimit(integer, default=10): Maximum number of results to return
- Returns: List of Docker images with metadata
search_tags
- Description: Search for specific tags of a Docker image
- Parameters:
image_name(string): Name of the Docker imagetag_pattern(string, default=""): Pattern to match tags againstlimit(integer, default=25): Maximum number of results to return
- Returns: List of matching tags
get_image_details
- Description: Get detailed information about a Docker image
- Parameters:
image_name(string): Name of the Docker imagetag(string, default="latest"): Tag of the Docker image
- Returns: Detailed image information
Advanced Tools
scan_security
- Description: Analyze Docker images for known vulnerabilities and security issues
- Parameters:
image_name(string): Name of the Docker imagetag(string, default="latest"): Tag of the Docker image to scan
- Returns: Security analysis report with recommendations
optimize_image_size
- Description: Analyze a Docker image and suggest ways to reduce its size
- Parameters:
repository_url(string): Full URL to a Docker Hub repositorytag(string, default="latest"): Tag of the Docker image to analyze
- Returns: Size optimization recommendations
generate_docker_compose
- Description: Generate a docker-compose.yml file based on an image
- Parameters:
repository_url(string): Full URL to a Docker Hub repositorytag(string, default="latest"): Tag of the Docker imageport_mapping(string, default=""): Optional port mapping (e.g., '8080:80')environment_variables(string, default=""): Optional environment variablesinclude_db(boolean, default=false): Whether to include a database service
- Returns: Generated docker-compose.yml content
analyze_runtime
- Description: Analyze how a container might behave at runtime
- Parameters:
image_name(string): Name of the Docker imagetag(string, default="latest"): Tag of the Docker imageapp_type(string, default="web"): Application type (web, database, cache, api, batch)
- Returns: Runtime analysis with resource usage predictions and recommendations
compare_images
- Description: Compare two Docker images and highlight the differences
- Parameters:
image1(string): First Docker image to compare (e.g., 'nginx:1.21' or 'user/repo:tag')image2(string): Second Docker image to compare (e.g., 'nginx:1.22' or 'user/repo:tag')
- Returns: Detailed comparison report highlighting differences in size, layers, configuration, and compatibility
generate_dockerfile
- Description: Generate a Dockerfile based on application requirements described in natural language
- Parameters:
app_description(string): Description of the application to containerize (e.g., 'Python Flask web app with Redis')app_type(string, default="web"): Application type (web, api, database, worker, static)base_image(string, default=""): Optional base image to use (e.g., 'python:3.9-alpine')include_comments(boolean, default=true): Whether to include explanatory comments in the Dockerfile
- Returns: Generated Dockerfile with usage instructions
🔒 Security Considerations
The Docker Explorer MCP server is designed for educational and development purposes. When using it:
- Do not expose sensitive credentials or API keys
- Be cautious when generating and running Docker Compose files
- Always review security recommendations before implementation
📌 License
MIT
👥 Contributing
Contributions are welcome! Please feel free to submit a Pull Request with new tools or improvements to existing functionality.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。