Gathering detailed insights and metrics for node-code-sandbox-mcp
Gathering detailed insights and metrics for node-code-sandbox-mcp
Gathering detailed insights and metrics for node-code-sandbox-mcp
Gathering detailed insights and metrics for node-code-sandbox-mcp
npm install node-code-sandbox-mcp
Typescript
Module System
Min. Node Version
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
20
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
Note: Containers run with controlled CPU/memory limits.
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.
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:
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:
1Create 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
1Create 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"
Add this to your claude_desktop_config.json
:
You can follow the Official Guide to install this MCP server
1{ 2 "mcpServers": { 3 "js-sandbox": { 4 "command": "docker", 5 "args": [ 6 "run", 7 "-i", 8 "--rm", 9 "-v", 10 "/var/run/docker.sock:/var/run/docker.sock", 11 "-v", 12 "$HOME/Desktop/sandbox-output:/root", 13 "-e", 14 "FILES_DIR=$HOME/Desktop/sandbox-output", 15 "-e", 16 "SANDBOX_MEMORY_LIMIT=512m", // optional 17 "-e", 18 "SANDBOX_CPU_LIMIT=0.75", // optional 19 "mcp/node-code-sandbox" 20 ] 21 } 22 } 23}
or with NPX:
1{ 2 "mcpServers": { 3 "node-code-sandbox-mcp": { 4 "type": "stdio", 5 "command": "npx", 6 "args": ["-y", "node-code-sandbox-mcp"], 7 "env": { 8 "FILES_DIR": "/Users/alfonsograziano/Desktop/node-sandbox", 9 "SANDBOX_MEMORY_LIMIT": "512m", // optional 10 "SANDBOX_CPU_LIMIT": "0.75" // optional 11 } 12 } 13 } 14}
Note: Ensure your working directory points to the built server, and Docker is installed/running.
Run the server in a container (mount Docker socket if needed), and pass through your desired host output directory as an env var:
1# Build locally if necessary 2# docker build -t mcp/node-code-sandbox . 3 4docker run --rm -it \ 5 -v /var/run/docker.sock:/var/run/docker.sock \ 6 -v "$HOME/Desktop/sandbox-output":"/root" \ 7 -e FILES_DIR="$HOME/Desktop/sandbox-output" \ 8 -e SANDBOX_MEMORY_LIMIT="512m" \ 9 -e SANDBOX_CPU_LIMIT="0.5" \ 10 mcp/node-code-sandbox stdio
This bind-mounts your host folder into the container at the same absolute path and makes FILES_DIR
available inside the MCP server.
1docker run --rm -it \ 2 -v /var/run/docker.sock:/var/run/docker.sock \ 3 alfonsograziano/node-code-sandbox-mcp stdio
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
:
1"mcp": { 2 "servers": { 3 "js-sandbox": { 4 "command": "docker", 5 "args": [ 6 "run", 7 "-i", 8 "--rm", 9 "-v", "/var/run/docker.sock:/var/run/docker.sock", 10 "-v", "$HOME/Desktop/sandbox-output:/root", // optional 11 "-e", "FILES_DIR=$HOME/Desktop/sandbox-output", // optional 12 "-e", "SANDBOX_MEMORY_LIMIT=512m", 13 "-e", "SANDBOX_CPU_LIMIT=1", 14 "mcp/node-code-sandbox" 15 ] 16 } 17 } 18}
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:
index.js
and a minimal package.json
.image
content..txt
, .json
) are returned as resource
content.Tip: To get files back, simply save them during your script execution.
Example Call:
1{ 2 "name": "run_js_ephemeral", 3 "arguments": { 4 "image": "node:lts-slim", 5 "code": "console.log('One-shot run!');", 6 "dependencies": [{ "name": "lodash", "version": "^4.17.21" }], 7 }, 8}
Example to save a file:
1import fs from 'fs/promises'; 2 3await fs.writeFile('hello.txt', 'Hello world!'); 4console.log('Saved hello.txt');
This will return the console output and the hello.txt
file.
Start a fresh sandbox container.
image
(string, optional, default: node:lts-slim
): Docker image for the sandboxport
(number, optional): If set, maps this container port to the hostRun shell commands inside the running sandbox.
container_id
(string): ID from sandbox_initialize
commands
(string[]): Array of shell commands to executeInstall npm dependencies and execute JavaScript code.
Input:
container_id
(string): ID from sandbox_initialize
code
(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:
index.js
and a minimal package.json
npm install --omit=dev --ignore-scripts --no-audit --loglevel=error
node index.js
and captures stdout, or leaves process running in background if listenOnPort
is setOutput: Script stdout or background execution notice
Terminate and remove the sandbox container.
container_id
(string): ID from sandbox_initialize
Search for npm packages by a search term and get their name, description, and a README snippet.
Input:
searchTerm
(string, required): The term to search for in npm packages. Should contain all relevant context. Use plus signs (+) to combine related terms (e.g., "react+components" for React component libraries).qualifiers
(object, optional): Optional qualifiers to filter the search results:
author
(string, optional): Filter by package author namemaintainer
(string, optional): Filter by package maintainer namescope
(string, optional): Filter by npm scope (e.g., "@vue" for Vue.js packages)keywords
(string, optional): Filter by package keywordsnot
(string, optional): Exclude packages matching this criteria (e.g., "insecure")is
(string, optional): Include only packages matching this criteria (e.g., "unstable")boostExact
(string, optional): Boost exact matches for this term in search resultsBehavior:
Output: JSON array containing package details with name, description, and README snippet
sandbox_initialize
➔ run_js
➔ sandbox_stop
) are ideal when you want to:
run_js_ephemeral
is perfect for:
Choose the workflow that best fits your use-case!
Compile and bundle:
1npm install 2npm run build
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.
7.5/10
Summary
Node.js Sandbox MCP Server vulnerability can lead to Sandbox Escape via Command Injection
Affected Versions
<= 1.2.0
Patched Versions
1.3.0
No security vulnerabilities found.