Loading...

Runs isolated Node.js code snippets with npm dependencies in Docker containers, offering ephemeral and persistent execution modes with file saving.
Boost this tool
Subscribe to listing upgrades or segmented pushes.
Runs isolated Node.js code snippets with npm dependencies in Docker containers, offering ephemeral and persistent execution modes with file saving.
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.
Performance is limited by the Docker container's CPU and memory allocation. Network access can also impact performance. Ephemeral mode has higher overhead due to container creation/deletion.
Cost is primarily related to Docker resource usage (CPU, memory, storage). Consider the cost of pulling Docker images from remote registries.
npm install
npm run build{
"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"
]
}
}
}FILES_DIRSANDBOX_MEMORY_LIMITSANDBOX_CPU_LIMITrun_js_ephemeralExecutes 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.
sandbox_initializeStarts a new Docker container to serve as a persistent sandbox environment.
Initializes a container with potential for long-term code execution and resource usage.
sandbox_execExecutes shell commands inside a running sandbox container.
Enables arbitrary shell command execution, potentially leading to system compromise.
run_jsInstalls npm dependencies and runs JavaScript code within a persistent sandbox container.
Allows code execution and dependency installation in an existing container.
sandbox_stopTerminates and removes a running sandbox container.
Can disrupt running processes and potentially lose unsaved data.
search_npm_packagesSearches 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.
None
hybrid
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.
Autonomy is limited by the Docker container's resource constraints and security configuration. Ensure proper resource limits and security policies are in place to prevent abuse.
Production Tip
Pre-pull the required Docker images to minimize execution latency in production environments.
The container and all its data are deleted after the script execution completes.
Use the persistent sandbox mode (sandbox_initialize, run_js, sandbox_stop) and mount a volume to the container.
The default limits are defined by the SANDBOX_MEMORY_LIMIT and SANDBOX_CPU_LIMIT environment variables. Check the README for details.
Yes, you can access environment variables defined in the Docker container using process.env.
You cannot install global packages directly. You should include all necessary packages in the dependencies array.
The default image uses Node.js LTS. You can specify a different image with a specific Node.js version.
Use try/catch blocks to handle exceptions. Errors will be captured and returned in the tool's response.