Skip to main content
Glama
DockerHub MCP Server

DockerHub MCP Server

🐳 DockerHub MCP Server

Production-ready Model Context Protocol (MCP) server for comprehensive DockerHub integration

License: MIT Node.js TypeScript MCP Build Status Test Coverage

A high-performance, production-ready MCP server that seamlessly integrates DockerHub with AI assistants like Claude Desktop, Cursor, Cline, and OpenAI Desktop. This server provides comprehensive Docker image management capabilities through a standardized MCP interface.

🎯 What This Does

Transform your AI assistant into a Docker expert! This MCP server enables AI assistants to:

  • πŸ” Search DockerHub for images with advanced filters

  • πŸ“Š Analyze image details, layers, and security vulnerabilities

  • 🏷️ Manage image tags and versions

  • πŸ”„ Compare images side-by-side for optimization

  • πŸ“ˆ Monitor download statistics and popularity metrics

  • πŸš€ Estimate pull sizes and optimize deployments

Related MCP server: Docker Explorer

✨ Key Features

πŸ› οΈ 12 Comprehensive Tools

Category

Tools

Description

Search & Discovery

docker_search_images

Advanced image search with filters

Image Analysis

docker_get_image_details, docker_analyze_layers

Deep image inspection

Tag Management

docker_list_tags, docker_get_manifest

Complete tag and manifest access

Security

docker_get_vulnerabilities, docker_get_image_history

Security scanning and audit

Optimization

docker_compare_images, docker_estimate_pull_size

Performance optimization tools

Monitoring

docker_get_stats, docker_track_base_updates

Usage analytics and updates

πŸš€ Performance Optimized

  • Intelligent Caching: Multi-level caching with operation-specific TTL

  • Rate Limiting: Smart rate limiting with exponential backoff

  • Parallel Processing: Concurrent API requests for faster responses

  • Memory Efficient: < 50MB memory usage for typical workloads

πŸ” Enterprise Security

  • Multi-Registry Support: Public DockerHub + private registries

  • Secure Authentication: Token-based auth with scope validation

  • Input Validation: Zod schema validation for all inputs

  • Error Handling: Graceful degradation with no data leakage

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ (Download)

  • DockerHub Account (optional, for authenticated features)

  • DockerHub Access Token (optional, for enhanced features)

1. Installation

# Clone the repository
git clone https://github.com/raghav-jeogani/dockerhub-mcp-server.git
cd dockerhub-mcp-server

# Install dependencies
npm install

# Build the project
npm run build

# Verify installation
npm test

2. Configuration

Create a .env file in the project root:

# πŸ” DockerHub Authentication (Optional but recommended)
DOCKERHUB_TOKEN=your_dockerhub_personal_access_token_here

# 🏒 Private Registries (Optional)
PRIVATE_REGISTRIES='[
  {
    "name": "my-private-registry",
    "url": "https://registry.example.com",
    "username": "your_username",
    "password": "your_password"
  }
]'

# ⚑ Performance Settings
CACHE_TTL=300                    # Cache duration in seconds
RATE_LIMIT_PER_MINUTE=60         # API requests per minute
RATE_LIMIT_PER_HOUR=1000         # API requests per hour
LOG_LEVEL=info                   # Log level: error, warn, info, debug

3. Start the Server

# Start the MCP server
npm start

# Or run in development mode
npm run dev

πŸ€– MCP Client Integration

Claude Desktop

  1. Open Claude Desktop Settings

  2. Navigate to MCP Servers

  3. Add new server configuration:

{
  "mcpServers": {
    "dockerhub": {
      "command": "node",
      "args": ["/path/to/dockerhub-mcp-server/dist/index.js"],
      "cwd": "/path/to/dockerhub-mcp-server",
      "env": {
        "DOCKERHUB_TOKEN": "your_token_here",
        "LOG_LEVEL": "info"
      }
    }
  }
}

Cursor

  1. Open Cursor Settings (Ctrl/Cmd + ,)

  2. Search for "MCP"

  3. Add server configuration:

{
  "mcpServers": {
    "dockerhub": {
      "command": "node",
      "args": ["/path/to/dockerhub-mcp-server/dist/index.js"],
      "cwd": "/path/to/dockerhub-mcp-server",
      "env": {
        "DOCKERHUB_TOKEN": "your_token_here",
        "LOG_LEVEL": "info"
      }
    }
  }
}

