Gru沙箱
Gru-sandbox(gbox)是一个开源项目,它提供了一个可自行托管的沙箱,用于MCP集成或其他AI代理用例。
服务介绍
gru-sandbox
Gru-sandbox(gbox) 是一个开源项目,它为 MCP 集成或其他 AI 代理用例提供了一个可自托管的沙箱。
随着 MCP 越来越受欢迎,我们发现没有简单的方法可以让像 Claude Desktop/Cursor 这样的 MCP 客户端在本地和安全地执行命令。该项目基于 gru.ai 的技术,并将其封装成系统命令和 MCP 服务器以方便使用。
对于高级场景,我们也保留了在本地或远程 k8s 集群中运行沙箱的能力。
用例
您的 AI 客户端(如 Claude Desktop)可以使用 gbox MCP 来提供更好的结果,例如:
1. 生成图表
生成特斯拉股票价格图:

https://claude.ai/share/34de8ca3-4e04-441b-9e79-5875fa9fc97a
2. 生成 PDF
生成最新的 AI 新闻 PDF:

https://claude.ai/share/84600933-dcf2-44be-a2fd-7f49540db57a
3. 分析与计算
分析并比较 Nvidia/Tesla 市值:

https://claude.ai/share/70c335b7-9fff-4ee7-8459-e6b7462d8994
4. 处理本地文件(即将推出)
Please compress all photos in shared folder and make sure each of them is smaller than 2MB.
5. 执行任意任务
下载 YouTube 视频:

https://claude.ai/share/c2ab6bcb-7032-489f-87d5-cc38f72c2ca9
安装
系统要求
- macOS 10.15 或更高版本
- 适用于 Mac 的 Docker Desktop
- Homebrew
注意:对其他平台(Linux, Windows)的支持即将推出。
安装步骤
# Install via Homebrew
brew tap babelcloud/gru && brew install gbox
# Initialize environment
gbox setup
# Export MCP config and merge into Claude Desktop
gbox mcp export --merge-to claude
# or gbox mcp export --merge-to cursor
# Restart Claude Desktop
更新步骤
# Update gbox to the latest version
brew update && brew upgrade gbox
# Update the environment
gbox setup
# Export and merge latest MCP config into Claude Desktop
gbox mcp export --merge-to claude
# or gbox mcp export --merge-to cursor
# Restart Claude Desktop
命令行使用
该项目提供了一个命令行工具 gbox 用于管理沙箱容器:
# Cluster management
gbox cluster setup # Setup cluster environment
gbox cluster cleanup # Cleanup cluster environment
# Container management
gbox box create --image python:3.9 --env "DEBUG=true" -w /app -v /host/path:/app # Create container
gbox box list # List containers
gbox box start <box-id> # Start container
gbox box stop <box-id> # Stop container
gbox box delete <box-id> # Delete container
gbox box exec <box-id> -- python -c "print('Hello')" # Execute command
gbox box inspect <box-id> # Inspect container
# MCP configuration
gbox mcp export # Export MCP configuration
gbox mcp export --merge-to claude # Export and merge into Claude Desktop config
gbox mcp export --dry-run # Preview merge result without applying changes
卷挂载
gbox box create 命令支持使用 -v 或 --volume 标志进行与 Docker 兼容的卷挂载。这允许您在主机系统和沙箱容器之间共享文件和目录。
卷挂载语法如下:
-v /host/path:/container/path[:ro][:propagation]
其中:
/host/path:主机系统上的文件或目录路径/container/path:文件或目录将在容器中挂载的路径ro(可选):使挂载只读propagation(可选):设置挂载传播模式(private, rprivate, shared, rshared, slave, rslave)
示例:
# Basic bind mount
gbox box create -v /data:/data --image python:3.9
# Read-only bind mount
gbox box create -v /data:/data:ro --image python:3.9
# Multiple bind mounts
gbox box create \
-v /config:/etc/myapp \
-v /data:/var/lib/myapp:ro \
-v /logs:/var/log/myapp:ro:rprivate \
--image python:3.9
注意:在创建容器之前,主机路径必须存在。如果容器路径不存在,则会自动创建。
开发设置
前提条件
- Go 1.21 或更高版本
- Docker Desktop
- Make
- pnpm (通过 corepack)
- Node.js 16.13 或更高版本
构建
# Build all components
make build
# Create distribution package
make dist
运行服务
# API Server
make -C packages/api-server dev
# MCP Server
cd packages/mcp-server && pnpm dev
# MCP Inspector
cd packages/mcp-server && pnpm inspect
贡献
我们欢迎贡献!请随时提交 Pull Request。对于重大更改,请先打开一个 issue 来讨论您想要进行的更改。
- Fork 仓库
- 创建您的功能分支 (
git checkout -b username/feature-name) - 提交您的更改 (
git commit -m 'Add some feature') - 将更改推送到分支 (
git push origin username/feature-name) - 打开 Pull Request
关于本地开发和调试需要知道的事情
如何在开发环境中运行 gbox 而不是使用系统安装的版本
- 通过
gbox cleanup停止已安装的 gbox。这将停止 API 服务器,以便您可以在开发环境中运行 API 服务器。 - 在项目根目录下执行
make api-dev。 - 执行
./gbox box list,这是从您的开发环境中运行的命令。
如何将 MCP 客户端(如 Claude Desktop)连接到开发环境中的 MCP 服务器
- 在项目根目录下执行
make mcp-dev。 - 执行
./gbox mcp export --merge-to claude
如何打开 MCP 检查
- 在项目根目录下执行
make mcp-inspect。 - 点击终端中返回的链接。
如何在开发环境中构建和使用镜像
- 在项目根目录下执行
make build-image-python以构建 Python 镜像,或执行make build-images以构建所有镜像。 - 根据需要更改镜像名称(例如,对于 TypeScript 镜像执行
make build-image-typescript)。 - 您可能需要删除当前的沙箱以使新镜像生效
./gbox box delete --all
为什么 MCP 客户端仍然获取旧的 MCP 内容?
- 在您更改了 MCP 配置(如工具定义)后,需要运行
make build来更新dist/index.js文件。 - 您可能还需要执行
./gbox mcp export --merge-to claude
许可证
本项目根据 Apache License 2.0 许可证发布 - 详情请参见 LICENSE 文件。