Get the FREE Ultimate OpenClaw Setup Guide →

node-code-sandbox

A Node.js–based Model Context Protocol server that spins up disposable Docker containers to execute arbitrary JavaScript.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio alfonsograziano-node-code-sandbox-mcp npx -y node-code-sandbox-mcp \
  --env FILES_DIR="/Users/you/Desktop/node-sandbox-output" \
  --env SANDBOX_CPU_LIMIT="0.75" \
  --env SANDBOX_MEMORY_LIMIT="512m"

How to use

The Node.js Sandbox MCP Server lets you run arbitrary JavaScript inside isolated ephemeral Docker containers with on-the-fly npm dependency installation. It exposes a set of tools that create a fresh container, install your requested dependencies, execute your code, and return stdout along with any saved files. This makes it ideal for testing small code snippets, exploring npm packages, or performing one-off computations in a controlled sandbox. Use the provided tools to spin up a sandbox, run JavaScript (with ES module support), and manage the container lifecycle. If you enable detached mode, you can keep the sandbox running to interact with it over time.

How to install

Prerequisites:

  • Docker installed and running on the host
  • Node.js (for NPX usage) or access to Docker-based deployment

Installation options:

  1. NPX (recommended if you have Node.js):
# Install and run the MCP server via NPX
npx -y node-code-sandbox-mcp
  1. Docker (standalone container):
# Build the image locally if needed
# docker build -t mcp/node-code-sandbox .

# Run the MCP server in a container (example)
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" \
  -e SANDBOX_MEMORY_LIMIT="512m" \
  -e SANDBOX_CPU_LIMIT="0.5" \
  mcp/node-code-sandbox stdio
  1. VM/host installation (if provided by the project): follow the repository’s official setup steps, ensuring Docker access and required environment variables are documented in your deployment script.

Additional notes

Tips and common issues:

  • Ensure Docker is running and the host user has permission to access the Docker daemon.
  • If you plan to persist outputs, mount a host directory and set FILES_DIR accordingly.
  • SANDBOX_MEMORY_LIMIT and SANDBOX_CPU_LIMIT are optional but help prevent resource exhaustion; tune them to your workload.
  • In ephemeral mode, no data is kept between runs unless you explicitly mount and save through FILES_DIR.
  • For ES module support, ensure your code uses import/export syntax and the server’s Node image includes a compatible Node.js version.
  • When using NPX, you must have Node.js/npm installed on the host; NPX will fetch the MCP server package at runtime.

Related MCP Servers

Sponsor this space

Reach thousands of developers