script-sandbox

v1.2.2
script-sandbox Checked 1 day ago Published 1 month ago

MCP server (stdio) to run any script (PowerShell, bash, Python, Node, Ruby, Perl, Lua, PHP, R, Java, batch, VBScript) and any executable inside a lightweight…

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

sandbox_info Sandbox info

Sandbox information: the root/scripts/work/logs folders, languages + interpreters available on this device (with versions), limits, per-language guardrails, env allowlist, file count, and the file-log redirect (Spring Boot / Quarkus built in, any other stack via SCRIPT_SANDBOX_LOG_VARS; the files land in logs/<run_id>/ so running a project never drops .log files into its folder).

list_scripts List scripts

Lists every script file in the sandbox scripts/ folder (all supported languages), sorted newest first.

write_script Write script

Creates or overwrites a script file inside the sandbox scripts/ folder. Relative paths only (subfolders allowed). The extension selects the language: .ps1 PowerShell, .sh/.bash bash, .py Python, .js/.mjs/.cjs Node, .rb Ruby, .pl Perl, .lua Lua, .php PHP, .r R, .java Java, .bat/.cmd batch, .vbs VBScript. .sh/.bash is normalized to LF and reported via normalized_crlf. For .java: the public class name must match the file name (the usual Java rule); without the public modifier the file name is free.

ParameterTypeDescription
content *stringScript content (UTF-8) matching its extension language.
name *stringRelative file name with its language extension, e.g. build/deploy.py
overwritebooleanSet true to overwrite an existing file.

read_script Read script

Reads the contents of any script file from the sandbox scripts/ folder.

ParameterTypeDescription
name *stringRelative file name, e.g. build/deploy.py

delete_script Delete script

Deletes a script file from the sandbox scripts/ folder.

ParameterTypeDescription
name *stringRelative file name, e.g. build/deploy.py

run_script Run script

Runs a script file of any language in the sandbox: separate process, per-run working dir, minimal env, timeout, logs, and a result with exit_code/duration/stdout/stderr. The interpreter is chosen from the file extension (see sandbox_info). If the interpreter for that extension is not installed on this device, the run is rejected with code INCOMPATIBLE plus a fix suggestion.

ParameterTypeDescription
script *stringRelative script path, e.g. build/deploy.py or check.ps1
argsarrayExtra arguments (an array so spaces are not split).
envobjectAdditional env vars for this run (max 20).
labelstringFree-form label for run bookkeeping.
timeout_msintegerTimeout in ms (default 120000, max 600000).

run_code Run inline code

Runs a code snippet of any language directly. The code is written to a temporary file in the sandbox (deleted automatically after the run) and executed with the same protections as run_script. For long or multi-file code, use write_script + run_script.

ParameterTypeDescription
code *stringCode to execute.
language *stringCode language: one of the kind/extension — ps1, sh, py, js, rb, pl, lua, php, r, java, bat, vbs. Java note: the file name is generated automatically, so do not give the first class the public modifi…
argsarrayExtra arguments (an array so spaces are not split).
envobjectAdditional env vars for this run (max 20).
labelstring
timeout_msintegerTimeout in ms (default 120000, max 600000).

run_executable Run executable

Runs any executable (CLI tools, compiled binaries) in the same sandbox: per-run cwd, minimal env, timeout, logs. A bare name is looked up on PATH; an absolute path is used as-is. Args are scanned by the guardrails. WARNING: native binaries cannot be contained by this soft sandbox — only run what you trust.

ParameterTypeDescription
executable *stringExecutable name on PATH (e.g. node, git) or an absolute path.
argsarrayExtra arguments (an array so spaces are not split).
envobjectAdditional env vars for this run (max 20).
labelstring
timeout_msintegerTimeout in ms (default 120000, max 600000).

read_log Read run log

Reads the full stdout/stderr log of a run (the output returned by run_script is already truncated).

ParameterTypeDescription
run_id *stringrun_id from a run result, e.g. 20260101-120000-a1b2c3
whichstringDefault: stdout

list_allowed_directories List allowed directories

