QuickJS Runner
STDIOMCP server for secure JavaScript execution in a sandboxed QuickJS WASM environment.
MCP server for secure JavaScript execution in a sandboxed QuickJS WASM environment.
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.
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.
stdout and stderr from the executed JavaScript code.stdio.qjs-wasi.wasm) targeting the WebAssembly System Interface (WASI).node:wasi module in Node.js to instantiate and run the WASM module.stdout and stderr from the WASM environment, the server currently relies on the standard approach compatible with node:wasi:
node:fs/promises and node:os.stdout and stderr are opened within this directory.WASI instance during initialization (stdout: fd, stderr: fd).memfs were unsuccessful because node:wasi currently requires real OS file descriptors for stdio.)@modelcontextprotocol/sdk to listen for MCP requests via stdio and respond with the execution results formatted according to the protocol.node:wasi compatibility for your specific version)qjs-wasi.wasm) must be present in the same directory as the compiled server script (e.g., ./dist/qjs-wasi.wasm relative to ./dist/server.js). You may need to obtain or compile this separately.npm install
node server.ts