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.
- 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
- π 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
- Python 3.10 or higher
- MCP Python SDK
- Required Python packages:
requests
,pydantic
- 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
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).
To use the Docker Explorer MCP server with Claude Desktop:
- Update the Claude Desktop configuration:
- Open or create the
claude_desktop_config.json
file 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
Once integrated with Claude Desktop, you can use the Docker Explorer tools by asking Claude questions like:
-
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?
-
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
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
To add a new tool to the Docker Explorer MCP server:
- Implement the tool function in
docker_explorer.py
using 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
-
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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
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
MIT
Contributions are welcome! Please feel free to submit a Pull Request with new tools or improvements to existing functionality.