Docker沙盒环境
STDIO提供隔离Docker环境的代码执行服务器
提供隔离Docker环境的代码执行服务器
An MCP server that provides isolated Docker environments for code execution. This server allows you to:
git clone <your-repo-url> cd sandbox_server
uv venv source .venv/bin/activate # On Unix/MacOS # Or on Windows: # .venv\Scripts\activate
uv pip install .
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
{ "mcpServers": { "sandbox": { "command": "uv", "args": [ "--directory", "/absolute/path/to/sandbox_server", "run", "sandbox_server.py" ], "env": { "PYTHONPATH": "/absolute/path/to/sandbox_server" } } } }
Replace /absolute/path/to/sandbox_server
with the actual path to your project directory.
Once connected to Claude Desktop, you can:
Could you create a Python container and write a simple hello world program?
Could you create a C program that calculates the fibonacci sequence and run it?
Could you create a Python script that uses numpy to generate and plot some random data?
The server provides several ways to save and reproduce your development environments:
When creating a container, you can make it persistent:
Could you create a persistent Python container with numpy and pandas installed?
This will create a container that:
The server will provide instructions for:
docker exec
)After setting up your environment, you can save it as a Docker image:
Could you save the current container state as an image named 'my-ds-env:v1'?
This will:
You can then share this image or use it as a starting point for new containers:
Could you create a new container using the my-ds-env:v1 image?
To make your environment fully reproducible, you can generate a Dockerfile:
Could you export a Dockerfile that recreates this environment?
The generated Dockerfile will include:
You can use this Dockerfile to:
For reproducible development environments:
Create a persistent Python container for data science work
Install numpy, pandas, and scikit-learn in the container
Create and run a test script to verify the environment
Save this container as 'ds-workspace:v1'
Generate a Dockerfile for this environment
This gives you multiple options for recreating your environment:
sandbox_server/
├── sandbox_server.py # Main server implementation
├── pyproject.toml # Project configuration
└── README.md # This file
The server provides three main tools:
create_container_environment
: Creates a new Docker container with specified imagecreate_file_in_container
: Creates a file in a containerexecute_command_in_container
: Runs commands in a containersave_container_state
: Saves the container state to a persistent containerexport_dockerfile
: exports a docker file to create a persistant environmentexit_container
: closes a container to cleanup environment when finished