Skip to content

hypnosis/docker-mcp-server

v2.0.1MIT

Docker through compose projects for AI agents: containers, logs, databases, backups and stack control, on this machine or on a remote host over SSH, with destructive operations blocked. Works with Claude Code, Codex, Cursor and any MCP client.

Docker MCP Server — Docker tools for AI agents

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.

MCP Registry npm version npm downloads tests License: MIT

Install · Tools · Setup · Security · Docs · Changelog


Install in 30 seconds

No global installation required. npx downloads the package on first use:

npx -y @hypnosis/docker-mcp-server

Add it to your MCP client — Claude Code, for example — for every project:

claude mcp add docker -s user -- npx -y @hypnosis/docker-mcp-server

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:

claude mcp add docker -s user \
  -e DOCKER_MCP_PROFILES_FILE="$HOME/.claude/docker-profiles.json" \
  -- npx -y @hypnosis/docker-mcp-server
{
  "default": "local",
  "profiles": {
    "local": { "mode": "local" },
    "production": {
      "host": "prod.example.com",
      "username": "deployer",
      "privateKeyPath": "~/.ssh/id_ed25519"
    }
  }
}

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.

Install as a plugin

Some clients — Claude Code, for example — can take the whole thing as a plugin instead:

/plugin marketplace add hypnosis/docker-mcp-server
/plugin install docker-mcp-server@docker-mcp-server

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.

Requirements

Node.js TypeScript MCP SDK

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.

Who this Docker MCP server is for

  • AI-assisted developers who build, run, and debug applications with Docker Compose.
  • Backend and full-stack developers who need their coding agent to inspect containers, logs, health checks, databases, and Compose services while solving a problem.
  • Independent developers and small product teams who deploy Docker applications to their own servers and want one agent workflow for local development and production.
  • Platform engineers who maintain Docker environments across development, staging, and production hosts.
  • DevOps engineers and SREs using AI coding agents for incident checks, routine container work, and faster investigation of Compose-based services.
  • Agencies and technical teams maintaining client applications, where an agent needs to understand an unfamiliar Compose stack before making a change.
  • QA and release engineers who need repeatable visibility into test stacks, service health, logs, and databases before a release.

Why use a Docker MCP server instead of raw Docker CLI?

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.

Less context, lower AI cost

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.

Debug Docker Compose as a system

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.

Make decisions from explicit results

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.

Manage local and remote Docker hosts over SSH

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:

docker_container({ "action": "list", "profile": "production" })

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.

Built for the Model Context Protocol

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.


Docker MCP vs Docker CLI: practical examples

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.

Diagnose the health of a Docker Compose stack

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?"

Raw docker CLI

$ docker compose ps
NAME              IMAGE               STATUS                     PORTS
shop-api-1        shop-api:latest     Up 4 minutes (healthy)     0.0.0.0:8080->8080/tcp
shop-postgres-1   postgres:16         Up 4 minutes (unhealthy)   5432/tcp
shop-worker-1     shop-worker:latest  Exited (1) 2 minutes ago
$ docker stats --no-stream
CONTAINER ID   NAME              CPU %   MEM USAGE / LIMIT     MEM %   NET I/O          BLOCK I/O
1f2c4d5e6a7b   shop-api-1        3.10%   214.8MiB / 7.66GiB    2.74%   12.4MB / 8.9MB   0B / 4.1MB
9a8b7c6d5e4f   shop-postgres-1   0.42%   1.204GiB / 7.66GiB    15.7%   3.2MB / 44MB     112MB / 890MB
$ docker inspect --format '{{.State.Health.Status}}' shop-postgres-1
unhealthy
$ docker inspect --format '{{.State.Health.Status}}' shop-worker-1
Template parsing error: executing "" at <.State.Health.Status>: nil pointer evaluating *types.Health.Status

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.

Structured MCP result

