docker-mcp
Docker MCP Server (docker-mcp)
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 --> HostRelated MCP server: Docker MCP Server
2. 整合后的 MCP 工具一览
工具 | 操作 | 能力与亮点 |
|
| 按名称/状态正则过滤、实时 CPU/RAM 计算、多路 stdout/stderr 日志提取、容器内命令执行、安全超时。 |
|
| 通过标签/目录发现多容器栈、生命周期编排、healthcheck 就绪状态验证。 |
|
| 镜像清单、虚拟大小格式化、标签解析、悬空镜像清理。 |
|
| 持久卷目录、驱动检查、孤立卷清理。 |
|
| Bridge、overlay 与 macvlan 网络拓扑检查,以及子网解析。 |
|
| Docker 守护进程健康检查、引擎版本、磁盘占用明细、系统级回收清理。 |
3. 快速开始与配置
环境变量
变量 | 默认值 | 说明 |
|
| HTTP / SSE 监听端口 |
|
| 绑定地址 |
| 可选 | 用于 HTTP / SSE Bearer 认证的密钥令牌 |
|
| 本机 Unix Docker Socket 路径 |
| 可选 | 远程 Docker TCP 地址(例如 |
| 可选 | 是否启用 TLS 证书校验( |
| 可选 | 客户端 TLS 证书路径( |
使用 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/mcp 或 http://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
This server cannot be deployed
Maintenance
Related MCP Connectors
327 dev tools via REST API and MCP. Generate Dockerfiles, schemas, K8s, APIs, and more.
Deploy and diagnose applications in governed Kubernetes Preview Spaces through authenticated MCP.
1Single-connection MCP gateway discovering and executing 490+ verified MCP & A2A tools.
MCP deployment checks: required tools, schema drift and verifiable receipts. Free preflight.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables remote Docker management over SSH via a local MCP server, providing tools to manage containers, images, Compose, and system resources.1GPL 3.0
- AlicenseNot gradedqualityDmaintenanceA comprehensive MCP server that provides advanced Docker operations through a unified interface with 16 MCP tools and 25+ CLI aliases, enabling secure container lifecycle management, multi-container orchestration, registry publishing, and system maintenance.110 npm15ISC
- AlicenseBqualityDmaintenanceProvides MCP tools for setting up and managing Hephaestus development environment with Docker containers, including starting/stopping services, initializing databases, and troubleshooting.7MIT
- AlicenseAqualityCmaintenanceWraps 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.17225 npmMIT