Execute Code Securely in Sandboxed Environments
MCP server executing Python, Java, C/C++, Node.js, and Rust code inside locked-down Docker sandboxes, exposed as a single run_code tool.
Maintainer of this project? Claim this page to edit the listing.
0.1.1Add to Favorites
Why it matters
This asset provides a secure MCP server for executing code in isolated Docker sandboxes. It supports multiple programming languages and offers features like resource restrictions and disabled networking for enhanced security.
Outcomes
What it gets done
Execute arbitrary code in isolated Docker sandboxes
Support for Python, Java, C, C++, JavaScript/Node.js, and Rust
Enforce resource limits (CPU, memory, process count)
Disable networking and use read-only file systems for security
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-onyx-mcp-sandbox | bash Capabilities
Tools your agent gets
Securely executes arbitrary code in Docker sandboxes with support for multiple programming languages
Overview
Onyx MCP Sandbox MCP Server
An MCP server that runs Python, Java, C, C++, Node.js, and Rust code inside network-isolated, read-only, non-root Docker sandboxes, exposed to Claude Desktop and other MCP clients through a single run_code tool. Use when an AI assistant needs to actually execute generated or untrusted code safely rather than review it statically. Requires Docker and Go to run; each language's Docker image must be available before first use.
What it does
Onyx is an MCP server that executes arbitrary code securely inside Docker sandboxes, integrating with Claude Desktop or other MCP clients so an AI assistant can run code without touching the host machine directly. It supports six languages via dedicated Docker images: Python (python:3.11), Java (openjdk:17), C and C++ (gcc:12), JavaScript/Node.js (node:20), and Rust (rust:1.72).
Sandboxing is deliberately restrictive: containers run with networking disabled (--network none), a read-only filesystem with tmpfs mounts for the writes execution actually needs, limited CPU, memory, and process counts, and non-root execution (--user 1000:1000). The server exposes a single MCP tool, run_code, for executing arbitrary code inside this environment, and routes all execution logs to stderr so they don't interfere with the MCP client's stdio protocol channel. The project also ships GitHub Actions CI that runs automated tests against its language executors.
Internally it is a Go project: cmd/server/main.go is the MCP server entrypoint, internal/model defines code parameters, the executor interface, and result types, internal/executor holds one executor implementation per supported language, and internal/utils checks Docker availability before attempting to run anything.
go build -o sandbox_server ./cmd/server/main.go
Adding a new language is a defined five-step process: pick a Docker image with the language's compiler or runtime (the docs give golang:1.22 for Go and php:8.2-cli for PHP as examples); implement an executor struct in internal/executor/<lang>.go whose Execute method pipes source code into the container, compiles or interprets it inside /workspace, and runs the resulting binary or script; register the new executor by language name in main.go; write a test for it; and pre-pull the corresponding Docker image.
When to use - and when NOT to
Use this connector when you want an AI assistant to run and verify code across multiple languages without exposing your host filesystem or network to untrusted execution - the disabled networking, read-only filesystem, and non-root, resource-limited containers are specifically designed for that threat model. It is a good fit for Claude Desktop workflows that need to actually execute generated code rather than just review it statically.
It requires Docker (Desktop or Engine) and Go 1.20+ to run the server itself, and each supported language's Docker image must be pulled - ideally ahead of time - to avoid first-run delays; environments that cannot run Docker containers cannot use this connector at all.
Capabilities
One tool, run_code, backed by a per-language executor struct (implementing a shared Execute interface) that pipes source into the container, compiles or interprets it inside /workspace, and returns the resulting output - the same interface every future language addition must implement, keeping the six current executors and any new ones behaviorally consistent.
How to install
Requires Docker (Desktop or Engine) and Go 1.20+. Build the server with go build -o sandbox_server ./cmd/server/main.go, pre-pull each language's Docker image to avoid first-run delays, then register it with Claude Desktop via an mcpServers entry in claude_desktop_config.json pointing at the built sandbox_server binary.
Who it's for
Claude Desktop power users and developers building AI workflows that need to actually execute untrusted or AI-generated code safely, across Python, Java, C, C++, Node.js, or Rust, rather than running it unsandboxed on the host.
Source README
Onyx
Onyx is a MCP (Model Context Protocol) server that executes code securely inside Docker sandboxes. It supports multiple programming languages and integrates seamlessly with Claude Desktop or other MCP clients. Onyx makes it safe and easy to execute arbitrary code in a sandboxed MCP environment. Perfect for Claude Desktop power users or anyone building AI workflows with executable code.
Features
πΉ Multi-language support:
- Python (
python:3.11) - Java (
openjdk:17) - C (
gcc:12) - C++ (
gcc:12) - JavaScript / Node.js (
node:20) - Rust (
rust:1.72)
- Python (
πΉ Docker sandboxing:
- Network disabled (
--network none) - Read-only FS with tmpfs mounts for safe writes
- Limited CPU, memory, and process count
- Non-root execution (
--user 1000:1000)
- Network disabled (
πΉ MCP protocol: Exposes a
run_codetool for executing arbitrary code.πΉ Logging: All execution logs go to
stderr(safe for MCP clients).πΉ CI-ready: Automated tests for executors via GitHub Actions.
Project Structure
sandbox/
βββ .github/
β βββ workflows/ci.yml # GitHub Actions CI
βββ cmd/
β βββ server/
β βββ main.go # MCP server entrypoint
βββ internal/
β βββ model/ # Code params, executor interface, result types
β βββ executor/ # Language-specific executors
β βββ utils/ # Docker availability checks
βββ tests/
βββ go.mod, go.sum
Setup Instructions
1. Prerequisites
- Go 1.20+
- Docker Desktop (Windows/macOS) or Docker Engine (Linux)
Verify both:
go version
docker --version
2. Pull Required Docker Images
To avoid delays during the first execution, pre-pull all language runtimes:
docker pull python:3.11
docker pull openjdk:17
docker pull gcc:12
docker pull node:20
docker pull rust:1.72
3. Build and Run the Server
From the root of the repo:
# Run directly
go run ./cmd/server/main.go
# Or build a binary (recommended for Claude Desktop)
go build -o sandbox_server ./cmd/server/main.go
You should now have sandbox_server (or sandbox_server.exe on Windows).
Connecting with Claude Desktop
Locate Claude Desktopβs config file:
code $env:AppData\Claude\claude_desktop_config.jsonAdd an MCP server entry for Onyx:
{ "mcpServers": { "onyx": { "command": "<absolute path>/sandbox_server.exe", "args": [] } } }Restart Claude Desktop.
You should now see the
run_codetool available.
Usage
Extending to New Languages
Adding support for another language requires:
Choose a Docker image with the languageβs compiler/runtime.
Example:golang:1.22for Go,php:8.2-clifor PHP.Implement an Executor in
internal/executor/<lang>.go:Define a struct (e.g.,
GoExecutor).Implement the
Executemethod to:- Pipe source code into the container.
- Compile/interpret it inside
/workspace. - Run the output binary/script.
Register it in
main.go:if args.Language == "go" { runtime = executor.GoExecutor{} }Write a test in
internal/executor/go_test.go.Pull the Docker image ahead of time (
docker pull golang:1.22).
FAQ
Common questions
Discussion
Questions & comments Β· 0
Sign In Sign in to leave a comment.