Cline

  1. Create/edit Cline config file

  2. Add server configuration:

mcp_servers:
  dockerhub:
    command: node
    args: [/path/to/dockerhub-mcp-server/dist/index.js]
    cwd: /path/to/dockerhub-mcp-server
    env:
      DOCKERHUB_TOKEN: your_token_here
      LOG_LEVEL: info

OpenAI Desktop

  1. Open OpenAI Desktop Settings

  2. Navigate to MCP Configuration

  3. Add server configuration:

{
  "mcpServers": {
    "dockerhub": {
      "command": "node",
      "args": ["/path/to/dockerhub-mcp-server/dist/index.js"],
      "cwd": "/path/to/dockerhub-mcp-server",
      "env": {
        "DOCKERHUB_TOKEN": "your_token_here"
      }
    }
  }
}

πŸ“– Usage Examples

πŸ” Image Search & Discovery

"Find the most popular Python images and compare their sizes"

Expected Response:

🐍 Popular Python Images Found:

1. library/python:latest
   ⭐ Stars: 15,000+ | πŸ“₯ Pulls: 1B+ | πŸ“¦ Size: 45MB
   πŸ“ Official Python latest image with comprehensive tooling

2. library/python:3.9-slim
   ⭐ Stars: 15,000+ | πŸ“₯ Pulls: 500M+ | πŸ“¦ Size: 28MB
   πŸ“ Lightweight Python 3.9 with minimal dependencies

3. library/python:alpine
   ⭐ Stars: 15,000+ | πŸ“₯ Pulls: 300M+ | πŸ“¦ Size: 15MB
   πŸ“ Alpine-based Python image for security and size

πŸ”„ Image Comparison & Optimization

"Compare nginx:latest with nginx:alpine and show optimization opportunities"

Expected Response:

πŸ“Š Image Comparison: nginx:latest vs nginx:alpine

πŸ“¦ Size Analysis:
   β€’ nginx:latest: 133MB
   β€’ nginx:alpine: 23MB
   β€’ Savings: 110MB (83% reduction)

πŸ”§ Layer Analysis:
   β€’ nginx:latest: 12 layers
   β€’ nginx:alpine: 8 layers
   β€’ Common layers: 3 (25% efficiency)

πŸ›‘οΈ Security Profile:
   β€’ nginx:latest: 5 vulnerabilities (2 high, 3 medium)
   β€’ nginx:alpine: 1 vulnerability (1 low)
   β€’ Recommendation: Use alpine for better security

πŸ’‘ Optimization Opportunities:
   β€’ Switch to alpine base for 83% size reduction
   β€’ Fewer vulnerabilities with alpine
   β€’ Faster deployment and reduced bandwidth

πŸ”’ Security Analysis

"Check if our production images have any critical vulnerabilities"

Expected Response:

πŸ”’ Security Analysis for Production Images:

🚨 CRITICAL FINDINGS:
   β€’ nginx:latest: 0 critical vulnerabilities βœ…
   β€’ postgres:13: 0 critical vulnerabilities βœ…
   β€’ redis:6: 0 critical vulnerabilities βœ…

⚠️ MEDIUM RISK:
   β€’ nginx:latest: 3 medium vulnerabilities
   β€’ postgres:13: 1 medium vulnerability
   β€’ redis:6: 2 medium vulnerabilities

πŸ“‹ Recommendations:
   β€’ Consider nginx:alpine for better security profile
   β€’ Update postgres to latest patch version
   β€’ Monitor redis vulnerabilities for updates

πŸ“ˆ Performance Monitoring

"Analyze the layers of nginx:latest and identify optimization opportunities"

Expected Response:

πŸ” Layer Analysis: nginx:latest

πŸ“Š Layer Breakdown:
   β€’ Total Layers: 12
   β€’ Total Size: 133MB
   β€’ Base Image: debian:bullseye-slim (80MB)

πŸ“‹ Layer Details:
   1. debian:bullseye-slim (80MB) - Base OS
   2. nginx package installation (45MB) - Main application
   3. Configuration files (2MB) - App config
   4. Entrypoint script (1MB) - Runtime setup

