garc33/js-sandbox-mcp-server
Project Overview
js-sandbox MCP Server
An MCP server that executes JavaScript code inside a vm2 sandbox for AI assistants.
True Intent (AI Assessment)
Provide LLM clients with a JavaScript code execution tool over the Model Context Protocol.
README Accuracy
Notes
The code matches the README's stated functionality, but the 'secure' and 'protection against malicious code' claims are overstated: vm2 is a deprecated library with known sandbox escapes, and the forbidden-pattern filter is a simple string match that is easy to circumvent.
This is a Model Context Protocol (MCP) server written in TypeScript that exposes a single tool, `execute_js`, allowing an MCP client (such as Claude Desktop) to run arbitrary JavaScript code in an isolated environment and receive back the result, console output, execution time, and memory usage.
The problem it addresses is that large language models like Claude cannot natively execute code. By adding this MCP server, an AI assistant gains the ability to run JavaScript snippets to compute results, test logic, or process data, without giving the model direct access to the host system. Configurable timeout (100ms-30s) and memory limits (1MB-100MB) are exposed to prevent runaway scripts.
The intended users are developers integrating LLMs (primarily Anthropic's Claude via the MCP protocol) who want to give the model a code execution tool. Installation is either manual via a claude_desktop_config.json entry or automated through the Smithery registry, and the server communicates over stdio.
Internally, the server uses the `@modelcontextprotocol/sdk` to handle MCP requests, parses incoming code with `acorn` for basic syntactic validation, blacklists a handful of dangerous identifiers (`process`, `require`, `eval`, `Buffer`, `global`, etc.), and then runs the code inside a `vm2` NodeVM with `require: false` and `eval: false`. Execution results and errors are logged to a local `js-sandbox.log` file via winston. A Dockerfile and GitHub Actions workflow build and publish the package to npm.
Notable red flags: the project depends on `vm2` (^3.9.19), which has been publicly deprecated by its maintainer due to unfixable sandbox escape vulnerabilities — vm2 is no longer considered a secure isolation mechanism. The forbidden-pattern check is a naive substring match on source text, which can be trivially bypassed (e.g., by string concatenation or unicode escapes). Despite the README's security claims, the isolation guarantees here are weak and should not be relied upon for untrusted code in production.
| Languages | TypeScript, JavaScript, Dockerfile |
| Runtime | Node.js 18+ / 20+ |
| Framework | Model Context Protocol SDK |
| Database | None detected |
| Package Manager | npm |
| Key Dependencies | @modelcontextprotocol/sdk, vm2, acorn, winston |
| Build Tool | TypeScript compiler (tsc) |
| Test Framework | None detected |