Skip to main content
Glama
README.md
# 🐋 Docker MCP server

<!-- mcp-name: io.github.dboeckli/mcp-server-docker -->

[![CI](https://github.com/dboeckli/mcp-server-docker/actions/workflows/ci.yml/badge.svg)](https://github.com/dboeckli/mcp-server-docker/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/mcp-server-docker-dboeckli)](https://pypi.org/project/mcp-server-docker-dboeckli/)
[![ghcr.io](https://img.shields.io/badge/ghcr.io-mcp--server--docker-blue)](https://github.com/dboeckli/mcp-server-docker/pkgs/container/mcp-server-docker)
[![License: GPL-3.0-only](https://img.shields.io/github/license/dboeckli/mcp-server-docker)](LICENSE)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=dboeckli_mcp-server-docker&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=dboeckli_mcp-server-docker)

An MCP server for managing Docker with natural language — maintained, with
Buildx tooling and bounded, LLM-friendly output.

```bash
uvx --from mcp-server-docker-dboeckli mcp-server-docker
```

> **Maintenance status:** the upstream project
> [`ckreiling/mcp-server-docker`](https://github.com/ckreiling/mcp-server-docker)
> last released `v0.3.0` and is effectively unmaintained. This repository is its
> maintained continuation: it keeps the upstream Docker MCP surface and is
> released independently as `mcp-server-docker-dboeckli` (PyPI) and
> `ghcr.io/dboeckli/mcp-server-docker` (GHCR).
>
> Credit for the original server belongs to Christian Kreiling and the upstream
> contributors. Maintained by [dboeckli](https://github.com/dboeckli); not
> affiliated with or endorsed by the upstream maintainer, Docker, Inc., or the
> Model Context Protocol project. Fixes are maintained here only and are not
> contributed back upstream.

See the [Quickstart](#-quickstart) below for Claude Desktop, container and
source setups.

## 🧭 Why this repository exists

This repository keeps the upstream Docker MCP surface and adds what is needed to
run it from agent sandboxes and day-to-day LLM clients. It is based on upstream
`main` at `57a7df2` (v0.3.0) and is released independently as
`mcp-server-docker-dboeckli` (PyPI) and
`ghcr.io/dboeckli/mcp-server-docker` (GHCR).

The differences that matter in practice:

- **Buildx tooling:** builders, build history, cache usage, inspection and build logs.
- **Bounded, LLM-friendly output:** compact `summary` listings plus capped log
  and attached-run output with `truncated`/`bytes` metadata.
- **More read-only tools:** container health, processes, stats, events, disk
  usage, version and system info.
- **Read-only mode** (`--read-only`) for gateway allow-listing.
- **Docker Desktop correctness:** label filters in the CLI map form and unset
  filter fields omitted instead of sent as `null`.
- **Packaging:** PyPI package, GHCR image and an independent release history.

This is an independent downstream project, not an upstream contribution channel:
fixes are maintained here only and are not contributed back upstream. See
[docs/upstream-tracking.md](docs/upstream-tracking.md) for the repositories we
monitor and [CHANGELOG.md](CHANGELOG.md) for release history.

## đŸĒŠ What can it do?

- 🚀 Compose containers with natural language
- 🔍 Introspect & debug running containers
- 📀 Manage persistent data with Docker volumes

## ❓ Who is this for?

- Server administrators: connect to remote Docker engines for e.g. managing a
  public-facing website.
- Tinkerers: run containers locally and experiment with open-source apps
  supporting Docker.
- AI enthusiasts: push the limits of what an LLM is capable of!
- Docker sandbox users: expose the host Docker daemon and Buildx to a sandbox
  through an MCP gateway without mounting the Docker socket.

## 🍴 What this repository adds

- Buildx tools: `docker_buildx_list`, `docker_buildx_history`, and
  `docker_buildx_logs`
- Clear tool error messages, including Docker and Buildx failures
- A published container image: `ghcr.io/dboeckli/mcp-server-docker`
- A published PyPI package: `mcp-server-docker-dboeckli`
- Docker/Buildx integration tests and coverage in CI
- Automated dependency updates (Dependabot and Renovate)

## 🔭 Upstream tracking

We track the upstream base repository and, in addition, the `X1pheR` community
fork, which carries ready branches for several open upstream issues. Monitored
sources, the branch-to-issue map and the commands to check for new activity are
documented in [docs/upstream-tracking.md](docs/upstream-tracking.md).

## 🧱 Use case: Docker sandbox

This server was originally designed for direct Docker management from an MCP
client. It can also serve as the host-side bridge for a **Docker sandbox** (for
example
[opencode-sandbox-kit](https://codeberg.org/dboeckli/opencode-sandbox-kit)):

- The sandbox keeps its own isolated Docker daemon; the host Docker socket is
  **not** mounted into it and port `2375` is not exposed.
- This server runs on the host and is registered with an MCP gateway (for
  example the `sbx` MCP gateway).
- The sandbox reaches the gateway over MCP and only sees the tools the gateway
  allows.
- Read-only tools (`docker_list_*`, `docker_fetch_container_logs`,
  `docker_buildx_*`) can be allow-listed; write tools should stay behind `ask`
  or be denied.
- The Buildx tools added by this repository are meant for this setup: inspecting
  builders, build history and build logs from inside the sandbox.

This is not a sandbox boundary by itself: the host-side server still has access
to the host Docker daemon. Use the gateway's permission rules and review them.

## đŸŽī¸ Quickstart

### Install

#### Claude Desktop

On MacOS: `~/Library/Application\ Support/Claude/claude_desktop_config.json`

On Windows: `%APPDATA%/Claude/claude_desktop_config.json`

<details>
  <summary>Install from PyPI with uv (recommended)</summary>

The package is published to PyPI as
[`mcp-server-docker-dboeckli`](https://pypi.org/project/mcp-server-docker-dboeckli/).
That is fast to start (a wheel download, no clone and no build) and needs no
Git.

> The PyPI name **`mcp-server-docker`** belongs to the
> [upstream project](https://github.com/ckreiling/mcp-server-docker) and stops at
> `0.3.0`. It does not contain the Buildx tools of this repository.

If you don't have `uv` installed, follow the installation instructions for your
system:
[link](https://docs.astral.sh/uv/getting-started/installation/#installation-methods)

Then add the following to your MCP servers file:

```
"mcpServers": {
  "mcp-server-docker": {
    "command": "uvx",
    "args": [
      "--from",
      "mcp-server-docker-dboeckli==0.11.0",
      "mcp-server-docker"
    ]
  }
}
```

</details>

<details>
  <summary>Install from a GitHub release wheel</summary>

Every release attaches the built wheel and sdist. This works without PyPI and
without cloning the repository:

```bash
uvx --from https://github.com/dboeckli/mcp-server-docker/releases/download/v0.11.0/mcp_server_docker_dboeckli-0.11.0-py3-none-any.whl \
  mcp-server-docker
```

</details>

<details>
  <summary>Install from GitHub source with uv</summary>

Pins the Git tag and builds from source on first start. Use this only when you
want to run unreleased commits; it needs Git and is slower to start than the
PyPI or wheel install.

```
"mcpServers": {
  "mcp-server-docker": {
    "command": "uvx",
    "args": [
      "--from",
      "git+https://github.com/dboeckli/mcp-server-docker@v0.11.0",
      "mcp-server-docker"
    ]
  }
}
```

</details>

<details>
  <summary>Install with Docker</summary>

Purely for convenience, the server can run in a Docker container. A prebuilt
image is published to GHCR:

```bash
docker run -i --rm \
  -v /var/run/docker.sock:/var/run/docker.sock \
  ghcr.io/dboeckli/mcp-server-docker:0.11.0
```

Alternatively, build the image locally:

```bash
docker build -t mcp-server-docker:0.11.0 .
```

And then add the following to your MCP servers file:

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

Note that we mount the Docker socket as a volume; this ensures the MCP server
can connect to and control the local Docker daemon. The image does not include
the Docker CLI, so the Buildx tools only work when the server runs where the
CLI is installed.

</details>

## 📔 Resources

The server exposes resource templates rather than enumerating currently-running containers:

- `docker://containers/{container_id}/logs` (`text/plain`)
- `docker://containers/{container_id}/stats` (`application/json`)

Read either URI with a Docker container ID or name.

## 🔨 Tools

> **Breaking in 0.8.0:** every tool name is prefixed with `docker_` so the flat
> MCP gateway namespace stays collision-free (for example `list_containers` is
> now `docker_list_containers`). Update gateway allow-lists and prompts that
> name tools directly. Resource URIs and the `docker_compose` prompt are
> unchanged.

### Containers

- `docker_list_containers`
- `docker_create_container`
- `docker_run_container`
- `docker_recreate_container`
- `docker_start_container`
- `docker_fetch_container_logs`
- `docker_stop_container`
- `docker_remove_container`
- `docker_container_inspect`
- `docker_container_health`
- `docker_container_processes`
- `docker_container_stats`

`docker_container_inspect` redacts environment values like
`docker_image_inspect`. `docker_container_health` returns a compact summary
instead of the full inspect
payload: state, health status with the last health log entry, restart count,
exit code, `OOMKilled`, start/finish timestamps, image and command. It builds a
fresh response, so no environment value is included.
`docker_container_processes` is the equivalent of `docker top`.
`docker_container_stats` returns a one-shot CPU, memory, network and block-IO
snapshot (`stream=false`), so it never blocks a tool call; the
`docker://containers/{container_id}/stats`
resource stays available for clients that read resources.

`docker_run_container` with `detach=false` returns `mode: "attached"`, the
decoded `output`, the original byte count (`bytes`) and a `truncated` flag.
Only the last 20 KiB of raw output are returned, so an attached process cannot
flood the client with unbounded text. `ports` accepts JSON arrays too, e.g.
`{"80/tcp": 8080}`, `{"80/tcp": [8080, 8081]}` for several host ports, or
`{"80/tcp": ["127.0.0.1", 8080]}` for a host IP and port.

`docker_fetch_container_logs` returns at most the last 20 KiB of raw log bytes,
split on newlines into `logs`, together with `truncated` and the original byte
count (`bytes`); invalid UTF-8 is replaced.

`docker_recreate_container` keeps its original stop/remove/run behaviour by
default. With `preserve_configuration=true` it rebuilds the container from its
inspected configuration instead: environment, mounts/volume identity, networks,
ports, labels, healthcheck and restart policy are preserved, the replacement
image is checked before anything is removed, and the original configuration is
restored if creating the replacement fails. In that mode pass only
`container_id`/`name` and optionally `image` (omitted `image` reuses the current
one); explicit overrides are rejected.

Every list tool returns a single JSON array. `docker_list_containers`,
`docker_list_images` and `docker_list_volumes` accept `format`: the default
`summary` returns a compact `docker ps`-style row (no health-check logs, nested
image object, labels or digests), while `full` returns the inspect-level object
with each health-check log entry capped at 500 characters. `docker_list_containers`
mirrors `docker ps`: without filters it returns the same containers as the CLI,
and a `label` filter is sent in the CLI's map form. That matters on Docker Desktop
hosts with the Kubernetes integration: the engine hides Kubernetes containers
from unfiltered listings but reveals them for a `label` filter, so
`docker_list_containers {"all": true, "filters": {"label":
["io.kubernetes.pod.namespace=kube-system"]}}` returns them just like
`docker ps --filter label=...`. Unset filter fields are not forwarded.

### Images

- `docker_list_images`
- `docker_pull_image`
- `docker_push_image`
- `docker_build_image`
- `docker_remove_image`
- `docker_image_inspect`
- `docker_image_history`

`docker_image_inspect` replaces environment values with `<redacted>`.
`docker_image_history` is not redacted: layer `CreatedBy` commands can contain
secrets baked into the image.

### Buildx

- `docker_buildx_list`
- `docker_buildx_du`
- `docker_buildx_inspect`
- `docker_buildx_history`
- `docker_buildx_logs`

These tools invoke the `docker` CLI, so the `docker` binary (with the Buildx
plugin) must be available on `PATH`. The container image built from this
repository does not include the Docker CLI, so the Buildx tools are only usable
when the server runs where the CLI is installed.

CLI output is decoded as UTF-8 with malformed bytes replaced by `īŋŊ` (U+FFFD),
independent of the host code page, so build logs with non-UTF-8 bytes cannot
crash a tool on Windows.

`docker_buildx_logs` accepts `progress="plain"` and `progress="rawjson"`. The
`tty` mode needs a terminal, which a stdio MCP server never has, so the tool
rejects it with an explanatory error instead of calling the CLI.

### System

- `docker_system_df`
- `docker_version`
- `docker_system_info`

`docker_system_df` uses the `docker` CLI and reports the same summary as
`docker system df`, including reclaimable space. Pass `verbose=true` for the
per-image, per-container, per-volume, and build-cache detail.

`docker_system_df` and `docker_system_info` take their numbers straight from
the engine, while `docker_list_containers` mirrors `docker ps`. Some engines
(Docker Desktop's Kubernetes integration, for example) hide containers from
unfiltered container listings while still counting them in `/info` and
`/system/df`, so `system_info.ContainersRunning` can exceed the number of
containers returned without filters. Pass a `label` filter to
`docker_list_containers` to list them.

### Events

- `docker_events_list`

`docker_events_list` reports recent Docker events (`die`, `oom`, `unhealthy`,
restart loops) for a window that always ends *now*, so a call can never wait
for future
events:

- `window_seconds` (default `900`, clamped to `1..86400`) is how far back to
  look. There is no `until` parameter on purpose. The window end is rounded up
  to the next full second, so events from the current second are included.
- `limit` (default `100`, clamped to `1..1000`) keeps the **newest** events and
  sets `truncated=true` when the window holds more.
- `filters` accepts `type`, `event`, `container`, `image` and `label`, each a
  list, and maps them to repeated `--filter key=value` arguments.
- The CLI call itself is bounded too: if `docker events` does not return in
  time, the events collected so far are returned with `truncated=true` and
  `truncated_reason="timeout"` instead of a generic timeout error.

Like the Buildx tools, `docker_events_list` invokes the `docker` CLI and needs
it on `PATH`.

### Networks

- `docker_list_networks`
- `docker_network_inspect`
- `docker_create_network`
- `docker_remove_network`

`docker_network_inspect` returns the full network attributes, including driver,
IPAM configuration and connected containers.

### Volumes

- `docker_list_volumes`
- `docker_volume_inspect`
- `docker_create_volume`
- `docker_remove_volume`

`docker_volume_inspect` returns the full volume attributes, including driver,
mountpoint, labels and options.

Both inspect tools apply the same environment redaction as
`docker_container_inspect` (`<redacted>`), so the reading posture stays uniform
even if the daemon adds a `Config.Env` section.

## 📝 Prompts

### đŸŽģ `docker_compose`

Optional: turns a project name and a container description into a `plan+apply`
loop for containers, volumes, and networks. Reusing an existing project name
lets the LLM see the current state, which is useful for cleanup.

This prompt is not required to use the server; the tools work directly without
it.

## 🔒 Read-only mode

Start the server with `--read-only`, or set
`MCP_SERVER_DOCKER_READ_ONLY=1`, to expose only tools annotated with
`readOnlyHint=true`. Write and destructive tools are not registered at all:
they are absent from `tools/list` and calls to them return `Unknown tool`.

- Default: all 36 tools.
- Read-only: the 22 read-only tools, including all `docker_list_*`, log, stats,
  inspect, `docker_container_health`, `docker_events_list`, disk-usage, and
  Buildx inspection tools.
- The container log/stats resources and the `docker_compose` prompt remain
  available.

Example with `uvx`:

```json
"args": [
  "--from",
  "git+https://github.com/dboeckli/mcp-server-docker@v0.11.0",
  "mcp-server-docker",
  "--read-only"
]
```

Or with the environment variable:

```json
"env": {
  "MCP_SERVER_DOCKER_READ_ONLY": "1"
}
```

For the sbx MCP gateway, append `--read-only` to the comma-separated `--args`
list, e.g. `sbx mcp add docker --args "--from,...,mcp-server-docker,--read-only"`.

Read-only mode is a best-effort guardrail, not a sandbox boundary. The process
still has host Docker access; keep gateway policy and sandbox isolation in place.

## 🚧 Disclaimers

### Sensitive Data

**DO NOT CONFIGURE CONTAINERS WITH SENSITIVE DATA.** This includes API keys,
database passwords, etc.

Any sensitive data exchanged with the LLM is inherently compromised, unless the
LLM is running on your local machine.

If you are interested in securely passing secrets to containers, file an issue
on this repository with your use-case.

### Reviewing Created Containers

Be careful to review the containers that the LLM creates. Docker is not a secure
sandbox, and therefore the MCP server can potentially impact the host machine
through Docker.

For safety reasons, this MCP server doesn't support sensitive Docker options
like `--privileged` or `--cap-add/--cap-drop`. If these features are of interest
to you, file an issue on this repository with your use-case.

## đŸ› ī¸ Configuration

This server uses the Python Docker SDK's `from_env` method. For configuration
details, see
[the documentation](https://docker-py.readthedocs.io/en/stable/client.html#docker.client.from_env).

### Connect to Docker over SSH

This MCP server can connect to a remote Docker daemon over SSH.

Simply set a `ssh://` host URL in the MCP server definition:

```
"mcpServers": {
  "mcp-server-docker": {
    "command": "uvx",
    "args": [
      "--from",
      "git+https://github.com/dboeckli/mcp-server-docker@v0.11.0",
      "mcp-server-docker"
    ],
    "env": {
      "DOCKER_HOST": "ssh://myusername@myhost.example.com"
    }
  }
}
```

## 📜 Changelog

Release notes and the history of notable changes live in
[CHANGELOG.md](CHANGELOG.md).

## đŸ’ģ Development

Prefer using Devbox to configure your development environment. The server uses
MCP Python SDK v2's high-level `MCPServer` API and can be inspected directly:

```bash
uv sync --all-groups
uv run mcp dev src/mcp_server_docker/server.py:app
# or: npx @modelcontextprotocol/inspector uv run mcp-server-docker
```

Run the hermetic test and lint suite without a Docker daemon:

```bash
uv run pytest
uv run pytest --cov=mcp_server_docker --cov-report=term-missing
uv run ruff format --check src tests
uv run ruff check src tests
```

CI also writes `target/reports/coverage.xml` and `target/reports/junit.xml`
and runs SonarCloud analysis when the `SONAR_TOKEN` repository secret is
configured.

Run the Docker integration tests (requires Docker and Buildx):

```bash
uv run pytest -o addopts= -m integration
```

See the `devbox.json` for helpful development commands.

After setting up devbox you can configure your Claude MCP config to use it:

```json
{
  "mcpServers": {
    "docker": {
      "command": "/path/to/repo/.devbox/nix/profile/default/bin/uv",
      "args": [
        "--directory",
        "/path/to/repo/",
        "run",
        "mcp-server-docker"
      ]
    }
  }
}
```

## 📄 License

This project is distributed under the **GNU General Public License v3.0**
(GPL-3.0-only); see [LICENSE](LICENSE).

It is a modified version of
[`ckreiling/mcp-server-docker`](https://github.com/ckreiling/mcp-server-docker).
Upstream copyright and authorship remain with Christian Kreiling and the
upstream contributors. Modifications in this repository are maintained by
[dboeckli](https://github.com/dboeckli) under the same license. See
[NOTICE](NOTICE) and [CHANGELOG.md](CHANGELOG.md) for the recorded changes.

This repository is not affiliated with or endorsed by the upstream maintainer,
Docker, Inc., or the Model Context Protocol project.

TDQS

B3/5.0

Scored across 36 tools

Disambiguation4/5

Each tool pairs a Docker resource with a distinct action, and descriptions clarify borderline cases (e.g., docker_run_container is explicitly 'preferred over create+start'). The only mild overlaps are docker_system_df vs docker_system_info vs docker_version and inspect vs health/stats/processes, but these resolve cleanly.

Naming Consistency4/5

All tools use snake_case with a consistent docker_ prefix, making them predictable. There is a minor ordering inconsistency where some tools are verb_noun (docker_list_images, docker_remove_image) and others noun_verb (docker_image_inspect, docker_container_health), but grouping remains readable.

Tool Count3/5

36 tools is on the heavy side (25+), though the breadth largely reflects Docker's genuinely wide surface across containers, images, networks, volumes, buildx, and system. Most tools earn their place, but a few could be consolidated (e.g., system_df/info, image history) to reduce the surface.

Completeness4/5

Coverage is strong: full container lifecycle (create/run/start/stop/remove/recreate/logs/stats/inspect), image build/pull/push/list/remove, and volume/network CRUD. Notable gaps include container exec, restart/pause, image tag, and network connect/disconnect, but agents can work around most of these.

Maintenance

ActivityMaintained
ResponsivenessLimited data