MCP Connector

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.

Works with dockergithub

Maintainer of this project? Claim this page to edit the listing.


91
Spark score
out of 100
Updated 11 months ago
Version 0.1.1
Models
universal

Add 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

01

Execute arbitrary code in isolated Docker sandboxes

02

Support for Python, Java, C, C++, JavaScript/Node.js, and Rust

03

Enforce resource limits (CPU, memory, process count)

04

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

run_code

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)
  • πŸ”Ή 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)
  • πŸ”Ή MCP protocol: Exposes a run_code tool 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

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

  1. Locate Claude Desktop’s config file:

    code $env:AppData\Claude\claude_desktop_config.json
    
  2. Add an MCP server entry for Onyx:

    {
      "mcpServers": {
        "onyx": {
          "command": "<absolute path>/sandbox_server.exe",
          "args": []
        }
      }
    }
    
  3. Restart Claude Desktop.

  4. You should now see the run_code tool available.


Usage

image For a good example of how it can be used, check out this chat: https://claude.ai/share/512e1f5a-77fc-40ca-8c49-b372b2c680f9

Extending to New Languages

Adding support for another language requires:

  1. Choose a Docker image with the language’s compiler/runtime.
    Example: golang:1.22 for Go, php:8.2-cli for PHP.

  2. Implement an Executor in internal/executor/<lang>.go:

    • Define a struct (e.g., GoExecutor).

    • Implement the Execute method to:

      • Pipe source code into the container.
      • Compile/interpret it inside /workspace.
      • Run the output binary/script.
  3. Register it in main.go:

    if args.Language == "go" {
        runtime = executor.GoExecutor{}
    }
    
  4. Write a test in internal/executor/go_test.go.

  5. 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.