Code Sandbox MCP
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Code Sandbox MCPrun a Python script to generate a QR code PNG, then share it"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Code Sandbox MCP
A remote Model Context Protocol server that gives AI clients a persistent Linux sandbox. The model runs any bash command as root in a Docker container with internet access, installs whatever it needs, and hands files back to the user through download links.
There is deliberately no command filtering. Isolation comes from the container: it is not privileged, has no Docker socket and no host directories mounted, and has memory and CPU limits.
It started as a fork of philschmid/code-sandbox-mcp and now uses a different design: one long-lived container instead of a container per snippet, and streamable HTTP with OAuth instead of stdio.
Tools
execute(command, timeout=3600): run a bash command in/sandbox. Returns stdout, stderr and the exit code. Output aboveMAX_OUTPUT_BYTESper stream is truncated in the middle.share_file(path): return a signed, expiring public download link for a file in the sandbox. Use it for PDFs, images, audio, video or anything else that cannot be returned as text.
Related MCP server: Persistent VPS Compute MCP
Behavior
/sandboxlives on a named Docker volume. A top-level entry with no change inside it forFILE_TTLseconds (default 168 hours) is deleted by an hourly cleanup.Packages installed with
pip,npmorapt-getpersist in the container. A stopped container is restarted, not recreated.Each call is a fresh bash process:
cdand exported variables do not carry over.Long-running processes can be detached with
setsid nohup <cmd> > log 2>&1 &.
Authentication
The server is its own OAuth 2.1 authorization server with dynamic client registration, so MCP
clients such as Claude connect with only the URL https://<your-host>/mcp. When a client
connects, the user is sent to a sign-in page that asks for SANDBOX_API_KEY. Registered clients
and tokens are kept in oauth-state.json so restarts do not force a new sign-in.
Download links from share_file are signed with the same key and valid for LINK_TTL seconds.
Rotating the key invalidates them.
Setup
Requires Docker and Python 3.10+.
docker build -f containers/Dockerfile.unified -t code-sandbox:latest .
python3 -m venv .venv
.venv/bin/pip install fastmcp docker uvicornCreate .env (keep it private, chmod 600 .env):
SANDBOX_API_KEY=<random string, e.g. python3 -c "import secrets;print(secrets.token_urlsafe(32))">
SANDBOX_PUBLIC_URL=https://sandbox.example.com
SANDBOX_HOST=127.0.0.1
SANDBOX_PORT=8891Run it, for example as a systemd service:
[Unit]
Description=Code Sandbox MCP Server
After=network-online.target docker.service
Requires=docker.service
[Service]
WorkingDirectory=/path/to/code-sandbox-mcp
EnvironmentFile=/path/to/code-sandbox-mcp/.env
ExecStart=/path/to/code-sandbox-mcp/.venv/bin/python sandbox_server.py
Restart=always
[Install]
WantedBy=multi-user.targetPut it behind HTTPS at SANDBOX_PUBLIC_URL (a reverse proxy or a Cloudflare Tunnel). Commands
can run longer than a proxy's idle timeout because the MCP response stream sends keep-alive
pings.
Settings
Variable | Default | Meaning |
| required | Sign-in key and link-signing secret |
| required | Public base URL, used as OAuth issuer and for links |
|
| Listen address |
|
| Container image |
|
| Container and volume names |
|
| Container limits, applied when it is created |
|
| Default per-command timeout in seconds |
|
| Output kept per stream |
|
| Idle-file expiry and scan interval, |
|
| Download link lifetime |
|
| Where clients and tokens are stored |
The image
containers/Dockerfile.unified is based on python:3.13-slim and adds Node.js 22 with npm,
pnpm, yarn, bun, TypeScript and tsx; uv; a broad set of Python data, document and web libraries;
Playwright with headless Chromium; and ffmpeg, ImageMagick, pandoc, poppler, build tools and CJK
fonts. Edit it to change what is preinstalled.
Legacy code
src/, examples/, tests/, .gemini/, containers/Dockerfile.python and
containers/Dockerfile.nodejs belong to the original stdio server and are not used by
sandbox_server.py.
License
MIT, see license.
This server cannot be deployed
Maintenance
Related MCP Connectors
A persistent Linux computer for your AI: what it installs and writes survives the session.
Persistent Linux computers for AI agents: desktop, signed-in browser, vault, apps and shell.
A private persistent computer: files and a bash shell that survive between runs.
Real Linux labs your AI agent deploys, routes and runs, with domains, TLS, DBs and an audit log.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceEnables AI agents to operate a persistent Linux sandbox in the cloud, running commands, managing files, using Git, and publishing artifacts through a Streamable HTTP MCP endpoint.-
- FlicenseNot gradedqualityCmaintenanceProvides AI agents with a single root terminal tool to a permanent Debian VPS, enabling them to run any Linux command, install software, manage services, and deploy applications that persist across sessions.-
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to work in a persistent, isolated Linux workspace with file management, Bash execution, SSH/SFTP access, and durable storage while keeping workloads contained from the host and private networks.MIT
- FlicenseNot gradedqualityBmaintenanceEnables AI coding agents to run shell commands, spawn persistent background tasks, and read/write files inside isolated remote container sandboxes on a VPS. It also provides project workspace listing, task attach/kill controls, and a searchable knowledge graph for memory continuity across sessions.-