Token导航 LogoToken导航TokenDH.com
Claude Docker MCP Server logo
开发工具stdio官方级别未说明来源级核验

Claude Docker MCP Server

MCP Server

一个全面的Docker管理协议(MCP)服务器,用于通过Claude Desktop控制Docker Desktop,提供完整的Docker管理功能,包括容器、镜像、网络、卷和系统管理。

工具数

24

提示词数

0

GitHub Stars

0

资源数

0
PythonClaude开发工具Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

FrenshGeek

提供方

FrenshGeek

最后核验

2026/5/17 20:21

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python3 setup_claude_desktop.py

详细介绍

克劳德桌面Docker MCP集成

一个全面、干净的MCP(模型上下文协议)服务器,用于通过Claude Desktop控制Docker Desktop。此实现提供了完整的Docker管理功能,同时兼容自定义服务器和Docker网关。

🎯 特性

完整的Docker控制

  • 容器:启动、停止、重启、日志、统计、exec命令
  • 图像:列出、拉、推、删除、构建、检查
  • 网络:创建、列出、删除、检查
  • :创建、列出、删除、检查
  • 系统:信息、版本、磁盘使用情况、清理/修剪

双重集成模式

  1. 自定义MCP服务器:功能齐全的Python实现
  2. Docker网关:官方Docker MCP集成
  3. 两者:同时运行两台服务器以获得最大兼容性

生产就绪

  • 全面的错误处理
  • Docker命令的安全验证
  • 结构化JSON响应
  • 完全符合MCP协议
  • 零外部依赖(仅限Python stdlib)

🚀 快速设置

先决条件

  • Docker桌面已安装并正在运行
  • Python 3.7+(用于自定义服务器)
  • Claude桌面应用程序

自动设置

cd Claude_modifcation
python3 setup_claude_desktop.py

选择选项3(两台服务器)以获得最大兼容性。

手动设置

选项1:自定义MCP服务器

复制 claude_desktop_config.json 将内容添加到您的Claude Desktop配置中:

cp claude_desktop_config.json ~/Library/Application\ Support/Claude/claude_desktop_config.json

选项2:仅限Docker网关

复制 claude_desktop_config_gateway.json 相反:

cp claude_desktop_config_gateway.json ~/Library/Application\ Support/Claude/claude_desktop_config.json

重新启动克劳德桌面

完全关闭并重新启动Claude Desktop以使更改生效。

🧪 测试

测试MCP服务器

python3 test_mcp_server.py

测试Docker集成

# Test Docker availability
docker --version

# Test Docker Gateway (if using)
docker mcp gateway --help

在Claude Desktop中进行测试

在Claude Desktop中尝试以下命令:

"List all my Docker containers"
"Show Docker system information"
"Pull the hello-world image"
"Show me my Docker images"
"Start container named jupyter_embedded_dd_vm"

📋 可用工具

容器管理

  • docker_ps -列出容器(正在运行或全部)
  • docker_start -启动容器
  • docker_stop -停止集装箱
  • docker_restart -重新启动容器
  • docker_logs -获取容器日志
  • docker_stats -显示资源使用情况
  • docker_exec -在容器中执行命令
  • docker_inspect -检查集装箱

图像管理

  • docker_images -列出图片
  • docker_pull -从注册表中提取图像
  • docker_push -将图像推送到注册表
  • docker_rmi -删除图像
  • docker_build -从Dockerfile构建映像

网络管理

  • docker_network_ls -列出网络
  • docker_network_create -创建网络
  • docker_network_rm -删除网络

卷管理

  • docker_volume_ls -列出卷
  • docker_volume_create -创建卷
  • docker_volume_rm -删除卷

系统管理

  • docker_info -系统信息
  • docker_version -版本信息
  • docker_system_df -磁盘使用情况
  • docker_system_prune -清理未使用的对象

集装箱作业

  • docker_run -运行具有完整配置的新容器

🔧 配置详情

自定义MCP服务器配置

{
  "mcpServers": {
    "docker-desktop-mcp": {
      "command": "python3",
      "args": ["/path/to/docker_mcp_server.py"],
      "env": {
        "PYTHONPATH": "/path/to/Claude_modifcation"
      }
    }
  }
}

Docker网关配置

{
  "mcpServers": {
    "MCP_DOCKER_GATEWAY": {
      "command": "docker",
      "args": ["mcp", "gateway", "run"]
    }
  }
}

组合配置

安装脚本可以同时配置两台服务器,提供冗余和最大的功能覆盖。

🛡️ 安全特性

  • 命令验证:所有Docker命令都经过验证和净化
  • 论点逃逸:通过外壳注射保护 shlex.quote()
  • 超时保护:默认情况下,命令在30秒后超时
  • 错误隔离:故障被安全地控制和报告
  • 无特权:服务器仅以用户权限运行

🔍 故障排除

MCP服务器未启动

  1. 检查配置中的Python路径
  2. 验证脚本权限: chmod +x docker_mcp_server.py
  3. 手动测试: python3 docker_mcp_server.py

Docker命令失败

  1. 验证Docker桌面是否正在运行
  2. 测试Docker CLI: docker ps
  3. 检查Docker权限

Claude Desktop无法识别服务器

  1. 验证配置文件位置
  2. 完全重新启动克劳德桌面
  3. 检查Claude Desktop日志中的MCP错误

Docker网关问题

  1. 将Docker Desktop更新到最新版本
  2. 测试网关: docker mcp gateway --help
  3. 尝试将自定义服务器作为后备

📁 文件结构

Claude_modifcation/
├── docker_mcp_server.py              # Main MCP server implementation
├── claude_desktop_config.json        # Custom server configuration
├── claude_desktop_config_gateway.json # Docker Gateway configuration
├── setup_claude_desktop.py           # Automatic setup script
├── test_mcp_server.py                # Test suite
├── requirements.txt                  # Dependencies (none required)
└── README.md                         # This documentation

🎨 示例用法

基本集装箱管理

Claude: "Show me all my Docker containers"
> Lists all containers with status

Claude: "Start the container named web-server"
> Starts the specified container

Claude: "Get the logs for my nginx container"
> Retrieves and displays container logs

系统管理

Claude: "Show Docker system information and disk usage"
> Displays comprehensive system info

Claude: "Clean up unused Docker objects to free space"
> Performs system cleanup

开发流程

Claude: "Pull the latest Ubuntu image"
> Downloads Ubuntu image

Claude: "Run a temporary Ubuntu container with bash"
> Creates and starts interactive container

Claude: "Build a Docker image from the current directory"
> Builds image using local Dockerfile

🔄 与Docker网关集成

此实现旨在与Docker的官方MCP网关兼容:

  • 遵循MCP协议规范
  • 使用标准的Docker CLI命令
  • 提供结构化JSON响应
  • 保持与Docker网关工具的兼容性

您可以同时运行自定义服务器和Docker网关,以获得最大的覆盖率和冗余。

🤝 贡献

服务器设计为易于扩展:

  1. 添加新工具 get_available_tools()
  2. 在中实现工具处理程序 handle_tool_call()
  3. 遵循现有的错误处理模式
  4. 使用提供的测试套件进行测试

📝 许可证

此实现仅使用Python标准库和Docker CLI,确保兼容性和最小依赖性。

目录标签

目录标签

PythonClaude开发工具Docker管理本地部署容器化服务器集成自动化

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

24

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP