Skip to main content
Glama

Docker MCP Guardian

A security-hardened Model Context Protocol (MCP) server written in Python with FastMCP that connects local LLM agents (Claude Desktop, Claude Code) to the Docker daemon with strict zero-trust boundaries.

CI License: MIT

Core Capabilities & Safeguards

  • Read-Only by Default: Mutation tools (safe_restart_container) reject calls before touching the Docker socket unless GUARDIAN_ALLOW_WRITE=true is explicitly set.

  • Canonical ID Resolution: Resolves container IDs to Docker's internal canonical name before evaluating regex denylists, preventing evasion via hex IDs.

  • Credential & Secret Redaction: inspect_container strips all environment variable values, returning only variable keys to prevent LLM prompt leakage.

  • Isolated Stdio JSON-RPC: Strict logging separation ensures zero unstructured stdout writes, preventing JSON-RPC stream corruption in MCP clients.

  • Bounded Daemon Timeouts: Every Docker API call is capped by GUARDIAN_DOCKER_TIMEOUT (default 5s), so a wedged or missing daemon returns a structured daemon_unavailable error instead of hanging the session.

Related MCP server: Docker MCP Server

Quickstart

Prerequisites

  • Python 3.10+

  • Docker Engine / Docker Desktop

  • mcp>=1.0.0,<2 (pinned to FastMCP API)

Local Installation

git clone https://github.com/SivaSaiKrishnaSuryadevara/docker-mcp-guardian.git
cd docker-mcp-guardian
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pytest tests/ -v

Connect to Claude Code

claude mcp add docker-guardian -- "$PWD/.venv/bin/python" "$PWD/server.py"

For Claude Desktop, add the same interpreter and script paths (absolute) under mcpServers in claude_desktop_config.json.

Configuration

Variable

Default

Purpose

GUARDIAN_ALLOW_WRITE

false

Must be true for safe_restart_container to do anything

GUARDIAN_RESTART_DENY_REGEX

^(prod|db|kube|vault)-.*

Containers that can never be restarted (always wins)

GUARDIAN_RESTART_ALLOW_REGEX

(unset)

If set, only matching containers can be restarted

GUARDIAN_ANOMALY_REGEX

error/exception/fatal/...

Pattern the log scanner flags

GUARDIAN_DOCKER_TIMEOUT

5

Seconds per Docker API call

GUARDIAN_LOG_LEVEL

INFO

Log level (logs go to stderr only)

Write-up

The design decisions behind this server are covered in ARTICLE.md.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables secure Docker command execution from isolated environments like containers through MCP protocol. Provides tools for managing Docker containers, images, and Docker Compose services with security validation and async operation support.
    MIT
  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    Enables AI assistants to interact with Docker containers through safe, permission-controlled access to inspect, manage, and diagnose containers, images, and compose services with built-in timeouts and AI-powered analysis.
    -
  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables AI agents to manage Docker containers through a secure MCP interface, supporting container lifecycle operations, log inspection, resource monitoring, and system diagnostics with role-based access control.
    3
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Enables agentic Docker container operations including file read/write, command execution, and interactive TTY sessions via the local Docker binary.
    19
    15 npm
    MIT