Skip to main content
Glama
thargy
by thargy

Docker MCP Server (docker-mcp)

Node.js Version License: MIT Architecture: Deep Module TypeScript

Model Context Protocol (MCP) 服务器,为检查、编排和排查 Docker Engine 与 Docker Compose 环境提供高杠杆工具。

构建于 @thargy/mcp-server-core 之上,遵循 John Ousterhout 的 Deep Module 哲学(A Philosophy of Software Design)。


1. 架构愿景:Deep Module 与工具膨胀

传统 MCP 服务器与 Docker CLI 动词一一映射,产生的 25+ 个浅层工具使 LLM 上下文窗口变得臃肿(每轮消耗 4,000+ 提示 token),并增加幻觉。

docker-mcp 仅暴露 6 个整合、高杠杆的工具,配合多态类型化动作判别器,总消耗 少于 1,000 个 token

graph LR
    subgraph Clients ["MCP Clients"]
        Claude["Claude Desktop (Stdio)"]
        Agent["Antigravity / Coding Agents"]
        Gateway["mcp-gateway (SSE / Streamable HTTP)"]
    end

    subgraph DeepModule ["docker-mcp (Deep Module)"]
        T1["docker_containers"]
        T2["docker_compose"]
        T3["docker_images"]
        T4["docker_volumes"]
        T5["docker_networks"]
        T6["docker_system"]
        
        Seam["IDockerClient Seam"]
        Engine["DockerodeClient / InMemoryDockerClient"]
    end

    subgraph Host ["Docker Infrastructure"]
        Socket["/var/run/docker.sock"]
        RemoteTCP["tcp://remote-host:2376"]
        RemoteSSH["ssh://user@remote-host"]
    end

    Clients --> DeepModule
    DeepModule --> Seam
    Seam --> Engine
    Engine --> Host

2. 整合后的 MCP 工具一览

工具

操作

能力与亮点

docker_containers

list, inspect, start, stop, restart, logs, stats, exec, remove

按名称/状态正则过滤、实时 CPU/RAM 计算、多路 stdout/stderr 日志提取、容器内命令执行、安全超时。

docker_compose

ps, up, down, restart, logs

通过标签/目录发现多容器栈、生命周期编排、healthcheck 就绪状态验证。

docker_images

list, inspect, pull, prune, remove

镜像清单、虚拟大小格式化、标签解析、悬空镜像清理。

docker_volumes

list, inspect, create, prune, remove

持久卷目录、驱动检查、孤立卷清理。

docker_networks

list, inspect, create, prune, remove

Bridge、overlay 与 macvlan 网络拓扑检查,以及子网解析。

docker_system

info, df, prune, version, ping

Docker 守护进程健康检查、引擎版本、磁盘占用明细、系统级回收清理。


3. 快速开始与配置

环境变量

变量

默认值

说明

PORT

3008

HTTP / SSE 监听端口

HOST

0.0.0.0

绑定地址

MCP_TOKEN

可选

用于 HTTP / SSE Bearer 认证的密钥令牌

DOCKER_SOCKET

/var/run/docker.sock

本机 Unix Docker Socket 路径

DOCKER_HOST

可选

远程 Docker TCP 地址(例如 tcp://192.168.86.50:2376

DOCKER_TLS_VERIFY

可选

是否启用 TLS 证书校验(10

DOCKER_CERT_PATH

可选

客户端 TLS 证书路径(ca.pemcert.pemkey.pem

使用 Stdio 运行(Claude Desktop / 本地 CLI)

{
  "mcpServers": {
    "docker": {
      "command": "node",
      "args": ["/Users/craigdean/Repos/docker-mcp/dist/src/index.js"],
      "env": {
        "DOCKER_SOCKET": "/var/run/docker.sock"
      }
    }
  }
}

使用 Docker Compose 与 mcp-gateway 运行

docker compose up -d --build

通过 http://localhost:3008/docker/mcphttp://localhost:3008/docker/sse 访问 HTTP SSE。


4. 测试与代码质量

100% 的单元测试均基于 InMemoryDockerClient 执行,无需访问实际运行的 Docker socket。

# Run unit tests
npm test

# Run test coverage (>85% required)
npm run test:coverage

# TypeScript compile check
npm run types:check

许可证

MIT © 2026 Craig Dean

-
license - not tested
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • Free MCP tools: the only MCP linter, health checks, cost estimation, and trust evaluation.

  • Official Sevalla MCP — full PaaS API access through just 2 tools.

  • 34 production API tools over one hosted MCP endpoint.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/thargy/docker-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server