Trash File
trash_fileMove files or folders to the Trash using Finder by providing the absolute path.
Instructions
Move a file or folder to the Trash using Finder.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path of the file or folder to trash |
Implementation Reference
- src/finder/tools.ts:187-205 (handler)The tool handler for 'trash_file'. It registers the tool with input schema (path), calls resolveAndGuard for path safety, then executes the JXA trash script via trashFileScript.
server.registerTool( "trash_file", { title: "Trash File", description: "Move a file or folder to the Trash using Finder.", inputSchema: { path: zFilePath.describe("Absolute path of the file or folder to trash"), }, annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false }, }, async ({ path }) => { try { resolveAndGuard(path); return ok(await runJxa(trashFileScript(path))); } catch (e) { return errJxaFor("trash file", e); } }, ); - src/finder/tools.ts:188-196 (schema)Input schema and metadata for the trash_file tool: requires 'path' (zFilePath), marked as destructiveHint: true.
"trash_file", { title: "Trash File", description: "Move a file or folder to the Trash using Finder.", inputSchema: { path: zFilePath.describe("Absolute path of the file or folder to trash"), }, annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false }, }, - src/finder/tools.ts:187-205 (registration)The tool is registered via server.registerTool('trash_file', ...) inside the registerFinderTools function.
server.registerTool( "trash_file", { title: "Trash File", description: "Move a file or folder to the Trash using Finder.", inputSchema: { path: zFilePath.describe("Absolute path of the file or folder to trash"), }, annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false }, }, async ({ path }) => { try { resolveAndGuard(path); return ok(await runJxa(trashFileScript(path))); } catch (e) { return errJxaFor("trash file", e); } }, ); - src/finder/scripts.ts:140-150 (helper)The trashFileScript JXA helper function. It uses Finder.delete() to move a file or folder to the Trash and returns JSON with trashed status, name, and path.
export function trashFileScript(path: string): string { assertSafePath(path); return ` const Finder = Application('Finder'); const posixFile = Path('${esc(path)}'); const item = Finder.items[posixFile.toString()]; const name = item.name(); Finder.delete(item); JSON.stringify({trashed: true, name: name, path: '${esc(path)}'}); `; }