Code Sandbox MCP

Integrations

  • Executes code within isolated Docker containers for secure sandboxed environments, with support for Python, Go, and Node.js code execution and dependency management.

  • Supports running Node.js code and projects with automatic dependency detection via require/import statements and package.json, including built-in TypeScript support.

  • Allows execution of Python code snippets and projects with automatic dependency detection and installation via pip, requirements.txt, pyproject.toml, or setup.py.

代码沙盒 MCP 🐳

用于在 Docker 容器内执行代码的安全沙盒环境。此 MCP 服务器为 AI 应用程序提供安全隔离的代码运行环境,同时通过容器化确保安全性。

🌟 功能

  • 灵活的容器管理:创建和管理用于代码执行的隔离 Docker 容器
  • 自定义环境支持:使用任何 Docker 镜像作为执行环境
  • 文件操作:主机和容器之间轻松传输文件和目录
  • 命令执行:在容器环境中运行任何 shell 命令
  • 实时日志记录:实时流式传输容器日志和命令输出
  • 自动更新:内置更新检查和自动二进制更新
  • 多平台:支持 Linux、macOS 和 Windows

🚀 安装

先决条件

快速安装

Linux、MacOS
curl -fsSL https://raw.githubusercontent.com/Automata-Labs-team/code-sandbox-mcp/main/install.sh | bash
视窗
# Run in PowerShell irm https://raw.githubusercontent.com/Automata-Labs-team/code-sandbox-mcp/main/install.ps1 | iex

安装程序将:

  1. 检查 Docker 安装
  2. 下载适合您系统的二进制文件
  3. 创建必要的配置文件

手动安装

  1. 发布页面下载适合您平台的最新版本
  2. 将二进制文件放在 PATH 中的目录中
  3. 使其可执行(仅限类 Unix 系统):
    chmod +x code-sandbox-mcp

🛠️ 可用工具

sandbox_initialize

初始化新的计算环境以执行代码。基于指定的 Docker 镜像创建容器。

参数:

  • image (字符串,可选):用作基础环境的 Docker 映像
    • 默认值:'python:3.12-slim-bookworm'

返回:

  • 可以与其他工具一起使用来与此环境进行交互的container_id
copy_project

将目录复制到沙盒文件系统。

参数:

  • container_id (字符串,必需):从初始化调用返回的容器的 ID
  • local_src_dir (字符串,必需):本地文件系统中目录的路径
  • dest_dir (字符串,可选):沙盒环境中保存 src 目录的路径
write_file

将文件写入沙盒文件系统。

参数:

  • container_id (字符串,必需):从初始化调用返回的容器的 ID
  • file_name (字符串,必需):要创建的文件的名称
  • file_contents (字符串,必需):要写入文件的内容
  • dest_dir (字符串,可选):创建文件的目录(默认值:${WORKDIR})
sandbox_exec

在沙盒环境中执行命令。

参数:

  • container_id (字符串,必需):从初始化调用返回的容器的 ID
  • commands (数组,必需):在沙盒环境中运行的命令列表
    • 例如:[“apt-get update”,“pip install numpy”,“python script.py”]
copy_file

将单个文件复制到沙盒文件系统。

参数:

  • container_id (字符串,必需):从初始化调用返回的容器的 ID
  • local_src_file (字符串,必需):本地文件系统中的文件路径
  • dest_path (字符串,可选):在沙盒环境中保存文件的路径
sandbox_stop

停止并删除正在运行的容器沙盒。

参数:

  • container_id (字符串,必需):要停止和删除的容器的 ID

**描述:**以 10 秒的超时时间正常停止指定的容器并将其与其卷一起删除。

容器日志资源

提供对容器日志的访问的动态资源。

资源路径: containers://{id}/logs
MIME 类型: text/plain
**描述:**将指定容器的所有容器日志作为单个文本资源返回。

🔐 安全功能

  • 使用 Docker 容器的隔离执行环境
  • 通过 Docker 容器约束进行资源限制
  • 单独的 stdout 和 stderr 流

🔧 配置

克劳德桌面

安装程序会自动创建配置文件。如果您需要手动配置:

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": {} } } }
视窗
// %APPDATA%\Claude\claude_desktop_config.json { "mcpServers": { "code-sandbox-mcp": { "command": "C:\\path\\to\\code-sandbox-mcp.exe", "args": [], "env": {} } } }

其他人工智能应用

对于支持 MCP 服务器的其他 AI 应用程序,请将其配置为使用code-sandbox-mcp二进制文件作为其代码执行后端。

🛠️ 开发

如果您想在本地构建项目或为其开发做出贡献,请参阅DEVELOPMENT.md

📝 许可证

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。

-
security - not tested
A
license - permissive license
-
quality - not tested

local-only server

The server can only run on the client's local machine because it depends on local resources.

MCP 服务器用于创建安全的代码沙盒环境以在 Docker 容器内执行代码。

  1. 🌟 Features
    1. 🚀 Installation
      1. Prerequisites
      2. Quick Install
      3. Manual Installation
    2. 🛠️ Available Tools
      1. sandbox_initialize
      2. copy_project
      3. write_file
      4. sandbox_exec
      5. copy_file
      6. sandbox_stop
      7. Container Logs Resource
    3. 🔐 Security Features
      1. 🔧 Configuration
        1. Claude Desktop
        2. Other AI Applications
      2. 🛠️ Development
        1. 📝 License

          Related MCP Servers

          • -
            security
            A
            license
            -
            quality
            An MCP server that allows managing Docker containers through natural language, enabling users to compose, introspect, and debug containers without running commands themselves.
            Last updated -
            340
            Python
            GPL 3.0
            • Apple
          • -
            security
            A
            license
            -
            quality
            A secure, container-based implementation of the Model Context Protocol (MCP) that provides sandboxed environments for AI systems to safely execute code, run commands, access files, and perform web operations.
            Last updated -
            4
            Python
            Apache 2.0
            • Linux
          • -
            security
            A
            license
            -
            quality
            An MCP server that enables secure execution of shell commands across Windows, macOS, and Linux with built-in whitelisting and approval mechanisms for enhanced security.
            Last updated -
            13
            JavaScript
            MIT License
            • Linux
            • Apple
          • -
            security
            F
            license
            -
            quality
            A secure MCP server that provides controlled ShellJS access for LLMs, enabling AI systems to safely execute shell commands and interact with the filesystem within a configurable security sandbox.
            Last updated -
            JavaScript

          View all related MCP servers

          ID: v1l1r5f6ek