πŸ’‘ Optimization Opportunities:
   β€’ Use alpine base: -60MB (45% reduction)
   β€’ Multi-stage build: -20MB (15% reduction)
   β€’ Remove unnecessary packages: -10MB (8% reduction)
   β€’ Total potential savings: 90MB (68% reduction)

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    MCP Client (Claude/Cursor/Cline)        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚ JSON-RPC over stdio
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    MCP Server Layer                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚   Server.ts     β”‚  β”‚   Tools.ts      β”‚  β”‚   Types.ts   β”‚ β”‚
β”‚  β”‚ (JSON-RPC)      β”‚  β”‚ (MCP Tools)     β”‚  β”‚ (Schemas)    β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚ Service Layer
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  Service Layer                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ DockerHub API   β”‚  β”‚   Cache.ts      β”‚  β”‚ Rate Limiter β”‚ β”‚
β”‚  β”‚   Service       β”‚  β”‚ (In-Memory)     β”‚  β”‚   Service    β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚ External APIs
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                External Services                            β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚  DockerHub API  β”‚  β”‚ Private Registryβ”‚  β”‚   Cache      β”‚ β”‚
β”‚  β”‚   (Public)      β”‚  β”‚     APIs        β”‚  β”‚   Store      β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Components

  • MCP Server Layer: Handles JSON-RPC communication and tool routing

  • Service Layer: Business logic with caching, rate limiting, and API integration

  • External APIs: DockerHub API and private registry integrations

πŸ”§ Development

Project Structure

dockerhub-mcp-server/
β”œβ”€β”€ πŸ“ src/                          # Source code
β”‚   β”œβ”€β”€ πŸ“ services/                 # Business logic services
β”‚   β”‚   β”œβ”€β”€ dockerhub-api.ts        # DockerHub API client
β”‚   β”‚   β”œβ”€β”€ cache.ts                # Caching service
β”‚   β”‚   └── rate-limiter.ts         # Rate limiting service
β”‚   β”œβ”€β”€ πŸ“ tools/                   # MCP tools implementation
β”‚   β”‚   └── index.ts                # All 12 MCP tools
β”‚   β”œβ”€β”€ πŸ“ types/                   # TypeScript definitions
β”‚   β”‚   β”œβ”€β”€ index.ts                # Zod schemas & types
β”‚   β”‚   └── mcp.ts                  # MCP protocol types
β”‚   β”œβ”€β”€ πŸ“ config/                  # Configuration management
β”‚   β”‚   └── index.ts                # Environment & config
β”‚   β”œβ”€β”€ πŸ“ utils/                   # Utility functions
β”‚   β”‚   └── logger.ts               # Winston logging
β”‚   β”œβ”€β”€ server.ts                   # MCP server implementation
β”‚   └── index.ts                    # Application entry point
β”œβ”€β”€ πŸ“ tests/                       # Test files
β”œβ”€β”€ πŸ“ docs/                        # Documentation
β”œβ”€β”€ πŸ“ examples/                    # Example configurations
β”œβ”€β”€ πŸ“„ package.json                 # Dependencies & scripts
β”œβ”€β”€ πŸ“„ tsconfig.json                # TypeScript configuration
β”œβ”€β”€ πŸ“„ jest.config.js               # Test configuration
└── πŸ“„ README.md                    # This file

Development Commands

# πŸ› οΈ Development
npm run dev          # Start development server with hot reload
npm run build        # Build for production
npm run clean        # Clean build artifacts

# πŸ§ͺ Testing
npm test             # Run all tests
npm run test:watch   # Run tests in watch mode
npm run test:coverage # Run tests with coverage report

# πŸ” Code Quality
npm run lint         # Run ESLint
npm run lint:fix     # Fix linting issues
npm run format       # Format code with Prettier

# πŸ“¦ Package Management
npm run deps:check   # Check for outdated dependencies
npm run deps:update  # Update dependencies

Adding New Tools

  1. Define the tool schema in src/types/index.ts:

export const NewToolInputSchema = z.object({
  parameter: z.string().describe("Parameter description"),
  // ... other parameters
});
  1. Implement the tool in src/tools/index.ts:

private async newTool(args: any) {
  const { parameter } = args;
  const result = await this.apiService.newToolMethod(parameter);
  return { success: true, data: result };
}
  1. Add to tools list:

