================== /// MCP /// /// NOD /// ================== [server:online] [protocol:ready]
node-code-sandbox-mcp
by alfonsograziano
Node.js Model Context Protocol (MCP) server that launches disposable Docker containers to run arbitrary JavaScript with on-the-fly npm dependency installation.
run_js_ephemeral
Run a one-off JavaScript script in a brand-new disposable Docker container, optionally installing npm dependencies, and return stdout plus any files generated by the script.
sandbox_initialize
Start a fresh, long-lived sandbox container (optionally specifying image and port) and return its container ID.
sandbox_exec
Execute one or more shell commands inside an existing sandbox container and return the combined stdout.
run_js
Within an existing sandbox container, install specified npm dependencies and execute JavaScript code (supports detached mode via listenOnPort); returns the script output or a background-running notice.
sandbox_stop
Terminate and remove a sandbox container identified by its container ID, returning a confirmation message.
search_npm_packages
Search the npm registry for packages matching a term and optional qualifiers, returning details for up to five packages (name, description, README snippet).
Installation
git clone https://github.com/alfonsograziano/node-code-sandbox-mcp.git
cd node-code-sandbox-mcp
npm install # or: pnpm install / yarn install
npm run build # outputs to /dist
# During development you can use:
npm run dev # nodemon + ts-node
# Maximum execution time (ms) for each sandbox run
SANDBOX_TIMEOUT=8000
# Memory limit for the container (e.g., 128m)
SANDBOX_MEMORY=128m
# Docker socket or remote host (defaults to local /var/run/docker.sock)
DOCKER_HOST=
# Optional: port on which the MCP server will listen
PORT=8080
# Production (compiled JS in /dist)
node dist/index.js
# or, if using ts-node directly
npm run start
curl -X POST http://localhost:8080/mcp/v1/execute -d '{"code":"console.log(123)"}' -H "Content-Type: application/json"