Skip to main content
Glama

JavaScript sandbox

FLOWRA_JS_REMOTE_WORKBENCH
Destructive

Process REMOTE FILES or script BULK TOOL EXECUTIONS using JavaScript code in a REMOTE SANDBOX. If you can see the data in chat, DON'T USE THIS TOOL.

ONLY use this when processing data stored in a remote file or when scripting bulk tool executions.

BOUNDARY WITH FLOWRA_REMOTE_BASH

  • Both tools share one sandbox per session.id and the same /home/user/files files.

  • This tool runs JavaScript and keeps variables between calls. Only this tool has run_tool (app tools), invoke_llm, proxy_execute, and upload_local_file.

  • FLOWRA_REMOTE_BASH runs one shell command with a fresh shell each call and none of those helpers. Use it for jq, grep, sort, unzip, or listing files.

  • Neither tool can call FLOWRA_MULTI_EXECUTE_TOOL or any other FLOWRA_* meta tool.

DO NOT USE

  • When the complete response is already inline/in-memory, or you only need quick parsing, summarization, or basic math.

USE IF

  • To parse/analyze tool outputs saved to a remote file in the sandbox or to script multi-tool chains there.

  • After FLOWRA_MULTI_EXECUTE_TOOL with syncResponseToWorkbench: true and the same session.id: the snapshot is at /home/user/files/multi_execute.json and as FLOWRA_WORKBENCH_SNAPSHOT. FLOWRA_REMOTE_BASH sees the same file.

  • For bulk or repeated executions of known Flowra tools (e.g., add a label to 100 emails).

  • To call APIs via proxy_execute when no Flowra tool exists for that API.

OUTPUTS

  • Returns a compact result or, if too long, artifacts for download.

IMPORTANT CODING RULES:

  1. Stepwise Execution: Split work into small steps. Save intermediate outputs in variables or temporary storage. Call FLOWRA_JS_REMOTE_WORKBENCH again for the next step. This improves composability and avoids timeouts.

  2. Session Persistence: This is a persistent JavaScript execution context: variables, functions, and in-memory state from previous and future code executions are preserved in the sandbox session and available for reuse. Do not import or redeclare the helpers below.

  3. Parallelism & Timeout (CRITICAL): There is a hard timeout of 4 minutes. Prioritize PARALLEL execution using Promise.all() with suitable concurrency for bulk operations (e.g., call run_tool or invoke_llm in parallel across items). 3.1 If the data is large, split into smaller batches and call the workbench multiple times to avoid timeouts.

  4. Checkpoints: Implement checkpoints (in memory or variables) so that long runs can be resumed from the last completed step.

  5. Schema Safety: Never assume the response schema for run_tool if not known already from previous tools. To inspect schema, run a simple request via MULTI_EXECUTE_TOOL or use invoke_llm helper.

  6. LLM Helpers: Always use invoke_llm helper for summary, analysis, or field extraction on results. Prefer batching items into smaller groups to stay within token limit.

  7. Avoid Meta Loops: Do not use run_tool to call MULTI_EXECUTE_TOOL or other FLOWRA_* meta tools to avoid cycles. Only use it for app tools.

  8. Pagination: Use when data spans multiple pages. Continue fetching pages with the returned next_page_token or cursor until none remains. Parallelize fetching pages if the tool supports page_number.

  9. No Hardcoding: Never hardcode data in code. Always load it from files or tool responses, iterating to construct intermediate or final inputs/outputs.

  10. Code Correctness (CRITICAL): Code must be syntactically and semantically correct and executable (ES5-friendly; avoid ?? or ?. if targeting older runtimes).

GLOBALS (when workbench snapshot loaded)

  • FLOWRA_WORKBENCH_SNAPSHOT: full JSON from MULTI_EXECUTE sync, or null if load failed / skipped.