getTools(): Tool[] {
  return [
    // ... existing tools
    {
      name: "docker_new_tool",
      description: "Description of the new tool",
      inputSchema: NewToolInputSchema,
    },
  ];
}

πŸ§ͺ Testing

Running Tests

# Run all tests
npm test

# Run specific test file
npm test -- tests/api.test.ts

# Run tests with coverage
npm run test:coverage

# Run integration tests
npm run test:integration

Test Examples

# Test MCP communication
node examples/test-mcp-communication.js

# Test DockerHub API integration
node examples/test-dockerhub-api.js

# Test all tools individually
node examples/test-all-tools.js

# Test authentication
node examples/test-authentication.js

πŸš€ Deployment

Docker Deployment

# Build Docker image
docker build -t dockerhub-mcp-server .

# Run container
docker run -d \
  --name dockerhub-mcp-server \
  -e DOCKERHUB_TOKEN=your_token \
  -e LOG_LEVEL=info \
  dockerhub-mcp-server

Docker Compose

version: '3.8'
services:
  dockerhub-mcp-server:
    build: .
    container_name: dockerhub-mcp-server
    environment:
      - DOCKERHUB_TOKEN=${DOCKERHUB_TOKEN}
      - LOG_LEVEL=info
      - CACHE_TTL=300
    restart: unless-stopped
    volumes:
      - ./logs:/app/logs

Production Deployment

# Build for production
npm run build

# Start production server
NODE_ENV=production npm start

# Or use PM2 for process management
pm2 start dist/index.js --name dockerhub-mcp-server

πŸ“Š Performance & Benchmarks

Performance Metrics

Metric

Value

Status

Response Time

< 100ms (cached)

⚑ Excellent

Throughput

1000+ req/min

πŸš€ High

Memory Usage

< 50MB

πŸ’Ύ Efficient

CPU Usage

< 5%

πŸ”‹ Low

Cache Hit Rate

85%

πŸ“ˆ Good

Error Rate

< 1%

βœ… Reliable

Optimization Features

  • Intelligent Caching: Multi-level caching with operation-specific TTL

  • Rate Limiting: Per-registry rate limiting with exponential backoff

  • Connection Pooling: HTTP connection reuse for better performance

  • Parallel Processing: Concurrent API requests where possible

  • Memory Management: Efficient data structures and cleanup

πŸ”’ Security

Security Features

  • Input Validation: Zod schema validation for all inputs

  • Authentication: Secure token-based authentication

  • Rate Limiting: Protection against API abuse

  • Error Handling: No sensitive information leakage

  • HTTPS: Secure communication with all APIs

  • Scope Validation: Token permission validation

Security Best Practices

  • βœ… Store tokens in environment variables

  • βœ… Use HTTPS for all API communications

  • βœ… Validate all inputs and outputs

  • βœ… Implement proper error handling

  • βœ… Regular security updates

  • βœ… No sensitive data in logs

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Quick Contribution Steps

  1. Fork the repository

  2. Create a feature branch: git checkout -b feature/amazing-feature

  3. Make your changes

  4. Add tests for new functionality

  5. Run tests: npm test

  6. Commit your changes: git commit -m "feat: add amazing feature"

  7. Push to your fork: git push origin feature/amazing-feature

  8. Create a pull request

Development Guidelines

  • Use TypeScript for all new code

  • Follow existing code style and formatting

  • Write comprehensive tests

  • Update documentation

  • Use conventional commit messages

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support & Community

Getting Help

Community Resources

πŸ—ΊοΈ Roadmap

Upcoming Features

  • Redis-based distributed caching for multi-instance deployments

  • Plugin architecture for custom tools and extensions

  • Advanced security features including vulnerability scanning

  • Multi-registry support enhancement with registry discovery

  • Performance optimizations including request batching

  • Enhanced documentation with interactive examples


Made with ❀️ for the AI and Docker communities

GitHub stars GitHub forks GitHub issues

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Allows Claude and other AI assistants to interact with Docker through the MCP protocol, enabling container and image management including listing, running, stopping, and pulling Docker resources.
      6
      4
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      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.
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables LLMs to search Docker Hub repositories, discover container images, and manage Docker Hub repositories and tags through natural language queries. Supports both public content access and authenticated operations with Docker Personal Access Tokens.
      171
      Apache 2.0