MCP HubMCP Hub
Automata-Labs-team

code-sandbox-mcp

by: Automata-Labs-team

An MCP server to create secure code sandbox environment for executing code within Docker containers. This MCP server provides AI applications with a safe and isolated environment for running code while maintaining security through containerization.

118created 26/01/2025
Visit
Docker
Sandbox

πŸ“ŒOverview

Purpose: To provide a secure and isolated environment for executing code within Docker containers, ensuring safety and flexibility for AI applications.

Overview: Code Sandbox MCP is a server designed to facilitate code execution in a controlled Docker environment. It leverages container technology to isolate the execution process, ensuring that applications remain secure while offering the flexibility needed to handle various coding tasks.

Key Features:

  • Flexible Container Management: Easily create and manage isolated environments for execution using Docker, enhancing security and resource management.

  • Custom Environment Support: Provide versatility by allowing any Docker image to be used as the execution environment, catering to diverse application needs.

  • Real-time Logging: Stream logs and command outputs in real-time, allowing for immediate monitoring and debugging of code execution processes.

  • Multi-Platform Support: Ensure compatibility across Linux, macOS, and Windows, broadening the accessibility of the server for different users.


Code Sandbox MCP 🐳

A secure sandbox environment for executing code within Docker containers. This MCP server provides AI applications with a safe and isolated environment for running code while maintaining security through containerization.

🌟 Features

  • Flexible Container Management: Manage isolated Docker containers for code execution.
  • Custom Environment Support: Use any Docker image as your execution environment.
  • File Operations: Easy transfer of files and directories between host and containers.
  • Command Execution: Run shell commands in the containerized environment.
  • Real-time Logging: Stream container logs and command output.
  • Auto-Updates: Built-in update checking and automatic binary updates.
  • Multi-Platform: Supports Linux, macOS, and Windows.

πŸš€ Installation

Prerequisites

  • Docker installed and running.

Quick Install

Linux, MacOS

curl -fsSL https://raw.githubusercontent.com/Automata-Labs-team/code-sandbox-mcp/main/install.sh | bash

Windows

# Run in PowerShell
irm https://raw.githubusercontent.com/Automata-Labs-team/code-sandbox-mcp/main/install.ps1 | iex

Manual Installation

  1. Download the latest release for your platform from the releases page.
  2. Place the binary in a directory in your PATH.
  3. Make it executable (Unix-like systems only):
    chmod +x code-sandbox-mcp
    

πŸ› οΈ Available Tools

sandbox_initialize

Initialize a new compute environment for code execution. Creates a container based on the specified Docker image.

Parameters:

  • image (optional): Docker image to use as the base environment (Default: 'python:3.12-slim-bookworm').

Returns:

  • container_id: ID for interacting with the environment.

copy_project

Copy a directory to the sandboxed filesystem.

Parameters:

  • container_id (required): ID of the container.
  • local_src_dir (required): Local directory path.
  • dest_dir (optional): Path in the sandbox environment.

write_file

Write a file to the sandboxed filesystem.

Parameters:

  • container_id (required): ID of the container.
  • file_name (required): Name of the file.
  • file_contents (required): Contents to write.
  • dest_dir (optional): Directory (Default: ${WORKDIR}).

sandbox_exec

Execute commands in the sandboxed environment.

Parameters:

  • container_id (required): ID of the container.
  • commands (required): List of commands to run.

copy_file

Copy a single file to the sandboxed filesystem.

Parameters:

  • container_id (required): ID of the container.
  • local_src_file (required): Local file path.
  • dest_path (optional): Path in the sandbox environment.

sandbox_stop

Stop and remove a running container sandbox.

Parameters:

  • container_id (required): ID of the container.

Description: Gracefully stops the specified container and removes it along with its volumes.

Container Logs Resource

A dynamic resource providing access to container logs.

πŸ” Security Features

  • Isolated execution environment using Docker containers.
  • Resource limitations via Docker container constraints.

πŸ”§ Configuration

Configuration File Locations

The installer creates the configuration file. Manual configuration locations:

Linux

// ~/.config/Claude/claude_desktop_config.json
{
    "mcpServers": {
        "code-sandbox-mcp": {
            "command": "/path/to/code-sandbox-mcp",
            "args": [],
            "env": {}
        }
    }
}

macOS

// ~/Library/Application Support/Claude/claude_desktop_config.json
{
    "mcpServers": {
        "code-sandbox-mcp": {
            "command": "/path/to/code-sandbox-mcp",
            "args": [],
            "env": {}
        }
    }
}

Windows

// %APPDATA%\Claude\claude_desktop_config.json
{
    "mcpServers": {
        "code-sandbox-mcp": {
            "command": "C:\\path\\to\\code-sandbox-mcp.exe",
            "args": [],
            "env": {}
        }
    }
}

πŸ› οΈ Development

For building the project locally or contributing, see 1.

πŸ“ License

This project is licensed under the MIT License.