docker_container({ "action": "list", "project": "shop" })
{
  "action": "list",
  "project": "shop",
  "containers": [
    { "name": "shop-api-1", "service": "api", "project": "shop", "state": "running",
      "health": "healthy", "image": "shop-api:latest",
      "ports": ["0.0.0.0:8080->8080/tcp"], "created": "2026-08-24T09:14:02Z" },
    { "name": "shop-postgres-1", "service": "postgres", "project": "shop", "state": "running",
      "health": "unhealthy", "image": "postgres:16",
      "ports": ["5432/tcp"], "created": "2026-08-24T09:14:01Z" },
    { "name": "shop-worker-1", "service": "worker", "project": "shop", "state": "exited",
      "health": null, "image": "shop-worker:latest",
      "ports": [], "created": "2026-08-24T09:14:01Z" }
  ],
  "reason": null,
  "legend": {
    "containers[].state=running": "Running now.",
    "containers[].state=exited": "Stopped. Its logs survive, its processes do not.",
    "containers[].health=healthy": "Its own healthcheck passed last run.",
    "containers[].health=unhealthy": "Its own healthcheck failed enough times in a row to give up on it.",
    "containers[].health=null": "The image declares no healthcheck, so nothing is measured. Not the same as failing."
  }
}

What changes for the agent

Raw docker CLIStructured MCPYour gain
Three commands and three output formatsOne call with state, health and ports per serviceFewer round trips
A missing healthcheck errors out or reads as failurehealth: null is explained in the answer itselfNo container blamed for a check nobody wrote
Container names must be mapped back to servicesEvery row carries service, project and nameThe 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.

Investigate container logs without losing context

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?"

Raw docker CLI

$ docker compose logs api --tail 200
api-1  | 2026-08-24T10:31:07.104Z INFO  request GET /health 200 3ms
api-1  | 2026-08-24T10:31:07.882Z INFO  request GET /health 200 2ms
... 196 more lines of the same ...
api-1  | 2026-08-24T10:39:14.522Z ERROR database connection timed out after 30000ms
$ docker compose logs api --since 10m | grep -i error
api-1  | 2026-08-24T10:39:14.522Z ERROR database connection timed out after 30000ms

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.

Structured MCP result

docker_logs({ "service": "api", "project": "shop", "since": "10m", "lines": 50 })
{
  "service": "api",
  "project": "shop",
  "date": "2026-08-24",
  "lines": [
    { "stream": "stdout", "time": "10:39:14.518",
      "text": "INFO  pool exhausted, waiting for a free connection" },
    { "stream": "stderr", "time": "10:39:14.522",
      "text": "ERROR database connection timed out after 30000ms" },
    { "stream": "stderr", "time": "10:39:14.530",
      "text": "ERROR upstream 502 while proxying GET /api/orders" }
  ],
  "returned_lines": 3,
  "since": "10m",
  "until": null,
  "truncated": false,
  "truncated_reason": null,
  "clipped_lines": 0,
  "follow": false,
  "reason": null,
  "legend": {
    "lines[].stream=stderr": "the stream the container wrote to; many programs write their ordinary progress there, so a line is not an error for being here"
  }
}

What changes for the agent

Raw docker CLIStructured MCPYour gain
A tail is a guess: too few lines miss it, too many bury itsince and until cut the window by time, then lines countsFewer tokens on noise
One text blob; stream and timestamp are glued into itEvery line carries its own stream, time and textErrors are found by field, not by grep
A dropped middle looks exactly like a quiet logtruncated, truncated_reason and clipped_lines name every cutNo "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.

Query a database running in Docker

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?"

Raw docker CLI

$ docker compose exec -T postgres psql -U app -d shop -c "select status, count(*) from orders group by status"
  status   | count
-----------+-------
 paid      |  1284
 pending   |    17
(2 rows)
$ docker compose exec -T redis redis-cli info keyspace
db0:keys=41822,expires=41822,avg_ttl=3600000

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".

Structured MCP result

docker_db({ "action": "query", "service": "postgres", "project": "shop",
            "query": "select status, count(*) from orders group by status" })
{
  "action": "query",
  "service": "postgres",
  "project": "shop",
  "engine": "postgresql",
  "query": "select status, count(*) from orders group by status",
  "output": "  status   | count\n-----------+-------\n paid      |  1284\n pending   |    17\n(2 rows)",
  "stderr": "",
  "exit_code": 0,
  "clipped_bytes": 0,
  "warnings": [],
  "reason": null,
  "legend": {}
}

What changes for the agent

Raw docker CLIStructured MCPYour gain
A different client, flag set and user for every engineOne tool for PostgreSQL, MySQL/MariaDB, Redis, MongoDB and SQLiteOne thing to learn, five databases
A refused statement still looks like a successful commandexit_code and stderr stay apart from outputA failure reads as a failure
Credentials get retyped into the command lineThe container's own user and database are the defaultFewer 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.

