- Explore MCP Servers
- mcp-javascript-sandbox
Mcp Javascript Sandbox
What is Mcp Javascript Sandbox
mcp-javascript-sandbox is a server that implements the Model Context Protocol (MCP) to securely execute arbitrary JavaScript code within a QuickJS engine compiled to WebAssembly (WASM) and run using Node.js’s built-in WASI implementation.
Use cases
Use cases include executing user-provided JavaScript snippets in a secure manner, testing JavaScript code in a controlled environment, and integrating JavaScript execution into applications that require dynamic code evaluation.
How to use
To use mcp-javascript-sandbox, send a request to the server with a string of JavaScript code as input. The server will execute the code in a sandboxed environment and return the standard output, standard error, and any execution errors back to the client.
Key features
Key features include secure execution of JavaScript in a WASM sandbox, standard I/O capture for stdout and stderr, error reporting for runtime errors and non-zero exit codes, MCP integration for tool functionality, and development with TypeScript for type safety.
Where to use
mcp-javascript-sandbox can be used in environments where safe execution of untrusted JavaScript code is required, such as in language models, web applications, and server-side scripting.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Mcp Javascript Sandbox
mcp-javascript-sandbox is a server that implements the Model Context Protocol (MCP) to securely execute arbitrary JavaScript code within a QuickJS engine compiled to WebAssembly (WASM) and run using Node.js’s built-in WASI implementation.
Use cases
Use cases include executing user-provided JavaScript snippets in a secure manner, testing JavaScript code in a controlled environment, and integrating JavaScript execution into applications that require dynamic code evaluation.
How to use
To use mcp-javascript-sandbox, send a request to the server with a string of JavaScript code as input. The server will execute the code in a sandboxed environment and return the standard output, standard error, and any execution errors back to the client.
Key features
Key features include secure execution of JavaScript in a WASM sandbox, standard I/O capture for stdout and stderr, error reporting for runtime errors and non-zero exit codes, MCP integration for tool functionality, and development with TypeScript for type safety.
Where to use
mcp-javascript-sandbox can be used in environments where safe execution of untrusted JavaScript code is required, such as in language models, web applications, and server-side scripting.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
MCP QuickJS Runner
A server implementing the Model Context Protocol (MCP) that provides a tool to securely execute arbitrary JavaScript code within a QuickJS engine compiled to WebAssembly (WASM) and run using Node.js’s built-in WASI implementation.
Description
This server acts as an MCP tool provider. It exposes a single tool, run_javascript_code, which takes a string of JavaScript code as input. The code is then executed inside a sandboxed QuickJS WASM environment. The server captures the standard output (stdout) and standard error (stderr) streams from the execution and returns them, along with any execution errors, back to the MCP client.
This allows language models or other MCP clients to safely execute potentially untrusted JavaScript code snippets without compromising the host system.
Features
- Secure Execution: Runs JavaScript in a WASM sandbox using QuickJS and Node.js WASI.
- Standard I/O Capture: Captures
stdoutandstderrfrom the executed JavaScript code. - Error Reporting: Reports runtime errors from QuickJS and non-zero exit codes.
- MCP Integration: Exposes functionality as a standard MCP tool over
stdio. - Built with TypeScript: Provides type safety during development.
How it Works
- WASM Module: Uses a pre-compiled QuickJS engine (
qjs-wasi.wasm) targeting the WebAssembly System Interface (WASI). - Node.js WASI: Leverages the
node:wasimodule in Node.js to instantiate and run the WASM module. - Stdio Redirection (Temporary Files): To capture
stdoutandstderrfrom the WASM environment, the server currently relies on the standard approach compatible withnode:wasi:- A temporary directory is created on the host filesystem using
node:fs/promisesandnode:os. - Temporary files for
stdoutandstderrare opened within this directory. - The real OS file descriptors for these files are passed to the
WASIinstance during initialization (stdout: fd,stderr: fd). - The QuickJS WASM module writes its output to these descriptors, which gets routed by WASI to the temporary files.
- After execution finishes, the server closes the file handles and reads the content of the temporary files.
- The temporary directory and files are cleaned up.
- (Note: Attempts to use in-memory pipes or virtual filesystems like
memfswere unsuccessful becausenode:wasicurrently requires real OS file descriptors for stdio.)
- A temporary directory is created on the host filesystem using
- MCP Communication: The server uses
@modelcontextprotocol/sdkto listen for MCP requests viastdioand respond with the execution results formatted according to the protocol.
Prerequisites
- Node.js (v23.x or later recommended, check
node:wasicompatibility for your specific version) - npm or yarn
- The QuickJS WASM file (
qjs-wasi.wasm) must be present in the same directory as the compiled server script (e.g.,./dist/qjs-wasi.wasmrelative to./dist/server.js). You may need to obtain or compile this separately.
Installation
- Clone the repository (if applicable).
- Install dependencies:
npm install
Usage
node server.ts
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










