Sponsored by Deepsite.site

Docker Mcp Server

Created By
xiispace7 months ago
Content

Docker MCP Server

This is a Model Context Protocol (MCP) server that provides tools and resources for interacting with Docker containers and images. It uses the stream HTTP transport method for communication and the Python Docker SDK (docker-py) for Docker operations.

Features

  • List Docker containers and images
  • Run, stop, and remove containers
  • View container logs
  • Pull Docker images
  • Inspect container details
  • Access Docker information as resources

Prerequisites

  • Docker
  • Docker Compose (optional, for easier deployment)
  • uv (for local development)

Getting Started

Running with Docker Compose

  1. Clone this repository
  2. Build and start the server:
docker-compose up -d

Running with Docker directly

  1. Build the Docker image:
docker build -t mcp-docker-server .
  1. Run the container:
# Run server with SSE transport (no authentication)
docker run -d -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock -e MCP_PORT=3000 --name mcp-docker-server mcp-docker-server

# Run server with SSE transport and token authentication
docker run -d -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock -e MCP_PORT=3000 -e MCP_AUTH_TOKEN=your_secret_token --name mcp-docker-server mcp-docker-server

When the MCP_PORT environment variable is set, the server will use the SSE transport instead of stdio. Authentication is only applicable when using SSE transport. If the MCP_AUTH_TOKEN environment variable is set, the server will enable token authentication and configure the SSE endpoint to use the format /sse/{token} where {token} must match the value set in MCP_AUTH_TOKEN. If the token doesn't match or is not provided, the connection will be rejected. If no token is set, the server uses the standard /sse endpoint without authentication.

Running locally (development)

  1. Install uv (if not already installed):
curl -sSf https://astral.sh/uv/install.sh | sh
  1. Install dependencies using uv:
uv sync
  1. Run the server:
# Run with stdio transport (default)
uv run server.py

# Run with SSE transport on port 8000
MCP_PORT=8000 uv run server.py

# Run with SSE transport and token authentication
MCP_PORT=8000 MCP_AUTH_TOKEN=your_secret_token uv run server.py

Configuration

The server can be configured using environment variables:

  • MCP_PORT: When set, enables SSE transport mode and specifies the port to listen on (default: 8000). If not set, the server will use stdio transport.
  • MCP_AUTH_TOKEN: Secret token for authentication (only applicable when using SSE transport). When set, the SSE endpoint will be /sse/{token} instead of /sse

Using with MCP clients

Should build the docker image first.

{
  "mcpServers": {
    "docker": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-v",
        "/var/run/docker.sock:/var/run/docker.sock",
        "mcp-docker-server"
      ]
    }
  }
}

Available Tools

  • docker_ps: List running containers
  • docker_images: List available Docker images
  • docker_inspect: Get detailed information about a container
  • docker_run: Run a Docker container
  • docker_stop: Stop a running container
  • docker_rm: Remove a container
  • docker_logs: Fetch container logs
  • docker_pull: Pull a Docker image

Available Resources

  • docker://containers: Information about all containers
  • docker://images: Information about all images
  • docker://container/{container_id}: Detailed information about a specific container

TODO

  • Add functionality to query documentation for a specific Docker image

License

MIT

Server Config

{
  "mcpServers": {
    "docker": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-v",
        "/var/run/docker.sock:/var/run/docker.sock",
        "mcp-docker-server"
      ]
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Amap Maps高德地图官方 MCP Server
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Playwright McpPlaywright MCP server
ChatWiseThe second fastest AI chatbot™
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
CursorThe AI Code Editor
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
WindsurfThe new purpose-built IDE to harness magic
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Serper MCP ServerA Serper MCP Server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
DeepChatYour AI Partner on Desktop
Tavily Mcp
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.