Back up a database before a risky migration

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?"

Raw docker CLI

$ docker compose exec -T postgres pg_dump -U app shop | gzip > backup.sql.gz
$ echo $?
0
$ ls -lh backup.sql.gz
-rw-r--r--  1 you  staff    20B 24 Aug 11:02 backup.sql.gz

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.

Structured MCP result

docker_db_admin({ "action": "backup", "service": "postgres", "project": "shop" })
{
  "action": "backup",
  "service": "postgres",
  "project": "shop",
  "engine": "postgresql",
  "file": "/backups/shop-2026-08-24T11-02-17.dump.gz",
  "bytes": 48219553,
  "verified": true,
  "message": null,
  "confirmed": false,
  "restarted": false,
  "reason": null,
  "legend": {
    "verified": "The file was read back around the call, and bytes is its size on disk. This is the difference between a dump that exists and a command that did not fail."
  }
}

What changes for the agent

Raw docker CLIStructured MCPYour gain
A pipe reports the exit code of its last commandThe dump is read back and its size namedAn empty backup cannot pass for a good one
Each engine needs its own dump command and flagsOne call for PostgreSQL, MySQL, MongoDB, SQLite and RedisSame workflow whatever the stack runs
"Done" is a wordverified is a field, and bytes: null says why it is unknownThe 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.

Understand Docker disk usage before cleaning up

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?"

Raw docker CLI

$ docker system df
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          48        9         31.2GB    22.4GB (71%)
Containers      21        7         1.8GB     412MB (22%)
Local Volumes   19        6         64.9GB    38.1GB (58%)
Build Cache     264       0         9.7GB     9.7GB
$ docker system df -v | head -40
... several screens of per-image, per-container and per-volume tables ...

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.

Structured MCP result

docker_resource({ "action": "disk" })
{
  "action": "disk",
  "count": 4,
  "total_bytes": 115534368358,
  "disk": [
    { "group": "images", "count": 48, "active": 9,
      "size_bytes": 33500985344, "unused_bytes": 24051816448 },
    { "group": "containers", "count": 21, "active": 7,
      "size_bytes": 1932735283, "unused_bytes": 431994470 },
    { "group": "volumes", "count": 19, "active": 6,
      "size_bytes": 69686362112, "unused_bytes": 40908324864 },
    { "group": "build_cache", "count": 264, "active": 0,
      "size_bytes": 10414285619, "unused_bytes": 10414285619 }
  ],
  "reason": null,
  "legend": {
    "disk[].active": "How many of them something uses right now: a running container, or an image behind one.",
    "disk[].unused_bytes": "Size of what nothing uses at the moment. Removing it frees less than this: what is shared stays until its last holder is gone.",
    "disk[].group=images": "Images are counted by their layers on disk, so this is what they really take; the sizes of separate images add up to more, because a shared layer belongs to each of them.",
    "disk[].group=containers": "Only what a container wrote on top of its image. What the image itself takes is counted with the images."
  }
}

What changes for the agent

Raw docker CLIStructured MCPYour gain
Sizes as text with mixed units and percentagesBytes as numbers, in four named groupsThe agent compares instead of parsing
The detail view costs several screensOne call, one number per groupFewer tokens for the same answer
"Reclaimable" hides what is holding a volumeactive counts what is in use, unused_bytes what is notBuild 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.

Built-in destructive command protection for AI agents

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.

Block irreversible loss, warn about destructive changes

Refused — the vessel itselfOnly warned about — its contents
DROP DATABASE, DROP SCHEMA, dropdbDROP TABLE, TRUNCATE
FLUSHALL, FLUSHDB (Redis)DELETE FROM with no WHERE
db.dropDatabase() (MongoDB)deleteMany({}), updateMany({}) with an empty filter
docker volume rm, docker volume prunedocker image prune, docker container prune
docker system prunedocker network prune
rm -rf /, rm -rf ~, rm -rf /srvrm -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.

Confirm a deliberate destructive operation

Nothing is forbidden permanently. Three tools take the confirmation, each where the danger is:

docker_exec({ "service": "api",
              "command": "rm -rf /srv/legacy # CONFIRMED-DESTRUCTIVE" })