Lists every directory the filesystem tools may read/write: the sandbox root plus anything in SCRIPT_SANDBOX_FS_ROOTS. Paths outside these are refused.

read_text_file Read text file

Reads a UTF-8 text file inside an allowed directory. Optionally return only the first (head) or last (tail) N lines — head and tail cannot be combined.

ParameterTypeDescription
path *stringAbsolute path inside an allowed directory, or a path relative to the sandbox root.
headintegerFirst N lines of the file.
tailintegerLast N lines of the file.

read_multiple_files Read multiple files

Reads several UTF-8 text files in one call. A failing path does not stop the batch: the failure is reported per file (ok=false + code).

ParameterTypeDescription
paths *arrayFiles to read (max 50).

read_media_file Read media file

Reads an image/audio/video/PDF file and returns it base64-encoded with its MIME type. Size cap: SCRIPT_SANDBOX_FS_MAX_MEDIA_BYTES (default 5 MB).

ParameterTypeDescription
path *stringAbsolute path inside an allowed directory, or a path relative to the sandbox root.

write_file Write file

Creates a file (parents are created automatically) inside an allowed directory. An existing file is only replaced with overwrite=true. Size cap: SCRIPT_SANDBOX_FS_MAX_WRITE_BYTES (default 1 MB).

ParameterTypeDescription
content *stringFile content (UTF-8).
path *stringAbsolute path inside an allowed directory, or a path relative to the sandbox root.
overwritebooleanSet true to replace an existing file.

edit_file Edit file

Makes selective edits with git-style diff output. Each edit replaces a unique oldText with newText (substring match; when only whitespace differs, indentation is carried over line by line). Ambiguous or missing patterns are refused with a clear code. Always dry_run=true first to preview the diff before applying.

ParameterTypeDescription
edits *arrayEdits applied in order (max 50).
path *stringAbsolute path inside an allowed directory, or a path relative to the sandbox root.
dryRunbooleanPreview the diff without writing (default false).

create_directory Create directory

Creates a directory (and its parents) inside an allowed directory.

ParameterTypeDescription
path *stringAbsolute path inside an allowed directory, or a path relative to the sandbox root.

move_file Move file or directory

Moves or renames a file/directory inside the allowed directories. Fails with ALREADY_EXISTS if the destination exists.

ParameterTypeDescription
destination *stringAbsolute path inside an allowed directory, or a path relative to the sandbox root.
source *stringAbsolute path inside an allowed directory, or a path relative to the sandbox root.

list_directory List directory

Lists a directory: every entry with its type (file or directory).

ParameterTypeDescription
path *stringAbsolute path inside an allowed directory, or a path relative to the sandbox root.

list_directory_with_sizes List directory with sizes

Lists a directory with file sizes, modification times and a summary (total files/directories/bytes); entries sorted by name or size.

ParameterTypeDescription
path *stringAbsolute path inside an allowed directory, or a path relative to the sandbox root.
sortBystringDefault: name.

search_files Search files

Recursively searches a directory for files/directories matching a glob pattern (e.g. "*.js", "src/**/*.ts"). A pattern without "/" matches names at any depth. Returns full paths, up to 500 matches.

ParameterTypeDescription
path *stringAbsolute path inside an allowed directory, or a path relative to the sandbox root.
pattern *stringGlob pattern, e.g. "*.py" or "src/**/*.ts".
excludePatternsarrayGlobs to skip, e.g. ["node_modules", "**/*.tmp"].

directory_tree Directory tree

Recursive JSON tree of a directory: name/type per entry, children for directories (empty array when empty). Symlinks are listed but never followed.

ParameterTypeDescription
path *stringAbsolute path inside an allowed directory, or a path relative to the sandbox root.
excludePatternsarrayGlobs to skip, e.g. ["node_modules", "**/*.tmp"].

get_file_info Get file info

File/directory metadata: size, created/modified/accessed times, type, permissions (octal + rwx) and whether it is a symlink.

ParameterTypeDescription
path *stringAbsolute path inside an allowed directory, or a path relative to the sandbox root.