docker-copilot-mcp

docker-copilot-mcp

Enables Claude to inspect and manage Docker containers locally, including listing containers, fetching status and logs, and checking system health. It also supports safely restarting whitelisted containers through a two-step confirmation flow with an audit trail.

Category
访问服务器

README

docker-copilot-mcp

A local MCP server that lets Claude inspect and safely manage Docker containers on your machine — built as a hands-on project to learn the Model Context Protocol (tools, transports, state, and safety-gated destructive actions).

What it does

  • Read-only inspection: list containers, get detailed status, fetch logs, check system health (CPU/memory/disk)
  • Safe destructive actions: restart a container, but only after a two-step confirmation flow — the agent must first request a plan + token, then explicitly confirm before anything actually happens
  • Scoped: only containers on an explicit whitelist can ever be restarted, regardless of what the agent is asked to do
  • Audited: every tool call (especially restarts) is logged to a local SQLite database with timestamp, arguments, result, and success/failure

Why this project

Most MCP tutorials stop at "here's a tool that returns data." The interesting and hard part of building real agent tooling is deciding what an agent should be allowed to do without asking, and what it must never do without a human explicitly confirming. This project exists to practice that boundary, not just the MCP plumbing.

Architecture

Claude Desktop (MCP client) → stdio transport → FastMCP server (server.py) → Tools (list_containers, get_container_status, get_container_logs, get_system_health, restart_container) → Safety Gate (scope check → confirmation token → validate → execute) → Docker Client + Audit Log (SQLite)

The safety model

Every destructive tool (currently just restart_container) goes through a gate before touching Docker:

  1. Scope check — is this target even allowed? The server maintains an explicit whitelist (safety/scope.py); anything outside it is refused immediately, no matter how the request is phrased.
  2. Dry run by default — calling restart_container without a confirmation_token never restarts anything. It returns a plan description and a token bound to that exact action (tool + target + parameters).
  3. Explicit confirmation — only a second call, with the matching token, actually executes. Tokens are single-use and expire after 2 minutes, so a stale or reused confirmation can't silently trigger an old, possibly outdated action.
  4. Audit trail — both the dry-run request and the real execution are logged to SQLite, so there's always a record of what was proposed and what actually happened.

Setup

python -m venv venv
venv\Scripts\Activate.ps1
pip install -r requirements.txt

Requires Docker Desktop running locally.

Running

Manually (for testing):

python src/server.py

Via Claude Desktop: add to your config:

{
  "mcpServers": {
    "homelab-ops": {
      "command": "/absolute/path/to/venv/Scripts/python.exe",
      "args": ["/absolute/path/to/src/server.py"]
    }
  }
}

Tools

Tool Type Description
list_containers read-only List all containers, running or stopped
get_container_status read-only Detailed status for one container
get_container_logs read-only Recent logs from a container
get_system_health read-only Host CPU / memory / disk usage
restart_container destructive, gated Restart a container (requires confirmation)

Tests

pytest tests/test_safety_gate.py -v

What I learned building this

  • The difference between MCP tools (actions) and the transport/routing layer
  • Why destructive tool calls need a confirmation flow, not just try/except
  • How to scope an agent's permissions explicitly, not just via prompt instructions
  • Debugging a live MCP integration end-to-end, including finding that Claude Desktop reads config from a sandboxed AppData path, not the documented default

Possible extensions

  • HTTP transport + OAuth for remote/shared access
  • systemd service management alongside Docker
  • Config-driven scope whitelist instead of hardcoded list
  • /diagnose <container> prompt template for guided investigation

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选