docker_db({ "action": "query", "service": "redis",
            "query": "FLUSHDB # CONFIRMED-DESTRUCTIVE" })

docker_compose_control({ "action": "down", "volumes": true,
                         "confirm": "# CONFIRMED-DESTRUCTIVE" })

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.

Docker MCP tools for containers, compose and databases

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.

Inspect a Docker Compose stack

ToolWhat it does
docker_containerList a project with state, health and ports, or measure what one service consumes
docker_logsRead what a container printed, line by line, in a window bounded by time
docker_composeRead what the project declares: the resolved compose file, or its variables
docker_healthHealthchecks of the services, health of this server, the hosts it was given
docker_resourceImages, volumes and networks of a host, and where the disk went

Control services and stack lifecycle

ToolWhat it does
docker_container_controlStart, stop or restart one service, reporting where it stood before
docker_compose_controlBring the whole stack up or take it down

Work with databases running in Docker

ToolWhat it does
docker_dbRun a statement, or ask the database about itself
docker_db_adminTake 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.

Secrets stay hidden by default

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.

Run a command when no dedicated tool fits

ToolWhat it does
docker_execRun a command inside a service container, stdout and stderr apart

Safe defaults in MCP clients

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.

Set up the Docker MCP server

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.

Configure remote Docker hosts

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:

{
  "default": "local",
  "profiles": {
    "local": { "mode": "local" },
    "production": {
      "host": "prod.example.com",
      "username": "deployer",
      "port": 22,
      "privateKeyPath": "~/.ssh/id_ed25519"
    },
    "staging": {
      "host": "staging.example.com",
      "username": "deployer",
      "port": 2222,
      "privateKeyPath": "~/.ssh/id_ed25519_staging"
    }
  }
}

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.

Configure Claude Code, Codex, Cursor and other MCP clients

Claude Code — one command; -s user makes the server available in every project:

claude mcp add docker -s user \
  -e DOCKER_MCP_PROFILES_FILE="$HOME/.claude/docker-profiles.json" \
  -- npx -y @hypnosis/docker-mcp-server

Codex CLI

codex mcp add docker \
  --env DOCKER_MCP_PROFILES_FILE="$HOME/.codex/docker-profiles.json" \
  -- npx -y @hypnosis/docker-mcp-server

Cursor — in ~/.cursor/mcp.json:

{
  "mcpServers": {
    "docker": {
      "command": "npx",
      "args": ["-y", "@hypnosis/docker-mcp-server"],
      "env": {
        "DOCKER_MCP_PROFILES_FILE": "~/.cursor/docker-profiles.json"
      }
    }
  }
}

opencode — in ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "docker": {
      "type": "local",
      "command": ["npx", "-y", "@hypnosis/docker-mcp-server"],
      "enabled": true,
      "environment": {
        "DOCKER_MCP_PROFILES_FILE": "~/.config/opencode/docker-profiles.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.

Verify the connection

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.

Docker MCP server configuration

VariableWhat it doesDefault
DOCKER_MCP_PROFILES_FILEPath to the profiles JSON. Without it, only local Docker
DOCKER_PROFILESThe same JSON inline, used when no profiles file is set
DOCKER_MCP_ALLOW_SSH_FALLBACKKeep going when a profile's key is missing, instead of refusingfalse
LOG_LEVELdebug, info, warn, errorinfo

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.

Docker MCP server limitations

The server favours bounded, explicit tool calls over open-ended or implicit behaviour. These are the current limits to keep in mind:

  • Log following is bounded. 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.
  • The guard reads one call at a time. It cannot connect a delete in one call with a read in the next, and it recognizes the tools it knows — a custom binary that wipes a directory is not one of them.
  • Host resources are per host, not per project. docker_resource answers about everything the daemon holds; narrowing to one project is docker_container.
  • Windows is not verified. Nothing in the server is written against one platform, but it has not been run end to end on Windows.

Develop and test the Docker MCP server

npm install
npm run build            # tsc
npx tsc --noEmit         # types
npm run test:unit        # unit tests
npm run docker:test:up   # start the test containers
npm run test:e2e         # end-to-end suite against those containers

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.

Support Docker MCP Server

If the tool helps your team, star the project on GitHub. It helps other developers find it too.

Contribute to the Docker MCP server

Issues and pull requests are welcome at github.com/hypnosis/docker-mcp-server.

License

MIT — see LICENSE.