MCP Connector

Execute Code Securely in Isolated Containers

MCP server executing code in isolated Docker containers, with file transfer, command execution, and log streaming.

Works with docker

91
Spark score
out of 100
Updated Mar 2025
Version 0.0.30
Models
universal

Add to Favorites

Why it matters

Provide AI applications with a secure and isolated environment for code execution using Docker containers. This asset enables flexible container management, custom environment support, and efficient file operations for seamless code integration.

Outcomes

What it gets done

01

Initialize and manage isolated Docker environments for code execution.

02

Copy project files and write individual files within the sandbox.

03

Execute commands and stream logs in real-time from the isolated environment.

04

Stop and remove sandbox containers after execution.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/vb-code-sandbox-mcp | bash

Capabilities

Tools your agent gets

sandbox_initialize

Initializes a new compute environment for code execution using the specified Docker image

copy_project

Copies a directory to the sandbox file system

write_file

Writes a file to the sandbox file system

sandbox_exec

Executes commands in the isolated environment

copy_file

Copies a single file to the sandbox file system

sandbox_stop

Stops and removes the running sandbox container

Overview

code-sandbox-mcp MCP Server

An MCP server executing code and shell commands inside isolated Docker containers, with file transfer, command execution, and real-time log streaming tools. Use when an AI application needs to actually execute code or shell commands in a real, isolated environment rather than reasoning about it.

What it does

Code Sandbox MCP is a secure sandbox environment for executing code within Docker containers, giving AI applications a safe, isolated environment for running code through containerization. Features include flexible container management (create and manage isolated Docker containers for code execution), custom environment support (any Docker image can be used as the execution environment), file operations (easy file/directory transfer between host and containers), command execution (any shell commands within the container), real-time logging (streaming container logs and command output), auto-updates (built-in update checking and automatic binary updates), and multi-platform support (Linux, macOS, Windows).

When to use - and when NOT to

Use this connector when an AI assistant needs to actually execute code or shell commands in a real, isolated environment rather than just reasoning about code. Security features include an isolated execution environment via Docker containers, resource limitations through container constraints, and separate stdout/stderr streams.

Capabilities

Available tools: sandbox_initialize (creates a container based on a specified Docker image, defaulting to python:3.12-slim-bookworm, returning a container_id for use with other tools); copy_project (copies a local directory into the sandbox filesystem, given a container_id and local_src_dir, with an optional dest_dir); write_file (writes a named file with given contents into the sandbox, defaulting to ${WORKDIR}); sandbox_exec (runs a list of shell commands in the sandboxed environment, e.g. ["apt-get update", "pip install numpy", "python script.py"]); copy_file (copies a single local file into the sandbox); and sandbox_stop (gracefully stops the container with a 10-second timeout and removes it along with its volumes). A dynamic resource at containers://{id}/logs (MIME type text/plain) returns all logs from a specified container as a single text resource.

How to install

Requires Docker installed and running. Quick install on Linux/macOS via curl -fsSL https://raw.githubusercontent.com/Automata-Labs-team/code-sandbox-mcp/main/install.sh | bash, or on Windows via the equivalent PowerShell irm ... | iex command; the installer checks for Docker, downloads the right binary, and creates configuration files automatically. Manual installation downloads the release binary for your platform, places it on your PATH, and (on Unix-like systems) makes it executable with chmod +x code-sandbox-mcp. For Claude Desktop, the installer configures claude_desktop_config.json automatically (Linux: ~/.config/Claude/; macOS: ~/Library/Application Support/Claude/; Windows: %APPDATA%\Claude\), or it can be set manually with command pointing at the binary path and empty args/env. Other MCP-supporting AI applications can be configured to use the code-sandbox-mcp binary as their code-execution backend. This project is MIT-licensed.

Who it's for

Developers building AI applications that need real, isolated code execution - running scripts, installing packages, and inspecting output - in a containerized sandbox rather than simulated or unsandboxed execution.

Source README

Code Sandbox MCP ๐Ÿณ

smithery badge

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: Create and manage isolated Docker containers for code execution
  • Custom Environment Support: Use any Docker image as your execution environment
  • File Operations: Easy file and directory transfer between host and containers
  • Command Execution: Run any shell commands within the containerized environment
  • Real-time Logging: Stream container logs and command output in real-time
  • Auto-Updates: Built-in update checking and automatic binary updates
  • Multi-Platform: Supports Linux, macOS, and Windows

๐Ÿš€ Installation

Prerequisites

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

The installer will:

  1. Check for Docker installation
  2. Download the appropriate binary for your system
  3. Create necessary configuration files

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 (string, optional): Docker image to use as the base environment
    • Default: 'python:3.12-slim-bookworm'

Returns:

  • container_id that can be used with other tools to interact with this environment
copy_project

Copy a directory to the sandboxed filesystem.

Parameters:

  • container_id (string, required): ID of the container returned from the initialize call
  • local_src_dir (string, required): Path to a directory in the local file system
  • dest_dir (string, optional): Path to save the src directory in the sandbox environment
write_file

Write a file to the sandboxed filesystem.

Parameters:

  • container_id (string, required): ID of the container returned from the initialize call
  • file_name (string, required): Name of the file to create
  • file_contents (string, required): Contents to write to the file
  • dest_dir (string, optional): Directory to create the file in (Default: ${WORKDIR})
sandbox_exec

Execute commands in the sandboxed environment.

Parameters:

  • container_id (string, required): ID of the container returned from the initialize call
  • commands (array, required): List of command(s) to run in the sandboxed environment
    • Example: ["apt-get update", "pip install numpy", "python script.py"]
copy_file

Copy a single file to the sandboxed filesystem.

Parameters:

  • container_id (string, required): ID of the container returned from the initialize call
  • local_src_file (string, required): Path to a file in the local file system
  • dest_path (string, optional): Path to save the file in the sandbox environment
sandbox_stop

Stop and remove a running container sandbox.

Parameters:

  • container_id (string, required): ID of the container to stop and remove

Description:
Gracefully stops the specified container with a 10-second timeout and removes it along with its volumes.

Container Logs Resource

A dynamic resource that provides access to container logs.

Resource Path: containers://{id}/logs
MIME Type: text/plain
Description: Returns all container logs from the specified container as a single text resource.

๐Ÿ” Security Features

  • Isolated execution environment using Docker containers
  • Resource limitations through Docker container constraints
  • Separate stdout and stderr streams

๐Ÿ”ง Configuration

Claude Desktop

The installer automatically creates the configuration file. If you need to manually configure it:

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": {}
        }
    }
}

Other AI Applications

For other AI applications that support MCP servers, configure them to use the code-sandbox-mcp binary as their code execution backend.

๐Ÿ› ๏ธ Development

If you want to build the project locally or contribute to its development, see DEVELOPMENT.md.

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

FAQ

Common questions

Discussion

Questions & comments ยท 0

Sign In Sign in to leave a comment.