Back to MCP Directory
Node Code Sandbox
Model Context Protocol moderate risk

Node Code Sandbox

Runs isolated Node.js code snippets with npm dependencies in Docker containers, offering ephemeral and persistent execution modes with file saving.

Connections & Capabilities

Connects To

DockerPlaywright

Capabilities

readwriteexec

Quickstart

Install

npm install
npm run build

Config

{
  "mcpServers": {
    "js-sandbox": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-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", // optional
        "-e",
        "SANDBOX_CPU_LIMIT=0.75", // optional
        "mcp/node-code-sandbox"
      ]
    }
  }
}

Exposed MCP Tools (6)

moderate
run_js_ephemeral

Executes a JavaScript script in a new, isolated container and returns the output and any saved files.

Allows arbitrary code execution and file system writes within a sandboxed environment.

moderate
sandbox_initialize

Starts a new Docker container to serve as a persistent sandbox environment.

Initializes a container with potential for long-term code execution and resource usage.

high
sandbox_exec

Executes shell commands inside a running sandbox container.

Enables arbitrary shell command execution, potentially leading to system compromise.

moderate
run_js

Installs npm dependencies and runs JavaScript code within a persistent sandbox container.

Allows code execution and dependency installation in an existing container.

moderate
sandbox_stop

Terminates and removes a running sandbox container.

Can disrupt running processes and potentially lose unsaved data.

safe
search_npm_packages

Searches the npm registry for packages based on a search term and returns package details.

Read-only operation that retrieves package information from the npm registry.

Safety Assessment

This MCP server provides a sandboxed environment for executing Node.js code, but the level of safety depends heavily on the Docker configuration and resource limits. It is relatively safe for running simple, isolated scripts, but can be risky if the Docker environment is not properly secured or if untrusted code is executed.

  • Sandboxed execution within Docker containers
  • CPU and memory limits can be configured
  • Ephemeral mode ensures no persistent changes
  • Option to specify allowed npm dependencies
  • Arbitrary code execution is possible
  • File system access within the container, potentially leading to data exfiltration if not properly configured
  • Docker socket access required, which can be a privilege escalation vector if misconfigured
  • No built-in RBAC or authentication beyond Docker's isolation