一个用于在 Docker 容器内执行代码的安全沙箱环境。该 MCP 服务器为 AI 应用程序提供了一个安全且隔离的代码运行环境,同时通过容器化技术确保安全性。
curl -fsSL https://raw.githubusercontent.com/Automata-Labs-team/code-sandbox-mcp/main/install.sh | bash
# 在 PowerShell 中运行
irm https://raw.githubusercontent.com/Automata-Labs-team/code-sandbox-mcp/main/install.ps1 | iex

安装程序将执行以下操作:
chmod +x code-sandbox-mcp

sandbox_initialize
初始化一个新的代码执行计算环境。
基于指定的 Docker 镜像创建容器。
参数:
image
(字符串,可选):用作基础环境的 Docker 镜像
返回值:
container_id
copy_project
将目录复制到沙箱文件系统中。
参数:
container_id
(字符串,必填):initialize 调用返回的容器 IDlocal_src_dir
(字符串,必填):本地文件系统中的目录路径dest_dir
(字符串,可选):在沙箱环境中保存源目录的路径write_file
向沙箱文件系统写入文件。
参数:
container_id
(字符串,必填):initialize 调用返回的容器 IDfile_name
(字符串,必填):要创建的文件名file_contents
(字符串,必填):要写入文件的内容dest_dir
(字符串,可选):创建文件的目录(默认值:${WORKDIR})sandbox_exec
在沙箱环境中执行命令。
参数:
container_id
(字符串,必填):initialize 调用返回的容器 IDcommands
(数组,必填):要在沙箱环境中运行的命令列表
copy_file
将单个文件复制到沙箱文件系统中。
参数:
container_id
(字符串,必填):initialize 调用返回的容器 IDlocal_src_file
(字符串,必填):本地文件系统中的文件路径dest_path
(字符串,可选):在沙箱环境中保存文件的路径sandbox_stop
停止并移除正在运行的容器沙箱。
参数:
container_id
(字符串,必填):要停止并移除的容器 ID描述:
以 10 秒超时优雅地停止指定的容器,并将其及其卷一起移除。
一个动态资源,提供对容器日志的访问。
资源路径: containers://{id}/logs
MIME 类型: text/plain
描述: 返回指定容器的所有容器日志作为单个文本资源。
安装程序会自动创建配置文件。如果需要手动配置:
// ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"code-sandbox-mcp": {
"command": "/path/to/code-sandbox-mcp",
"args": [],
"env": {}
}
}
}

// ~/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 文件。