VOOZH about

URL: https://glama.ai/mcp/servers/Tsuchijo/sandbox-mcp?locale=zh-CN

⇱ 沙盒 MCP 服务器 by Tsuchijo | Glama


沙盒 MCP 服务器

一个 MCP 服务器,提供隔离的 Docker 环境以执行代码。此服务器允许您:

  • 使用任意 Docker 镜像创建容器

  • 使用多种编程语言编写和执行代码

  • 安装软件包并设置开发环境

  • 在隔离的容器中运行命令

先决条件

  • Python 3.9 或更高版本

  • Docker 安装并运行

  • uv 包管理器(推荐)

  • Docker MCP 服务器(推荐)

Related MCP server: Docker MCP Server

安装

  1. 克隆此存储库:

git clone <your-repo-url>
cd sandbox_server
  1. 使用 uv 创建并激活虚拟环境:

uv venv
source .venv/bin/activate # On Unix/MacOS
# Or on Windows:
# .venv\Scripts\activate
  1. 安装依赖项:

uv pip install .

与 Claude Desktop 集成

  1. 打开Claude Desktop的配置文件:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

  1. 添加沙盒服务器配置:

{
 "mcpServers": {
 "sandbox": {
 "command": "uv",
 "args": [
 "--directory",
 "/absolute/path/to/sandbox_server",
 "run",
 "sandbox_server.py"
 ],
 "env": {
 "PYTHONPATH": "/absolute/path/to/sandbox_server"
 }
 }
 }
}

/absolute/path/to/sandbox_server替换为项目目录的实际路径。

  1. 重启Claude桌面

使用示例

基本用法

一旦连接到 Claude Desktop,您可以:

  1. 创建 Python 容器:

Could you create a Python container and write a simple hello world program?
  1. 以不同的语言运行代码:

Could you create a C program that calculates the fibonacci sequence and run it?
  1. 安装包并使用它们:

Could you create a Python script that uses numpy to generate and plot some random data?

保存和重现环境

服务器提供了几种保存和重现开发环境的方法:

创建持久容器

创建容器时,您可以使其持久化:

Could you create a persistent Python container with numpy and pandas installed?

这将创建一个容器:

  • Claude Desktop 关闭后仍继续运行

  • 可以通过Docker直接访问

  • 保留所有已安装的软件包和文件

服务器将提供以下说明:

  • 直接访问容器( docker exec

  • 停止和启动容器

  • 不再需要时删除

保存容器状态

设置好环境后,您可以将其保存为 Docker 镜像:

Could you save the current container state as an image named 'my-ds-env:v1'?

这将:

  1. 创建一个新的 Docker 镜像,其中包含以下内容:

    • 已安装的软件包

    • 创建的文件

    • 配置更改

  2. 提供重复使用环境的说明

然后,您可以共享此图像或将其用作新容器的起点:

Could you create a new container using the my-ds-env:v1 image?

生成 Dockerfile

为了使您的环境完全可重现,您可以生成一个 Dockerfile:

Could you export a Dockerfile that recreates this environment?

生成的 Dockerfile 将包括:

  • 基础镜像规范

  • 创建的文件

  • 附加设置步骤的模板

您可以使用此 Dockerfile 来执行以下操作:

  1. 与他人共享您的环境设置

  2. 版本控制您的开发环境

  3. 修改和定制构建过程

  4. 部署到不同的系统

推荐的工作流程

对于可重复的开发环境:

  1. 创建持久容器:

Create a persistent Python container for data science work
  1. 安装所需的软件包并设置环境:

Install numpy, pandas, and scikit-learn in the container
  1. 测试您的设置:

Create and run a test script to verify the environment
  1. 保存状态:

Save this container as 'ds-workspace:v1'
  1. 导出 Dockerfile:

Generate a Dockerfile for this environment

这为您提供了重新创建环境的多种选择:

  • 直接使用保存的Docker镜像

  • 通过修改 Dockerfile 进行构建

  • 如果需要,可以访问原始容器

安全说明

  • 所有代码都在隔离的 Docker 容器中执行

  • 容器使用后自动移除

  • 容器之间的文件系统是隔离的

  • 主机系统访问受到限制

项目结构

sandbox_server/
├── sandbox_server.py # Main server implementation
├── pyproject.toml # Project configuration
└── README.md # This file

可用工具

该服务器提供三个主要工具:

  1. create_container_environment :使用指定的镜像创建一个新的 Docker 容器

  2. create_file_in_container :在容器中创建文件

  3. execute_command_in_container :在容器中运行命令

  4. save_container_state :将容器状态保存到持久容器

  5. export_dockerfile :导出docker文件以创建持久环境

  6. exit_container :完成后关闭容器以清理环境

F
license - not found
-
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Tsuchijo/sandbox-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server