ZD

zaycruz/docker_mcp

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

5 stars 3 forks 品質 62 トレンド 21MIT

MCP Server for docker container creation and code execution

概要

A powerful Model Context Protocol (MCP) server that executes code in isolated Docker containers and returns the results to language models like Claude. - : Run code in Docker containers separated from your main system - : Execute code in any language with a Docker image - : Run both simple commands and complete multi-line scripts - : Install dependencies using pip, npm, apt-get, or apk - : Create, list, and clean up Docker containers easily - : Graceful timeout management and fallback mechanisms - : Clear, color-coded console feedback - Python 3.9+ - Docker installed and running - fastmcp library To test and explore the server's functionality: The MCP Inspector interface will open in your browser at http://localhost:5173. The Docker MCP server provides the following tools: Lists all Docker containers and their details: - : - show_all: (Optional) Whether to show all containers including stopped ones (default: True)

README

以下は原文 README の抜粋です。原文を見る。

Docker MCP Server

A powerful Model Context Protocol (MCP) server that executes code in isolated Docker containers and returns the results to language models like Claude.

Features

  • Isolated Code Execution: Run code in Docker containers separated from your main system
  • Multi-language Support: Execute code in any language with a Docker image
  • Complex Script Support: Run both simple commands and complete multi-line scripts
  • Package Management: Install dependencies using pip, npm, apt-get, or apk
  • Container Management: Create, list, and clean up Docker containers easily
  • Robust Error Handling: Graceful timeout management and fallback mechanisms
  • Colorful Output: Clear, color-coded console feedback

Requirements

  • Python 3.9+
  • Docker installed and running
  • fastmcp library

Installation

  1. Clone this repository:

    git clone https://github.com/zaycruz/docker_mcp.git
    cd docker_mcp
    
  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install required packages:

    pip install -r requirements.txt
    

Usage

Running the MCP Inspector

To test and explore the server’s functionality:

python run_server.py

The MCP Inspector interface will open in your browser at http://localhost:5173.

Available Tools

The Docker MCP server provides the following tools:

1. List Containers

Lists all Docker containers and their details:

  • Parameters:
    • show_all: (Optional) Whether to show all containers including stopped ones (default: True)

2. Create Container

Creates and starts a Docker container with optional dependencies:

  • Parameters:
    • image: The Docker image to use (e.g., “python:3.9-slim”, “node:16”)
    • container_name: A unique name for the container
    • dependencies: (Optional) Space-separated list of packages to install (e.g., “numpy pandas”, “express lodash”)

3. Add Dependencies

Installs additional packages in an existing Docker container:

  • Parameters:
    • container_name: The name of the target container
    • dependencies: Space-separated list of packages to install

4. Execute Code

Executes a command inside a running Docker container:

  • Parameters:
    • container_name: The name of the target container
    • command: The command to execute inside the container

5. Execute Python Script

Executes a multi-line Python script inside a running Docker container:

  • Parameters:
    • container_name: The name of the target container
    • script_content: The full Python script content
    • script_args: Optional arguments to pass to the script

6. Cleanup Container

Stops and removes a Docker container:

  • Parameters:
    • container_name: The name of the container to clean up

Examples

Basic Workflow Example

# 1. List existing containers to see what's already running
GitHub で README 全文を見る

インストール

This server does not publish a one-line install command.

Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →