spring-ai-playground

description: Default Tools - Filesystem reference. 11 safety.fs-wrapped tools (list-roots · read · list · stat · grep · count · slice · sort · cut · find · write) over readable roots and a writable working directory.

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:

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 { #the-filesystem-tools }

listAllowedDirectories 🆓
:material-folder-key-outline:
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 🆓
:material-file-document-outline:
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 🆓
:material-folder-outline:
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 🆓
:material-information-outline:
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 🆓
:material-counter:
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 🆓
:material-content-cut:
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 🆓
:material-sort:
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 🆓
:material-file-find-outline:
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 🆓
:material-folder-search-outline:
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 🆓
:material-table-column:
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 🆓
:material-file-edit-outline:
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:

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.