Skip to content

Default Tools - Filesystem

The 11 tools in default-tool-specs-builtin-fs.json are the safety.fs surface as ready-to-call tools - a small shell-style filesystem pipeline covering list-roots, read, list, stat, grep, count, slice, sort, cut, find, and write. They operate within two boundaries:

  • Readable roots - directories the tools may read from, recursively. The user's home directory is a readable root by default.
  • A working directory (TOOL_STUDIO_FS_BASE, default ${user.home}/spring-ai-playground/workspace) - the only writable location, and where relative paths resolve. When a tool runs inside a chat, writes are confined to a per-conversation subdirectory of it (<workspace>/<conversationId>/), created on first write and removed when you delete the conversation; listAllowedDirectories reports that exact path at runtime.

So a relative path resolves under the working directory; an absolute path may be read anywhere under a readable root, but writes are confined to the working directory. Call listAllowedDirectories first to learn the exact absolute paths before reading or writing.

Because they ride on java.nio.file.Path / Files, separator handling (/ vs \), case folding, and symlink semantics are normalised at the JVM layer - these tools behave identically on macOS, Windows, and Linux. See Tool Studio: Cross-platform by design for the mechanics, and Tool Studio: Filesystem mode for the read-only / read-write sandbox split.

The 11 filesystem tools

listAllowedDirectories 🆓

file · pipeline L3

Reports the filesystem boundaries these tools operate within: the readable roots (anything under them can be read) and the working directory (the only writable location; a per-conversation subdirectory when run from a chat). Call this first. Uses safety.fs.readRoots() / workspace().

Params   -

Env       -

Click for full reference · params · sandbox · JS source
readTextFile 🆓

file · pipeline L3

Reads a UTF-8 text file from disk and returns its contents as a single string.

Params   path

Env       -

Click for full reference · params · sandbox · JS source
listDir 🆓

file · pipeline L3

Lists the immediate entries (files and subdirectories) of a directory. Entries in the working directory come back as relative names; entries elsewhere under a readable root come back as absolute paths. Uses safety.fs.list().

Params   dir

Env       -

Click for full reference · params · sandbox · JS source
statFile 🆓

file · pipeline L3

Returns size, last-modified timestamp, and a directory flag for a path (relative under the working directory, or absolute under a readable root). Uses safety.fs.stat().

Params   path

Env       -

Click for full reference · params · sandbox · JS source
lineCount 🆓

file · pipeline L3

Counts the lines in a UTF-8 text file. Uses safety.fs.lineCount().

Params   path

Env       -

Click for full reference · params · sandbox · JS source
sliceFile 🆓

file · pipeline L3

Returns a slice of lines from a UTF-8 text file (head / tail / range). start is 0-based inclusive, end is 0-based exclusive (Python-style slice). Negative values count from the end of the file. Uses safety.fs.slice().

Params   path · start · end

Env       -

Click for full reference · params · sandbox · JS source
sortFile 🆓

file · pipeline L3

Sorts the lines of a UTF-8 text file and returns the sorted lines as an array. Options: reverse / numeric / caseInsensitive / unique. Uses safety.fs.sort().

Params   path · reverse · numeric · caseInsensitive · unique

Env       -

Click for full reference · params · sandbox · JS source
grepFile 🆓

file · pipeline L3

Searches a UTF-8 text file for lines matching a JavaScript regex. Returns an array of matching lines (optionally numbered). Uses safety.fs.grep().

Params   pattern · path · caseInsensitive · numbered · limit

Env       -

Click for full reference · params · sandbox · JS source
findFiles 🆓

file · pipeline L3

Recursively finds files matching a glob inside a directory. Glob supports * and ?. Optional max recursion depth and type filter ('file' or 'dir'). Uses safety.fs.find().

Params   dir · glob · maxDepth · type

Env       -

Click for full reference · params · sandbox · JS source
cutFileFields 🆓

file · pipeline L3

Extracts selected fields from each line of a delimited file (CSV/TSV/etc.). Uses safety.fs.cut(). 1-based field numbers, comma-separated alternatives via the array.

Params   path · fields · delimiter · regex

Env       -

Click for full reference · params · sandbox · JS source
writeTextFile 🆓

file · pipeline L4

Writes a UTF-8 text file inside the working directory (creating parent directories as needed). Overwrites any existing file. Requires fileWrite permission on the sandbox.

Params   path · content

Env       -

Click for full reference · params · sandbox · JS source

Composition patterns (shell-style filesystem chains)

These eleven tools mirror the standard Unix-shell pipeline shape, but every step is a JSON-returning function so the agent can reason between calls:

  • Read → filter → trim → save - listDir(dir)grepFile(pattern, path)sliceFile(path, start, end)writeTextFile(outPath, content). The canonical "summarise recent errors from a log directory" flow.
  • Find → cut → ETL - findFiles(dir, glob='*.csv') → loop with cutFileFields(path, fields=[1,3]) to project a directory of CSVs into one structured dataset.
  • Sort dedupe → count - sortFile(path, numeric=true, unique=true)lineCount(path) to deduplicate a numeric stream in place and report the resulting size.
  • Stat-first guard - statFile(path) → branch on size / lastModified → only run the rest of the pipeline if the file changed since the last run.

Tutorial 8: Default Tool Recipes walks the Read → filter → trim → save chain end-to-end as summariseRecentLogs.

Keys & secrets

One configuration value, no real secrets.

Variable What it does Default Where to set
TOOL_STUDIO_FS_BASE The safety.fs working directory - the only writable location, and where relative paths resolve. Reads also reach the readable roots (the home directory by default). ${user.home}/spring-ai-playground/workspace Launcher Environment Variables card, or export TOOL_STUDIO_FS_BASE=/path before launch

The File Toolkit preset opts every read tool into fileRead automatically; writeTextFile requires fileWrite (L4) which you enable per-tool in the Sandbox & Capabilities pane - see Tool Studio: Filesystem mode.

Tool Studio: Filesystem mode - fileRead / fileWrite semantics and base-path enforcement.