HELPERS (already in sandbox – do not redeclare):

  • run_tool(toolSlug, args) -> [result, error]: Execute a known Flowra app tool (from DISCOVER_TOOLS). Match the tool's input schema. Returns (data, "") on success; ({}, "error_message") on failure. Check error before using result.

  • invoke_llm(query) -> [text, error]: Invoke an LLM for semantic tasks. Pass MAX ~400k characters. Returns (response_text, "") on success; ("", "error_message") on failure.

  • proxy_execute(method, endpoint, toolkit, query_params?, body?, headers?) -> [data, error]: Call a connected toolkit API. endpoint is a path on that toolkit's base URL. Credentials stay on the host. Returns (response_data, "") or (null, "error_message").

  • upload_local_file(filePath) -> [fileUrl, error]: Upload a file from /home/user/files and return a public download URL.

All helpers return [result, error]. Always check error before using result.

Error-first pattern: const [res, err] = await run_tool("SOME_TOOL_SLUG", { key: "value" }); if (err) { return { error: err }; } const data = res.data != null ? res.data : res; // use data

Parallelize (4-min timeout): const CONCURRENCY = 10; const items = [/* ... */]; const results = []; for (let i = 0; i < items.length; i += CONCURRENCY) { const batch = items.slice(i, i + CONCURRENCY); const out = await Promise.all(batch.map(async (item) => { const [r, e] = await run_tool("TOOL_SLUG", item); return e ? { status: "failed", error: e } : { status: "ok", data: r }; })); results.push(...out); } return results;

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionNoALWAYS pass session.id from DISCOVER (never invent; never mint here).
thoughtNoConcise objective and high-level plan (no private chain-of-thought). 1 sentence describing what the cell should achieve and why the sandbox is needed.
codeToExecuteYesJavaScript to run inside the persistent remote JavaScript sandbox. State (imports, variables, files) is preserved across executions. Keep code concise to minimize tool call latency. Avoid unnecessary comments.
workbenchArtifactIdNoPin a specific snapshot from MULTI_EXECUTE (workbenchArtifactId); omit to use the latest for this session.
useWorkbenchSnapshotNoWhen true (default), fetch the latest Flowra workbench JSON for this session (from MULTI_EXECUTE + syncResponseToWorkbench) before your code runs; exposed as FLOWRA_WORKBENCH_SNAPSHOT. Set false to skip.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataNo
errorNoError if any occurred during the execution of the action
messageNo
successfulNoWhether or not the action execution was successful or not

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "properties": {
      +    "data": {
      +      "properties": {
      +        "error": {
      +          "default": "",
      +          "description": "Error message if any"
      +        },
      +        "results": {
      +          "anyOf": [
      +            {
      +              "propertyNames": {}
      +            },
      +            {
      +              "items": {}
      +            },
      +            {},
      +            {},
      +            {},
      +            {}
      +          ],
      +          "description": "The parsed result of the code execution (object, array, or primitive)"
      +        },
      +        "results_file_path": {
      +          "anyOf": [
      +            {},
      +            {}
      +          ],
      +          "description": "Path to file containing full results if output was truncated"
      +        },
      +        "session": {
      +          "anyOf": [
      +            {
      +              "properties": {
      +                "id": {
      +                  "description": "Meta session identifier"
      +                },
      +                "instructions": {
      +                  "description": "Instructions for session reuse"
      +                }
      +              }
      +            },
      +            {}
      +          ],
      +          "description": "Meta session echoed back to reinforce reuse: { id: string, instructions: string }"
      +        },
      +        "stderr": {
      +          "description": "The standard error output from the command"
      +        },
      +        "stderr_file_path": {
      +          "anyOf": [
      +            {},
      +            {}
      +          ],
      +          "description": "Path to file containing full stderr if output was truncated"
      +        },
      +        "stdout": {
      +          "description": "The standard output from the command"
      +        },
      +        "stdout_file_path": {
      +          "anyOf": [
      +            {},
      +            {}
      +          ],
      +          "description": "Path to file containing full stdout if output was truncated"
      +        }
      +      }
      +    },
      +    "error": {
      +      "anyOf": [
      +        {},
      +        {}
      +      ],
      +      "description": "Error if any occurred during the execution of the action"
      +    },
      +    "message": {},
      +    "successful": {
      +      "description": "Whether or not the action execution was successful or not"
      +    }
      +  },
      +  "type": "object"
      +}
  2. First observed

TDQS

Score is being calculated.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources