Node.js MCP server that launches disposable Docker containers to run arbitrary JavaScript with on-the-fly npm dependency installation.
https://github.com/alfonsograziano/node-code-sandbox-mcpRun any JavaScript code in isolated Docker containers without contaminating your development environment.
You know the drill: you want to test a quick npm package, generate some files, or prototype an idea – but you don't want to mess with your local Node setup or install dependencies you'll never use again. This MCP server solves that by spinning up disposable Docker containers that execute your JavaScript and clean up after themselves.
Zero Environment Pollution: Every script runs in a fresh container with exactly the dependencies you specify. No leftover packages cluttering your global installs, no version conflicts, no cleanup headaches.
Instant Package Testing: Want to try that new charting library or image processing package? Just specify it in the dependencies array and start coding immediately. No need to create a test project, run npm install, or remember to clean up later.
Safe Code Execution: Run untrusted code, experiment with dangerous operations, or test system-level scripts without risk. The containers run with controlled CPU/memory limits and network isolation.
File Generation Made Simple: Generate QR codes, charts, PDFs, or any other assets directly from your AI conversation. The server automatically detects and returns files your scripts create – images come back as viewable content, text files as downloadable resources.
Quick Data Processing:
// Generate a CSV report from API data
const data = await fetch('https://api.example.com/sales');
const csv = convertToCSV(data);
await fs.writeFile('sales-report.csv', csv);
The CSV appears instantly in your specified output directory.
Package Evaluation:
// Test three different date libraries without installing any
import { format } from 'date-fns';
import dayjs from 'dayjs';
import moment from 'moment';
console.log('Comparing formats:');
console.log('date-fns:', format(new Date(), 'yyyy-MM-dd'));
console.log('dayjs:', dayjs().format('YYYY-MM-DD'));
console.log('moment:', moment().format('YYYY-MM-DD'));
Asset Generation:
// Create a QR code for your deployment URL
import QRCode from 'qrcode';
await QRCode.toFile('deployment-qr.png', 'https://myapp.com');
API Prototyping: Use detached mode to spin up temporary servers for testing integrations or webhooks without setting up local infrastructure.
Ephemeral Mode (run_js_ephemeral): Perfect for one-shot scripts. Container spins up, runs your code, returns output and files, then disappears. Zero cleanup required.
Session Mode (sandbox_initialize → run_js → sandbox_stop): Ideal when you need to run multiple scripts in the same environment, incrementally install dependencies, or maintain state across executions.
Detached Mode: Keeps containers running for long-lived services. Spin up a temporary API server, run integration tests against it, then tear it down.
{
"mcpServers": {
"js-sandbox": {
"command": "npx",
"args": ["-y", "node-code-sandbox-mcp"],
"env": {
"FILES_DIR": "/Users/yourname/Desktop/sandbox-output"
}
}
}
}
docker run --rm -it \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$HOME/Desktop/sandbox-output:/root" \
-e FILES_DIR="$HOME/Desktop/sandbox-output" \
mcp/node-code-sandbox stdio
Containers run with memory/CPU limits, no network access by default, and controlled file system access. You get the flexibility of arbitrary code execution with the safety of proper isolation.
The built-in npm package search helps you discover and evaluate packages before using them, so you're not flying blind when adding dependencies.
Bottom line: This MCP server turns your AI assistant into a safe JavaScript playground where you can prototype, generate assets, and test packages without any setup friction or environment concerns. Perfect for the developer who values both experimentation speed and system cleanliness.