Node.js Sandbox MCP Server is an MCP server that enables AI assistants to execute arbitrary JavaScript and Node.js code inside secure, isolated Docker containers. It connects AI clients such as Claude Desktop or VS Code directly to the host Docker daemon, allowing assistants to dynamically run ES modules, install npm packages on the fly, and inspect script outputs. Developers, automation engineers, and data practitioners use this server to safely test code snippets, generate diagrams, create local files, and inspect package documentation without polluting their host operating systems. The server offers both disposable, single-execution environments that self-terminate and long-lived sessions that allow incremental testing or persistent background servers via detached mode. Additionally, generated artifacts such as images and text files are automatically captured and passed back to the client interface, while resource controls like configurable CPU and memory limits ensure the host machine remains stable during intensive executions.
Category: Cloud & Infrastructure
Tags: docker, javascript, nodejs, npm, sandbox
Visit Node.js Sandbox MCP Server
claude_desktop_config.json for Claude Desktop or settings.json for VS Code. 3. Add the server entry under the mcpServers object using Docker: json { "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", "mcp/node-code-sandbox" ] } } } 4. Alternatively, configure the server via NPX by setting command to npx and args to ["-y", "node-code-sandbox-mcp"]. 5. Restart your MCP client to initialize the sandbox connection.run_js_ephemeral to process data and automatically receive created files directly in your chat interface. * Search the npm registry with search_npm_packages to inspect dependencies, package descriptions, and README excerpts before running code. * Spin up persistent environments via sandbox_initialize to execute multiple shell commands and share context across multiple script runs. * Launch background web servers or services inside containers using run_js with the listenOnPort parameter enabled. * Generate media assets such as QR codes, charts, or images by running scripts with pre-installed Node.js graphical libraries.Part of MCP Servers
Node.js Sandbox MCP Server lets AI clients run JavaScript in Docker containers. It supports installing npm dependencies on the fly, running ephemeral or persistent containers, running shell commands, searching the npm registry, exposing ports for long-running servers, and returning generated files like images and text directly back to the chat interface.
Docker must be installed and actively running on the host system. The server interacts with the Docker socket to spin up, configure, and tear down containers. Pre-pulling recommended Docker images like node:lts-slim or custom Playwright images is recommended to avoid download delays during initial runs.
The server works with any Model Context Protocol client supporting stdio transport. It includes tested setup instructions for Claude Desktop and Visual Studio Code, and it can be run either directly via an official Docker container image or through an NPX execution command.
Yes, Node.js Sandbox MCP Server is open source software published under the MIT License. The complete source code, issue tracker, and contribution details are publicly available in its GitHub repository.