Docker MCP Server

Docker MCP Server

Provides Docker management tools for Claude Code, enabling container, image, network, and volume operations.

Category
Visit Server

README

Docker MCP Server

A Model Context Protocol (MCP) server providing Docker management tools for Claude Code.

Overview

This MCP server exposes Docker functionality through MCP tools, allowing Claude to interact with Docker containers, images, networks, and volumes.

Features

Tools for Docker operations including:

  • Container management (list, start, stop, inspect)
  • Image management (list, pull, build)
  • Network operations
  • Volume management
  • Docker Compose integration

Installation

Prerequisites

  • Python 3.11 or higher
  • Docker installed and running
  • uv package manager (recommended) or pip

Setup

# Install dependencies
uv sync

# Or with pip
pip install -e .

Usage

Option 1: Run with Docker (Recommended)

Build and Run with Docker Compose

# Build and start the container
docker-compose up -d

# View logs
docker-compose logs -f

# Stop the container
docker-compose down

Build and Run with Docker CLI

# Build the image
docker build -t docker-mcp-server .

# Run the container (Linux/macOS)
docker run -it --rm \
  -v /var/run/docker.sock:/var/run/docker.sock \
  docker-mcp-server

# Run the container (Windows)
docker run -it --rm \
  -v //var/run/docker.sock:/var/run/docker.sock \
  docker-mcp-server

Important: The -v flag mounts the Docker socket, allowing the container to manage the host's Docker daemon.

Configure with Claude Code (Docker)

# Add the Docker-based server
claude mcp add --transport stdio docker -- docker run -i --rm \
  -v /var/run/docker.sock:/var/run/docker.sock \
  docker-mcp-server

Or configure in .mcp.json:

{
  "mcpServers": {
    "docker": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-v", "/var/run/docker.sock:/var/run/docker.sock",
        "docker-mcp-server"
      ]
    }
  }
}

Option 2: Run with Python (Local Development)

Add the server to your Claude Code configuration:

claude mcp add --transport stdio docker -- python /path/to/custom-docker-mcp-server/server.py

Or configure in .mcp.json:

{
  "mcpServers": {
    "docker": {
      "command": "python",
      "args": ["/absolute/path/to/server.py"]
    }
  }
}

Standalone Testing

Test the server using MCP Inspector:

# With Docker
docker run -i --rm \
  -v /var/run/docker.sock:/var/run/docker.sock \
  docker-mcp-server | mcp-inspector

# With Python
mcp-inspector -- python server.py

Available Tools

list_containers

Lists all running Docker containers with detailed information.

Parameters: None

Returns:

  • Container ID (short form)
  • Container name
  • Image name/tag
  • Status
  • Port mappings

Example usage:

User: "Show me all running containers"
Claude: Uses list_containers tool
Result: Displays formatted list of running containers

Development

Project Structure

custom-docker-mcp-server/
├── src/                    # Business logic
│   ├── __init__.py        # Package initialization
│   └── containers.py      # Container operations
├── server.py              # Main MCP server implementation
├── pyproject.toml         # Project configuration
├── Dockerfile             # Docker image definition
├── docker-compose.yml     # Docker Compose configuration
├── .dockerignore          # Docker build exclusions
├── README.md              # This file
└── .gitignore            # Git ignore rules

Adding New Tools

Tools are implemented using the FastMCP framework with business logic separated in the src/ directory:

  1. Add business logic in appropriate module under src/ (e.g., src/containers.py)
  2. Define the MCP tool in server.py using @mcp.tool() decorator
  3. Import and call the business logic from the tool

See server.py and src/containers.py for examples.

Requirements

  • Docker Engine API access
  • Appropriate permissions to manage Docker resources

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured