home / mcp / mcp javascript sandbox server
Provides a secure QuickJS WASM sandbox to execute JavaScript via MCP and capture stdout and stderr.
Configuration
View docs{
"mcpServers": {
"jlucaso1-mcp-javascript-sandbox": {
"command": "node",
"args": [
"server.ts"
]
}
}
}You can run JavaScript snippets securely in a sandboxed QuickJS WASM environment and access the output through the MCP protocol. This server exposes a single tool, run_javascript_code, and streams stdout and stderr back to you for easy integration with your MCP clients.
You connect to the server via an MCP client over stdio and invoke the run_javascript_code tool by sending a JavaScript code string. The server executes the code inside a QuickJS WASM sandbox and returns three pieces of information: the captured standard output, the captured standard error, and any runtime errors. This lets you safely run potentially untrusted code and observe exactly what it prints or reports as errors.
Prerequisites you need on your machine before starting:
Step-by-step setup commands you should run in order:
# 1) Install dependencies
npm install
# 2) Ensure the QuickJS WASM file is in the expected location
# (e.g., ./dist/qjs-wasi.wasm if your build places it there)
# 3) Start the server
node server.tsSecure execution is achieved by running JavaScript code inside a WASI-enabled QuickJS sandbox. The server redirects stdout and stderr to files during execution and returns their contents to the MCP client. If an error occurs, you receive both runtime error information and the non-zero exit status when appropriate.
Environment and runtime details you might encounter: the server relies on a WASI-enabled runtime provided by Node.js and a pre-compiled WASM engine. Ensure the qjs-wasi.wasm file is available in the expected path relative to the server entry point, and that your Node.js version supports node:wasi for proper instantiation.
run_javascript_code: Executes a string of JavaScript within a sandboxed QuickJS WASM environment and returns stdout, stderr, and any execution errors to the MCP client.
Executes a JavaScript snippet inside a sandboxed QuickJS WASM environment and returns stdout, stderr, and any runtime errors to the MCP client.