Skip to main content
Glama

Node Code Sandbox MCP

by mozicim

run_js_ephemeral

Execute JavaScript code in temporary containers with optional npm dependencies, automatically cleaning up after execution for secure one-time script runs.

Instructions

Run a JavaScript snippet in a temporary disposable container with optional npm dependencies, then automatically clean up. The code must be valid ESModules (import/export syntax). Ideal for simple one-shot executions without maintaining a sandbox or managing cleanup manually. When reading and writing from the Node.js processes, you always need to read from and write to the "./files" directory to ensure persistence on the mounted volume. This includes images (e.g., PNG, JPEG) and other files (e.g., text, JSON, binaries).

Example:

import fs from "fs/promises"; await fs.writeFile("./files/hello.txt", "Hello world!"); console.log("Saved ./files/hello.txt");

Input Schema

NameRequiredDescriptionDefault
codeYesJavaScript code to run inside the ephemeral container.
dependenciesNoA list of npm dependencies to install before running the code. Each item must have a `name` (package) and `version` (range). If none, returns an empty array.
imageNoDocker image to use for ephemeral execution. e.g. - **node:lts-slim**: Node.js LTS version, slim variant. (Lightweight and fast for JavaScript execution tasks.) - **mcr.microsoft.com/playwright:v1.52.0-noble**: Playwright image for browser automation. (Preconfigured for running Playwright scripts.) - **alfonsograziano/node-chartjs-canvas:latest**: Chart.js image for chart generation and mermaid charts generation. ('Preconfigured for generating charts with chartjs-node-canvas and Mermaid. Minimal Mermaid example: import fs from "fs"; import { run } from "@mermaid-js/mermaid-cli"; fs.writeFileSync("./files/diagram.mmd", "graph LR; A-->B;", "utf8"); await run("./files/diagram.mmd", "./files/diagram.svg");)node:lts-slim

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "code": { "description": "JavaScript code to run inside the ephemeral container.", "type": "string" }, "dependencies": { "default": [], "description": "A list of npm dependencies to install before running the code. Each item must have a `name` (package) and `version` (range). If none, returns an empty array.", "items": { "additionalProperties": false, "properties": { "name": { "description": "npm package name, e.g. lodash", "type": "string" }, "version": { "description": "npm package version range, e.g. ^4.17.21", "type": "string" } }, "required": [ "name", "version" ], "type": "object" }, "type": "array" }, "image": { "default": "node:lts-slim", "description": "Docker image to use for ephemeral execution. e.g. - **node:lts-slim**: Node.js LTS version, slim variant. (Lightweight and fast for JavaScript execution tasks.)\n- **mcr.microsoft.com/playwright:v1.52.0-noble**: Playwright image for browser automation. (Preconfigured for running Playwright scripts.)\n- **alfonsograziano/node-chartjs-canvas:latest**: Chart.js image for chart generation and mermaid charts generation. ('Preconfigured for generating charts with chartjs-node-canvas and Mermaid. Minimal Mermaid example:\n import fs from \"fs\";\n import { run } from \"@mermaid-js/mermaid-cli\";\n fs.writeFileSync(\"./files/diagram.mmd\", \"graph LR; A-->B;\", \"utf8\");\n await run(\"./files/diagram.mmd\", \"./files/diagram.svg\");)", "type": "string" } }, "required": [ "code" ], "type": "object" }

Other Tools from Node Code Sandbox MCP

Related Tools

    MCP directory API

    We provide all the information about MCP servers via our MCP API.

    curl -X GET 'https://glama.ai/api/mcp/v1/servers/mozicim/node-code-sandbox-mcp'

    If you have feedback or need assistance with the MCP directory API, please join our Discord server