The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the Docker MCP Server listing page.
A Docker MCP server that lets AI agents operate Compose stacks with structured, Docker-native tools — instead of brittle shell commands and terminal-shaped output.
Inspect containers, read logs, check health, query databases, take dumps, and bring stacks up or down — on your laptop or on a server across the world by naming its profile.
It speaks Docker the way you do: your compose files, project names, and service names. Answers come back as named fields with enough context for an agent to act on them, rather than parse an ASCII table and guess.
Works with Claude Code, Codex CLI, Cursor, opencode, Gemini CLI, Qwen Code and other MCP clients.
Install · Tools · Setup · Security · Docs · Changelog
No global installation required. npx downloads the package on first use:
Add it to your MCP client — Claude Code, for example — for every project:
That is the whole setup for the Docker on this machine. No profiles file, no environment variables: the server uses the local Docker socket, and the compose project of your working directory is the project it answers about.
For a Docker host on another machine, add one file with the servers you reach over SSH:
Now every tool takes a profile, and docker_health({ action: "profiles" }) lists what the
server was given.
Codex, Cursor, opencode and other clients are covered in Set up the Docker MCP server.
Some clients — Claude Code, for example — can take the whole thing as a plugin instead:
The plugin brings the server up against the Docker on this machine, with no configuration at
all. Point it at other hosts the same way as above, with DOCKER_MCP_PROFILES_FILE.
Node.js 18+ and a Docker daemon you can already reach — the local socket, or a remote host over SSH with a key.
The server starts whether or not Docker is up. A call made while the daemon is down answers "start Docker" and works on the next try, without restarting your MCP client.
Prefer a pinned version, offline work, or one less registry check per launch:
npm install -g @hypnosis/docker-mcp-server, then use docker-mcp-server as the command
instead of npx.
Docker CLI is excellent for a person at a terminal. An AI agent needs something different: Docker and Compose concepts it can query directly, results it can reason about, and clear boundaries between what happened, what was not found, and what could not be checked.
docker ps, docker stats, and docker logs are designed to be read on a screen. Their output
mixes labels, values, units, and formatting into text an agent must parse before it can use it.
A Docker MCP tool returns the fields the task needs: service, project, state, health, ports, timestamps, byte counts, exit codes, and log streams. The agent receives less terminal noise, spends fewer tokens interpreting it, and keeps more context for the problem it is solving.
A Docker application is more than a list of containers. It is a Compose project with services, dependencies, health checks, logs, databases, and resources that affect one another.
The server lets an agent ask about that system in the names you use every day: the project, service, and Compose file. One call can show the state and health of a stack; another can inspect a bounded log window, measure a service, or query the database already running beside it. The agent spends its turns finding the cause, not assembling and decoding shell commands.
A shell command can return an empty table, clipped output, or an error printed alongside ordinary text. For an agent, those are different situations — and treating them as the same leads to guesses.
Docker MCP results say what was found, what was not found, what was cut short, and why an action did not run. A missing healthcheck is not a failed healthcheck; an empty list is not a failed read; a command with no exit code never started. That gives the agent a reliable basis for its next step, and gives you fewer confident-looking but wrong fixes.
Use the same Docker MCP tools on the Docker daemon beside you and on a remote server. A remote Docker host is a profile: a stable name, its SSH connection, and the authentication it needs. The agent names that profile in a tool call:
Leave profile out and the default Docker host answers, so local development stays frictionless.
Name a profile the server does not know and the response lists the profiles it does know instead
of quietly sending a request to another machine.
Remote Docker Compose projects are resolved by the labels their containers already carry. Ask for
a project by name wherever it lives on that host — no remote working directory or fixed Compose
path to maintain. For a project that has not run there yet, pass its file explicitly with
compose_path.
A native Docker MCP server built on the official MCP SDK, with structured tools designed for AI agents rather than terminal automation.
Its behaviour is covered by unit tests and end-to-end tests that run against real Docker containers, not only mocks.
The Docker CLI is the right interface when a person is driving the terminal. These examples show what changes when an AI agent needs to inspect a Docker Compose application, understand the result, and choose the next safe step.
Each comparison uses the same real-world task: first the commands and output an agent would have to work through, then the structured Docker MCP result it can use directly.
Situation: A deploy just went out. The site is slow, and you do not know whether a container is down, a healthcheck is failing, or something is eating the memory.
Question: "Is this stack healthy?"
Three commands, three formats, and the last one fails because the worker image declares no healthcheck at all. Nothing is broken — there is simply nothing to read — but the agent now has to tell "no healthcheck" apart from "failing", and a table gives it no help.
| Raw docker CLI | Structured MCP | Your gain |
|---|---|---|
| Three commands and three output formats | One call with state, health and ports per service | Fewer round trips |
| A missing healthcheck errors out or reads as failure | health: null is explained in the answer itself | No container blamed for a check nobody wrote |
| Container names must be mapped back to services | Every row carries service, project and name | The agent speaks compose, not container ids |
The legend explains only the words this answer used, right next to the fields that used them —
so the meaning of unhealthy is not sitting hundreds of messages back in a tool description.
Need numbers rather than states? docker_container({ action: "stats", service: "postgres" })
returns CPU, memory against its limit, network and disk as numbers, with the answer saying
plainly that it is one instant reading and not an average.
Need the healthchecks themselves? docker_health({ action: "services" }) reports each
service's own verdict, counts its checks and failures, and calls a service with no healthcheck
none rather than counting it as sick.
Situation: The API started returning 502 about ten minutes ago. The container has been running for a week and has written hundreds of thousands of lines.
Question: "What did it print when it broke?"
The first call spent two hundred lines of context on health-check noise. The second found the error but threw away the lines around it, and nothing in either output says whether the stream was stdout or stderr, or whether anything was dropped on the way.
| Raw docker CLI | Structured MCP | Your gain |
|---|---|---|
| A tail is a guess: too few lines miss it, too many bury it | since and until cut the window by time, then lines counts | Fewer tokens on noise |
| One text blob; stream and timestamp are glued into it | Every line carries its own stream, time and text | Errors are found by field, not by grep |
| A dropped middle looks exactly like a quiet log | truncated, truncated_reason and clipped_lines name every cut | No "the logs are clean" from a partial read |
The day the lines fall on is said once, at the top, and each line then carries only its time — the same stamp repeated on every line is text you would be paying for. Lines spread across more than one day keep their full stamps, and the answer says why.
since also takes a date or a UNIX timestamp, and follow: true waits for lines still to come,
returning what arrived within its own time and size ceiling instead of hanging on an open stream.
Situation: Orders stopped appearing on the dashboard. You want to look in the database — which is a container, with a client inside it and no port published to your machine.
Question: "What does the table actually hold?"
Every engine needs its own client, its own flags and its own way of naming the user and the database. Get one flag wrong and the shell prints an error the agent has to read as text — the call itself "succeeded".
| Raw docker CLI | Structured MCP | Your gain |
|---|---|---|
| A different client, flag set and user for every engine | One tool for PostgreSQL, MySQL/MariaDB, Redis, MongoDB and SQLite | One thing to learn, five databases |
| A refused statement still looks like a successful command | exit_code and stderr stay apart from output | A failure reads as a failure |
| Credentials get retyped into the command line | The container's own user and database are the default | Fewer secrets in the transcript |
status asks the database about itself instead — version, size, uptime, connections — and
format: "csv" lays PostgreSQL rows out for parsing. A statement that would destroy a database
or a whole keyspace does not run until it carries the confirmation marker; see
Destructive command protection for AI agents.
Situation: A migration is about to rewrite a table. You want a dump first — and you want to know the dump is real before the migration touches anything.
Question: "Do I actually have a backup?"
Exit code zero came from gzip, the last command in the pipe — not from pg_dump. Twenty
bytes is an empty archive: the dump failed on a wrong user, the error went to the terminal, and
the shell reported success. A migration now runs on the strength of a backup that does not exist.
| Raw docker CLI | Structured MCP | Your gain |
|---|---|---|
| A pipe reports the exit code of its last command | The dump is read back and its size named | An empty backup cannot pass for a good one |
| Each engine needs its own dump command and flags | One call for PostgreSQL, MySQL, MongoDB, SQLite and Redis | Same workflow whatever the stack runs |
| "Done" is a word | verified is a field, and bytes: null says why it is unknown | The agent knows what it does not know |
When the file cannot be read back, the answer says so instead of claiming a size: verified
stays false, bytes is null, and message names what stopped it — an unknown size is never
reported as an empty file.
Filling the database back is the same tool: action: "restore". It overwrites what is there,
so it is refused until the call carries the confirmation marker in its confirm field — and the
refusal tells you to take a backup here first.
Situation: The server is at 90% disk. Docker is the obvious suspect, but you do not know whether it is images, volumes, stopped containers or build cache — and pruning the wrong one destroys a database.
Question: "What is safe to reclaim?"
The summary is readable by a person and expensive for an agent: percentages in parentheses,
sizes as text with mixed units, and the detail view is several screens long. To compare
"reclaimable volumes" against "reclaimable images" the agent has to parse 64.9GB and
38.1GB (58%) back into numbers.
| Raw docker CLI | Structured MCP | Your gain |
|---|---|---|
| Sizes as text with mixed units and percentages | Bytes as numbers, in four named groups | The agent compares instead of parsing |
| The detail view costs several screens | One call, one number per group | Fewer tokens for the same answer |
| "Reclaimable" hides what is holding a volume | active counts what is in use, unused_bytes what is not | Build cache goes, the database volume stays |
images, volumes and networks list what the host holds — volumes with their size and how
many containers hold them. An empty list means asked and found nothing, which is not the same
as never asked.
An AI agent can generate a valid command that is still the wrong command to run. This server adds a local guard before anything reaches Docker or a database client, so irreversible operations need an explicit confirmation in the call that requests them.
The guard distinguishes between deleting the thing that holds data — a database, volume, or top-level directory — and changing or deleting data inside it. The first category is refused until confirmed. The second can run, but returns a warning that states what changed.
| Refused — the vessel itself | Only warned about — its contents |
|---|---|
DROP DATABASE, DROP SCHEMA, dropdb | DROP TABLE, TRUNCATE |
FLUSHALL, FLUSHDB (Redis) | DELETE FROM with no WHERE |
db.dropDatabase() (MongoDB) | deleteMany({}), updateMany({}) with an empty filter |
docker volume rm, docker volume prune | docker image prune, docker container prune |
docker system prune | docker network prune |
rm -rf /, rm -rf ~, rm -rf /srv | rm -rf /srv/app/cache |
mkfs, dd of=/dev/... |
A warning is not a refusal: the operation runs, and what it destroyed is stated as a fact in
the answer's warnings. DELETE FROM orders with a WHERE is not remarked on at all — that is
a normal statement.
Removal reads by where it points. A directory named directly under the root holds all of
something — the application, the data, the system — so rm -rf /srv is refused, while
rm -rf /srv/app/cache is what deleting files is for. A command wrapped in sh -c is unwrapped
and read however many shells it hides behind. The command runs as one argv, so a separator at the
top level is an argument: echo "hi"; rm -rf /data prints a line and removes nothing.
Nothing is forbidden permanently. Three tools take the confirmation, each where the danger is:
The marker is carried inside the call, so it lifts the refusal for that one call and no other. The marker itself never reaches the database or the shell — it is taken out of the statement before it runs.
Every refusal names what would have gone, so it can be read before the call is repeated rather
than stepped over: DROP DATABASE shop destroys the database itself. Add # CONFIRMED-DESTRUCTIVE to the command to run it.
The guard reads one call at a time. It cannot connect a delete in one call with a read in the next, and it knows the tools it knows — a custom binary that wipes a directory is not something it recognizes. It is a seatbelt, not a policy engine: recoverable operations remain your call.
A focused Docker MCP toolkit for the work AI agents do most often: inspect a Compose stack, diagnose a service, control its lifecycle, work with its database, and understand host resources. Full parameters and examples live in docs/tools.md.
Every tool speaks the same Docker Compose vocabulary. profile selects the Docker host;
project selects the Compose project; service selects the service from its Compose file, not
the generated container name. Leave profile out and the default host answers. Leave project
out and the project in the working directory answers. Use compose_path only when Docker cannot
resolve a project because it has not run on that host yet.
| Tool | What it does |
|---|---|
docker_container | List a project with state, health and ports, or measure what one service consumes |
docker_logs | Read what a container printed, line by line, in a window bounded by time |
docker_compose | Read what the project declares: the resolved compose file, or its variables |
docker_health | Healthchecks of the services, health of this server, the hosts it was given |
docker_resource | Images, volumes and networks of a host, and where the disk went |
| Tool | What it does |
|---|---|
docker_container_control | Start, stop or restart one service, reporting where it stood before |
docker_compose_control | Bring the whole stack up or take it down |
| Tool | What it does |
|---|---|
docker_db | Run a statement, or ask the database about itself |
docker_db_admin | Take a dump, or fill a database from one |
PostgreSQL, MySQL/MariaDB, Redis, MongoDB and SQLite are spoken to through the client the image already carries — nothing is installed into your containers.
Reading a project's variables with docker_compose hides the values whose key names a secret —
anything containing PASSWORD, TOKEN, KEY, SECRET, PRIVATE or CREDENTIALS. Each
variable says whether it was hidden, so a masked value is never mistaken for the real one, and
mask: false returns it when you actually need it.
| Tool | What it does |
|---|---|
docker_exec | Run a command inside a service container, stdout and stderr apart |
Standard MCP annotations tell your client which tools are safe to run without asking. The five
reading tools declare readOnlyHint. The two control tools declare destructiveHint with
idempotentHint — the same call twice leaves the same state. docker_db, docker_db_admin and
docker_exec declare destructiveHint alone: they carry something the server did not write, so
what happens is decided by what you handed in.
For local Docker, add the server to your MCP client and start working. No profile file or Docker endpoint configuration is required: the server uses the Docker socket on this machine.
Configure profiles only when an AI agent needs to reach remote Docker hosts over SSH.
Store the profiles file wherever your MCP client keeps its configuration. Each profile gives the agent a name for a Docker host and the SSH connection details it needs:
A profile with mode: "local" is the Docker on this machine. A remote profile needs host and
username; port defaults to 22. Where the compose projects live on that server is not asked
for: a project is found by the labels its containers carry. default names the profile used
when a call leaves profile out.
Prefer keys. A profile without privateKeyPath uses your SSH agent, which is the better answer
when the key is encrypted.
The host key of the machine is checked: the first connection remembers it in
~/.ssh/known_hosts, and a machine that later answers with a different key is refused instead of
being talked to. knownHostsPath in a profile points at another file when you keep those keys
apart.
Claude Code — one command; -s user makes the server available in every project:
Codex CLI
Cursor — in ~/.cursor/mcp.json:
opencode — in ~/.config/opencode/opencode.json:
Other MCP clients — Gemini CLI, Qwen Code, Cline, an editor plugin or your own agent work the same way. All they need is a command to run and, for remote hosts, one environment variable.
Restart your MCP client, then run docker_health({ action: "profiles" }). It lists the Docker
hosts the server received from configuration and identifies any profile it could not read, along
with the field that needs attention.
| Variable | What it does | Default |
|---|---|---|
DOCKER_MCP_PROFILES_FILE | Path to the profiles JSON. Without it, only local Docker | — |
DOCKER_PROFILES | The same JSON inline, used when no profiles file is set | — |
DOCKER_MCP_ALLOW_SSH_FALLBACK | Keep going when a profile's key is missing, instead of refusing | false |
LOG_LEVEL | debug, info, warn, error | info |
DOCKER_PROFILES_FILE is the deprecated spelling of the first variable. It still works and logs
a line asking you to rename it.
A profile pointing at a key that does not exist is refused by default, with the path and the ways out named — a missing key otherwise turns into a connection attempt that fails much later, somewhere less obvious.
The server favours bounded, explicit tool calls over open-ended or implicit behaviour. These are the current limits to keep in mind:
follow: true returns what arrived within 10 seconds or 1 MB,
whichever comes first. It is a look at a live stream, not a subscription.docker_resource answers about everything
the daemon holds; narrowing to one project is docker_container.The end-to-end suite runs against real PostgreSQL, MySQL, MariaDB, MongoDB, Redis, and web service containers. It verifies Docker integration behaviour that unit tests and mocks cannot prove alone. See docs/architecture.md for the project layout.
If the tool helps your team, star the project on GitHub. It helps other developers find it too.
Issues and pull requests are welcome at github.com/hypnosis/docker-mcp-server.
MIT — see LICENSE.