Docker MCP server

Manage containers and compose stacks through natural language.
Back to servers
Provider
QuantGeekDev
Release date
Dec 04, 2024
Language
Python
Package
Stats
21.5K downloads
323 stars

The Docker MCP server lets you manage Docker containers and compose stacks directly through Claude AI. It provides tools for container creation, deploying compose stacks, retrieving logs, and monitoring container status.

Installation

Prerequisites

Before installing the Docker MCP server, ensure you have:

  • UV (package manager)
  • Python 3.12+
  • Docker Desktop or Docker Engine
  • Claude Desktop

Installing via Smithery

The easiest way to install Docker MCP for Claude Desktop is through Smithery:

npx @smithery/cli install docker-mcp --client claude

Manual Installation

To manually set up the Docker MCP server, add the following configuration to your Claude Desktop config file:

MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "docker-mcp": {
      "command": "uvx",
      "args": [
        "docker-mcp"
      ]
    }
  }
}

Using Docker MCP

The Docker MCP server provides several tools that allow Claude to manage your Docker environment.

Creating Containers

Use the create-container tool to create and run a standalone Docker container:

{
    "image": "image-name",
    "name": "container-name",
    "ports": {"80": "80"},
    "environment": {"ENV_VAR": "value"}
}

You can ask Claude to create containers by specifying the image, container name, port mappings, and environment variables you need.

Deploying Compose Stacks

The deploy-compose tool allows you to deploy multi-container applications with Docker Compose:

{
    "project_name": "example-stack",
    "compose_yaml": "version: '3.8'\nservices:\n  service1:\n    image: image1:latest\n    ports:\n      - '8080:80'"
}

Simply provide a project name and the compose YAML configuration for your stack.

Retrieving Container Logs

To view logs from a specific container, use the get-logs tool:

{
    "container_name": "my-container"
}

This helps you troubleshoot issues or monitor container output.

Listing Containers

The list-containers tool shows all your Docker containers and their status:

{}

No additional parameters are required - Claude will retrieve and display the full list of containers.

Debugging

If you need to debug the MCP server, you can use the MCP Inspector:

npx @modelcontextprotocol/inspector uv --directory <path-to-docker-mcp> run docker-mcp

This will provide a URL to access the debugging interface where you can monitor requests and responses between Claude and the MCP server.

Limitations

The current version has some limitations to be aware of:

  • No built-in environment variable support for containers
  • No volume management
  • No network management
  • No container health checks
  • No container restart policies
  • No container resource limits

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later