Node.js Code Sandbox▌

by ssdeanx
Node.js Code Sandbox offers a secure, isolated Docker environment to run Node.js code, npm dependencies, and shell comma
Provides a secure Docker-based environment for executing Node.js code with npm dependencies, shell commands, and file operations while maintaining proper isolation for testing and web development prototyping.
best for
- / Testing JavaScript libraries without local installation
- / Web development prototyping and experiments
- / Running untrusted code safely
- / Automating browser tasks with Playwright
capabilities
- / Execute JavaScript code in Docker containers
- / Install npm dependencies on-demand
- / Run shell commands inside sandboxes
- / Create and manage files within containers
- / Keep containers alive for long-running processes
- / Control CPU and memory limits
what it does
Executes JavaScript code in isolated Docker containers with automatic npm dependency installation and file operations. Provides a secure sandbox environment for running Node.js scripts without affecting your local system.
about
Node.js Code Sandbox is a community-built MCP server published by ssdeanx that provides AI assistants with tools and capabilities via the Model Context Protocol. Node.js Code Sandbox offers a secure, isolated Docker environment to run Node.js code, npm dependencies, and shell comma It is categorized under developer tools.
how to install
You can install Node.js Code Sandbox in your AI client of choice. Use the install panel on this page to get one-click setup for Cursor, Claude Desktop, VS Code, and other MCP-compatible clients. This server runs locally on your machine via the stdio transport.
license
MIT
Node.js Code Sandbox is released under the MIT license. This is a permissive open-source license, meaning you can freely use, modify, and distribute the software.
readme
🐢🚀 Node.js Sandbox MCP Server
Node.js server implementing the Model Context Protocol (MCP) for running arbitrary JavaScript in ephemeral Docker containers with on‑the‑fly npm dependency installation.

