docker-mcp

docker-mcp

Wraps the Docker Engine API as MCP tools for container and image management. Reduces token consumption by providing typed tools with default summaries and field selection.

Category
Visit Server

README

docker-mcp

MCP (Model Context Protocol) server wrapping the Docker Engine API. Exposes Docker operations as typed MCP tools, reducing token consumption versus generating CLI commands.

Quick Start

npx docker-mcp

Or add to your MCP client config (OpenCode, Claude Desktop, etc.):

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

Configuration

Configure via environment variables, matching Docker CLI conventions:

Variable Purpose Example
DOCKER_HOST Docker daemon address ssh://user@192.168.1.111
DOCKER_TLS_VERIFY Enable TLS 1
DOCKER_CERT_PATH TLS cert directory ~/.docker/certs

Default: Connects to local Docker socket (/var/run/docker.sock).

Connection methods (recommended order)

  1. SSH (preferred): DOCKER_HOST=ssh://user@host — dockerode handles SSH natively. Pre-populate ~/.ssh/known_hosts to avoid host key prompts.
  2. TCP + TLS: DOCKER_HOST=tcp://host:2376 with DOCKER_TLS_VERIFY=1 and DOCKER_CERT_PATH.
  3. Plain TCP: DOCKER_HOST=tcp://host:2375 — warning: unencrypted TCP grants root access to anyone on the network. Only use on trusted LANs.

Authentication

For private registries, prefer pre-configuring credentials:

docker login myregistry.io

dockerode reads ~/.docker/config.json automatically. Inline auth parameters are also supported on image_action pull/push, but note that credentials transit the MCP protocol (stdin/stdout).

Tools (17 total)

Container tools

Tool Description
container_query List or inspect containers. Supports filters (status, label), limit, field selection, verbose mode.
container_action Start, stop, restart, pause, unpause, or remove containers.
container_create Create a container from an image with env, ports, volumes.
container_logs Get container logs with tail limit (default 100, max 10,000) and timestamps. ANSI codes stripped.
container_exec Run a command inside a running container. Output capped at 10KB/200 lines.

Image tools

Tool Description
image_query List or inspect images. Supports dangling filter, field selection.
image_action Pull, remove, tag, or push images. Supports registry auth.
image_build Build an image from a Dockerfile.

Volume tools

Tool Description
volume_query List or inspect volumes.
volume_action Create or remove volumes.

Network tools

Tool Description
network_query List or inspect networks.
network_action Create, remove, connect, or disconnect networks.

Compose tools

Tool Description
compose_action Up, down, pull, or stop Compose projects. Fire-and-forget for up (check with compose_query ps).
compose_query List services (ps), validate config, or get logs.

System tools

Tool Description
system_df Docker disk usage breakdown.
system_prune Prune unused resources by scope (all, containers, images, volumes, networks, builder).

Health

Tool Description
docker_ping Check Docker daemon connectivity and return version info.

Token Optimization

This server is designed to minimize token consumption:

  • Default summaries: Query tools return curated fields by default. Use verbose: true for full payloads.
  • Field selection: Pass fields: ["Id", "State.Status"] to get only the data you need.
  • Pagination: Use limit on list tools to cap result size.
  • Log capping: Logs default to 100 lines (max 10,000). Exec output capped at 10KB/200 lines.
  • Compact IDs: 12-character IDs by default. Use fullId: true for full 64-char IDs.
  • ANSI stripping: All output has ANSI codes stripped server-side.
  • Tool consolidation: Related operations merged into 17 tools via action enums instead of 35 individual tools.

Security Notes

  • container_exec allows arbitrary command execution in any container — equivalent to docker exec.
  • image_build accepts a context path — ensure it points to a project directory, not / or /etc.
  • Inline auth credentials on image_action transit the MCP protocol (stdio). Prefer docker login.
  • Plain TCP Docker sockets grant root access without authentication. Use SSH or TLS when accessing remote hosts.

Development

# Install
npm install

# Dev server with hot reload
npm run dev

# Build
npm run build

# Test
npm test                 # Unit tests (no Docker needed)
npm run test:integration # Integration tests (requires Docker)
npm run lint             # Lint
npm run typecheck        # TypeScript check

# Format
npm run format

Architecture

src/
  index.ts         — Entrypoint, DI wiring, stdio transport
  config.ts        — Docker client factory (reads DOCKER_HOST env vars)
  error.ts         — Centralized error handler with status-code mapper
  utils/
    compose.ts     — Compose arg builder + JSON output parser (pure)
    summarize.ts   — Token optimization utilities (field projection, ID truncation, ANSI stripping, output capping)
  tools/
    types.ts       — Shared types + tool registration helpers
    health.ts      — docker_ping (validates pipeline)
    containers.ts  — 5 container tools
    images.ts      — 3 image tools
    volumes.ts     — 2 volume tools
    networks.ts    — 2 network tools
    compose.ts     — 2 compose tools
    system.ts      — 2 system tools

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured