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.
-
πΉ 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.
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
- Go 1.20+
- Docker Desktop (Windows/macOS) or Docker Engine (Linux)
Verify both:
go version
docker --versionTo 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.72From 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.goYou should now have sandbox_server (or sandbox_server.exe on Windows).
-
Locate Claude Desktopβs config file:
code $env:AppData\Claude\claude_desktop_config.json -
Add 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.
For a good example of how it can be used, check out this chat: https://claude.ai/share/512e1f5a-77fc-40ca-8c49-b372b2c680f9
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).