👉 Look at the official website
Features
- Start and manage isolated Node.js sandbox containers
- Execute arbitrary shell commands inside containers
- Install specified npm dependencies per job
- Run ES module JavaScript snippets and capture stdout
- Tear down containers cleanly
- Detached Mode: Keep the container alive after script execution (e.g. for long-running servers)
Note: Containers run with controlled CPU/memory limits.
Explore Cool Use Cases
If you want ideas for cool and powerful ways to use this library, check out the use cases section on the website It contains a curated list of prompts, examples, and creative experiments you can try with the Node.js Sandbox MCP Server.
⚠️ Prerequisites
To use this MCP server, Docker must be installed and running on your machine.
Tip: Pre-pull any Docker images you'll need to avoid delays during first execution.
Example recommended images:
- node:lts-slim
- mcr.microsoft.com/playwright:v1.52.0-noble
- alfonsograziano/node-chartjs-canvas:latest
Getting started
In order to get started with this MCP server, first of all you need to connect it to a client (for example Claude Desktop).
Once it's running, you can test that it's fully working with a couple of test prompts:
-
Validate that the tool can run:
Create and run a JS script with a console.log("Hello World")This should run a console.log and in the tool response you should be able to see Hello World.
-
Validate that you can install dependencies and save files
Create and run a JS script that generates a QR code for the URL `https://nodejs.org/en`, and save it as `qrcode.png` **Tip:** Use the `qrcode` package.This should create a file in your mounted directory (for example the Desktop) called "qrcode.png"
Usage with Claude Desktop
Add this to your claude_desktop_config.json:
You can follow the Official Guide to install this MCP server
{
"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
"alfonsograziano/node-code-sandbox-mcp"
]
}
}
}
or with NPX:
{
"mcpServers": {
"node-code-sandbox-mcp": {
"type": "stdio",
"command": "npx",
"args": ["-y", "node-code-sandbox-mcp"],
"env": {
"FILES_DIR": "/Users/alfonsograziano/Desktop/node-sandbox",
"SANDBOX_MEMORY_LIMIT": "512m", // optional
"SANDBOX_CPU_LIMIT": "0.75" // optional
}
}
}
}
Note: Ensure your working directory points to the built server, and Docker is installed/running.
Docker
Run the server in a container (mount Docker socket if needed), and pass through your desired host output directory as an env var:
# Build locally if necessary
# docker build -t alfonsograziano/node-code-sandbox-mcp .
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" \
alfonsograziano/node-code-sandbox-mcp stdio
This bind-mounts your host folder into the container at the same absolute path and makes FILES_DIR available inside the MCP server.
Usage with VS Code
Quick install buttons (VS Code & Insiders):
Install js-sandbox-mcp (NPX) Install js-sandbox-mcp (Docker)
Manual configuration: Add to your VS Code settings.json or .vscode/mcp.json:
"mcp": {
"servers": {
"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",
"-e", "SANDBOX_CPU_LIMIT=1",
"alfonsograziano/node-code-sandbox-mcp"
]
}
}
}
API
Tools
run_js_ephemeral
Run a one-off JS script in a brand-new disposable container.
Inputs:
image(string, optional): Docker image to use (default:node:lts-slim).code(string, required): JavaScript source to execute.dependencies(array of{ name, version }, optional): NPM packages and versions to install (default:[]).
Behavior:
- Creates a fresh container.
- Writes your
index.jsand a minimalpackage.json. - Installs the specified dependencies.
- Executes the script.
- Tears down (removes) the container.
- Returns the captured stdout.
- If your code saves any files in the current directory, these files will be returned automatically.
- Images (e.g., PNG, JPEG) are returned as
imagecontent. - Other files (e.g.,
.txt,.json) are returned asresourcecontent. - Note: the file saving feature is currently available only in the ephemeral tool.
- Images (e.g., PNG, JPEG) are returned as
Tip: To get files back, simply save them during your script execution.
Example Call:
{
"name": "run_js_ephemeral",
"arguments": {
"image": "node:lts-slim",
"code": "console.log('One-shot run!');",
"dependencies": [{ "name": "lodash", "version": "^4.17.21" }],
},
}
Example to save a file:
import fs from 'fs/promises';
await fs.writeFile('hello.txt', 'Hello world!');
console.log('Saved hello.txt');
This will return the console output and the hello.txt file.
sandbox_initialize
Start a fresh sandbox container.
- Input:
image(string, optional, default:node:lts-slim): Docker image for the sandboxport(number, optional): If set, maps this container port to the host
- Output: Container ID string
sandbox_exec
Run shell commands inside the running sandbox.
- Input:
container_id(string): ID fromsandbox_initializecommands(string[]): Array of shell commands to execute
- Output: Combined stdout of each command
run_js
Install npm dependencies and execute JavaScript code.
-
Input:
container_id(string): ID fromsandbox_initializecode(string): JS source to run (ES modules supported)dependencies(array of{ name, version }, optional, default:[]): npm package names → semver versionslistenOnPort(number, optional): If set, leaves the process running and exposes this port to the host (Detached Mode)
-
Behavior:
- Creates a temp workspace inside the container
- Writes
index.jsand a minimalpackage.json - Runs
npm install --omit=dev --ignore-scripts --no-audit --loglevel=error - Executes
node index.jsand captures stdout, or leaves process running in background iflistenOnPortis set - Cleans up workspace unless running in detached mode
-
Output: Script stdout or background execution notice
sandbox_stop
Terminate and remove the sandbox container.
- Input:
container_id(string): ID fromsandbox_initialize
- Output: Confirmation message
Usage Tips
- Session-based tools (
sandbox_initialize➔run_js➔sandbox_stop) are ideal when you want to:- Keep a long-lived sandbox container open.
- Run multiple commands or scripts in the same environment.
- Incrementally install and reuse dependencies.
- One-shot execution with
run_js_ephemeralis perfect for:- Quick experiments or simple scripts.
- Cases where you don’t need to maintain state or cache dependencies.
- Clean, atomic runs without worrying about manual teardown.
- Detached mode is useful when you want to:
- Spin up servers or long-lived services on-the-fly
- Expose and test endpoints from running containers
Choose the workflow that best fits your use-case!
Build
Compile and bundle:
npm install
npm run build
License
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQ
- What is the Node.js Code Sandbox MCP server?
- Node.js Code Sandbox is a Model Context Protocol (MCP) server profile on explainx.ai. MCP lets AI hosts (e.g. Claude Desktop, Cursor) call tools and resources through a standard interface; this page summarizes categories, install hints, and community ratings.
- How do MCP servers relate to agent skills?
- Skills are reusable instruction packages (often SKILL.md); MCP servers expose live capabilities. Teams frequently combine both—skills for workflows, MCP for APIs and data. See explainx.ai/skills and explainx.ai/mcp-servers for parallel directories.
- How are reviews shown for Node.js Code Sandbox?
- This profile displays 10 aggregated ratings (sample rows for discoverability plus signed-in user reviews). Average score is about 4.5 out of 5—verify behavior in your own environment before production use.
Ratings
4.5★★★★★10 reviews- ★★★★★Shikha Mishra· Oct 10, 2024
Node.js Code Sandbox is among the better-indexed MCP projects we tried; the explainx.ai summary tracks the official description.
- ★★★★★Piyush G· Sep 9, 2024
We evaluated Node.js Code Sandbox against two servers with overlapping tools; this profile had the clearer scope statement.
- ★★★★★Chaitanya Patil· Aug 8, 2024
Useful MCP listing: Node.js Code Sandbox is the kind of server we cite when onboarding engineers to host + tool permissions.
- ★★★★★Sakshi Patil· Jul 7, 2024
Node.js Code Sandbox reduced integration guesswork — categories and install configs on the listing matched the upstream repo.
- ★★★★★Ganesh Mohane· Jun 6, 2024
I recommend Node.js Code Sandbox for teams standardizing on MCP; the explainx.ai page compares cleanly with sibling servers.
- ★★★★★Oshnikdeep· May 5, 2024
Strong directory entry: Node.js Code Sandbox surfaces stars and publisher context so we could sanity-check maintenance before adopting.
- ★★★★★Dhruvi Jain· Apr 4, 2024
Node.js Code Sandbox has been reliable for tool-calling workflows; the MCP profile page is a good permalink for internal docs.
- ★★★★★Rahul Santra· Mar 3, 2024
According to our notes, Node.js Code Sandbox benefits from clear Model Context Protocol framing — fewer ambiguous “AI plugin” claims.
- ★★★★★Pratham Ware· Feb 2, 2024
We wired Node.js Code Sandbox into a staging workspace; the listing’s GitHub and npm pointers saved time versus hunting across READMEs.
- ★★★★★Yash Thakker· Jan 1, 2024
Node.js Code Sandbox is a well-scoped MCP server in the explainx.ai directory — install snippets and categories matched our Claude Code setup.