
mcp-server-docker
io.github.dboeckli/mcp-server-docker
Manage Docker containers, images, networks, volumes and Buildx builds from an LLM.
Documentation
đ Docker MCP server
An MCP server for managing Docker with natural language â maintained, with Buildx tooling and bounded, LLM-friendly output.
uvx --from mcp-server-docker-dboeckli mcp-server-docker
Maintenance status: the upstream project
ckreiling/mcp-server-dockerlast releasedv0.3.0and is effectively unmaintained. This repository is its maintained continuation: it keeps the upstream Docker MCP surface and is released independently asmcp-server-docker-dboeckli(PyPI) andghcr.io/dboeckli/mcp-server-docker(GHCR).Credit for the original server belongs to Christian Kreiling and the upstream contributors. Maintained by 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 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
summarylistings plus capped log and attached-run output withtruncated/bytesmetadata. - More read-only tools: container health, processes, stats, events, disk usage, version and system info.
- Safety modes (
--read-only,--disable-destructive) 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 for the repositories we monitor and 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, anddocker_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.
đ§ą 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):
- The sandbox keeps its own isolated Docker daemon; the host Docker socket is
not mounted into it and port
2375is not exposed. - This server runs on the host and is registered with an MCP gateway (for
example the
sbxMCP 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 behindaskor 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
Install from PyPI with uv (recommended)
The package is published to PyPI as
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-dockerbelongs to the upstream project and stops at0.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
Then add the following to your MCP servers file:
"mcpServers": {
"mcp-server-docker": {
"command": "uvx",
"args": [
"--from",
"mcp-server-docker-dboeckli==0.12.0",
"mcp-server-docker"
]
}
}
Install from a GitHub release wheel
Every release attaches the built wheel and sdist. This works without PyPI and without cloning the repository:
uvx --from https://github.com/dboeckli/mcp-server-docker/releases/download/v0.12.0/mcp_server_docker_dboeckli-0.12.0-py3-none-any.whl \
mcp-server-docker
Install from GitHub source with uv
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.12.0",
"mcp-server-docker"
]
}
}
Install with Docker
Purely for convenience, the server can run in a Docker container. A prebuilt image is published to GHCR:
docker run -i --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
ghcr.io/dboeckli/mcp-server-docker:0.12.0
Alternatively, build the image locally:
docker build -t mcp-server-docker:0.12.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.12.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.
đ Verifying the image
Release tags (v*) publish SLSA provenance (mode=max) and an SPDX SBOM as OCI
attestations next to the image. Pulling the image is unchanged; inspect the
attestations with:
docker buildx imagetools inspect ghcr.io/dboeckli/mcp-server-docker:0.12.0 \
--format '{{json .Provenance}}'
docker buildx imagetools inspect ghcr.io/dboeckli/mcp-server-docker:0.12.0 \
--format '{{json .SBOM}}'
The provenance records the source repository, the commit and the build
arguments; the SBOM lists the packages in the image. Narrow the output with
.Provenance.SLSA or .SBOM.SPDX, for example
--format '{{json .SBOM.SPDX}}'. Branch and pull-request builds are not
attested, so only release tags carry these statements.
Attestations prove what was built, not what the container may do: the image still mounts the host Docker socket and is as privileged as the daemon it talks to. Keep the sandbox/gateway boundary in place.
đ 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 examplelist_containersis nowdocker_list_containers). Update gateway allow-lists and prompts that name tools directly. Resource URIs and thedocker_composeprompt are unchanged.
Containers
docker_list_containersdocker_create_containerdocker_run_containerdocker_recreate_containerdocker_start_containerdocker_fetch_container_logsdocker_stop_containerdocker_remove_containerdocker_container_inspectdocker_container_healthdocker_container_processesdocker_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_imagesdocker_pull_imagedocker_push_imagedocker_build_imagedocker_remove_imagedocker_image_inspectdocker_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_listdocker_buildx_dudocker_buildx_inspectdocker_buildx_historydocker_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_dfdocker_versiondocker_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(default900, clamped to1..86400) is how far back to look. There is nountilparameter on purpose. The window end is rounded up to the next full second, so events from the current second are included.limit(default100, clamped to1..1000) keeps the newest events and setstruncated=truewhen the window holds more.filtersacceptstype,event,container,imageandlabel, each a list, and maps them to repeated--filter key=valuearguments.- The CLI call itself is bounded too: if
docker eventsdoes not return in time, the events collected so far are returned withtruncated=trueandtruncated_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_networksdocker_network_inspectdocker_create_networkdocker_remove_network
docker_network_inspect returns the full network attributes, including driver,
IPAM configuration and connected containers.
Volumes
docker_list_volumesdocker_volume_inspectdocker_create_volumedocker_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.
đ Safety modes
Three modes decide which tools are registered. A filtered tool is absent from
tools/list, and calling it returns Unknown tool.
| Mode | Flag / env | Tools |
|---|---|---|
| Default | â | 36 |
| No destructive | --disable-destructive / MCP_SERVER_DOCKER_DISABLE_DESTRUCTIVE=1 | 31 |
| Read-only | --read-only / MCP_SERVER_DOCKER_READ_ONLY=1 | 22 |
- No destructive removes the five tools annotated with
destructiveHint=true(docker_remove_container,docker_remove_image,docker_remove_network,docker_remove_volume,docker_recreate_container). Creating, pulling, starting and stopping containers still works.--no-destructiveandMCP_SERVER_DOCKER_NO_DESTRUCTIVEare accepted as synonyms. - Read-only exposes only tools annotated with
readOnlyHint=true: alldocker_list_*, log, stats, inspect,docker_container_health,docker_events_list, disk usage and the Buildx inspection tools. - Read-only is the stricter mode and wins when both are set.
- The container log/stats resources and the
docker_composeprompt stay available in every mode.
Per-tool overrides on top of the modes:
--enable-tools docker_version,docker_system_info(repeatable,MCP_SERVER_DOCKER_ENABLE_TOOLS) registers the named tools regardless of the mode above.--disable-tools docker_stop_container(repeatable,MCP_SERVER_DOCKER_DISABLE_TOOLS) removes the named tools, unless the same tool is also enabled.- Naming a tool in both lists aborts startup with an error.
Example with uvx:
"args": [
"--from",
"git+https://github.com/dboeckli/mcp-server-docker@v0.12.0",
"mcp-server-docker",
"--disable-destructive"
]
Or with the environment variables:
"env": {
"MCP_SERVER_DOCKER_DISABLE_DESTRUCTIVE": "1",
"MCP_SERVER_DOCKER_DISABLE_TOOLS": "docker_stop_container"
}
For the sbx MCP gateway, append the flag to the comma-separated --args list,
e.g. sbx mcp add docker --args "--from,...,mcp-server-docker,--disable-destructive".
These modes are best-effort guardrails, 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.
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.12.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.
đģ 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:
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:
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):
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:
{
"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.
It is a modified version of
ckreiling/mcp-server-docker.
Upstream copyright and authorship remain with Christian Kreiling and the
upstream contributors. Modifications in this repository are maintained by
dboeckli under the same license. See
NOTICE and 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.
mcp-server-docker-dboecklipip install mcp-server-docker-dboecklighcr.io/dboeckli/mcp-server-docker:0.11.0docker pull ghcr.io/dboeckli/mcp-server-docker:0.11.0:undefined