examples.cleanup
Tools: cleanup.old-files. Part of the Java Tool SDK examples.
By ToolGate Examples Signed
Java 17, protocol 2
Use in ToolGate
In the ToolGate console, open Server packages, then Marketplace, and install this package. These values identify exactly what you install:
{
"marketplace": "olo-labs-marketplace",
"packageId": "examples.cleanup",
"version": "0.1.0",
"packageDigest": "sha256:114d958bcded32566229a430ef65ddff02fa75bb83bfd91d62cc660a73ed02ab"
}
Overview
File cleanup
Tools: cleanup.old-files. Part of the Java Tool SDK examples.
Finds files older than a number of days that match a name pattern (such as *.log or export-*.csv) in an approved directory, optionally in sub-directories, and lists them oldest first with their total size. With dryRun false it deletes them.
Safety
- Off until the administrator sets
CleanupRoots; the directory must be one of them or inside one, and..is refused. - A dry run is the default. Deletes need an age of at least
MinAgeDays, whatever the caller asks, and stop afterMaxDeletesPerCallfiles. - Each file is checked again just before it is deleted. Links are not followed and directories are never removed.
- The tool is declared
destructive, so an administrator sees that when approving it, and itsuseWhentells the model to show a dry run first.
Settings
Globals unless marked. Set them in toolgate.dev.json for development, as TOOLGATE_GLOBAL_<NAME> (or TOOLGATE_DESTINATION_<NAME>, TOOLGATE_SECRET_<NAME>) for a standalone jar, or on the deployment under ToolGate.
| Setting | Default | Meaning |
|---|---|---|
CleanupRoots |
none |
Comma-separated directories the tool may clean. none disables it. |
MinAgeDays |
7 |
Youngest age a file may have to be deleted. |
MaxDeletesPerCall |
500 |
Most files one call deletes. |
Try it
cp toolgate.dev.example.json toolgate.dev.json # then edit it; never commit toolgate.dev.json
toolgate dev # an MCP server over stdio
toolgate pack # build/toolgate/file-cleanup-0.1.0.tgpkg
Things to ask a model connected to it:
- "What .log files older than 30 days are in /var/log/myapp?"
- "Delete them."
- Source repository
- License: Apache-2.0
Tools
cleanup.old-filesIdempotent- Clean up old files Finds files older than a number of days, matching a name pattern, in an approved directory. Lists them by default; deletes them only with dryRun false.
Settings it needs
| Name | Kind | Type | Default | Description |
|---|---|---|---|---|
CleanupRoots | global | STRING | none | Comma-separated directories the tool may clean, such as /var/log/app,D:\exports. 'none' disables it. |
MaxDeletesPerCall | global | INT | 500 | Most files one call deletes. |
MinAgeDays | global | INT | 7 | Youngest age, in days, a file may have to be deleted, whatever the caller asks. |
Versions
| Version | API change | Compatibility | Published |
|---|---|---|---|
| 0.1.0 | none | Java 17, protocol 2 | 15 Oct 2026 - 11:55 |
Publisher
ToolGate Examples, OLO Labs
Publisher details are supplied by the publisher. Validation checks package format, not code safety.