Skip to main content

Methods

delete()

Deletes a file or directory at the specified path on the session’s file mount. Removes the file or directory from the virtual filesystem. Use with caution: deletion is typically irreversible. Ensure the path exists and is intended for removal.
Parameters Returns Promise<FileDeleteResponse> — Confirmation of deletion (implementation-specific). Example

download()

Downloads a file from the session’s file mount to the local filesystem. Retrieves a file stored in the session’s virtual filesystem (e.g., one produced by a tool or previously uploaded) and saves it to the specified local path.
Parameters Returns Promise<RemoteFile> — The downloaded file data or path (implementation-specific). Example

list()

Lists files and directories at the specified path on the session’s file mount. Use this to browse the virtual filesystem attached to the tool router session. The path is relative to the mount root (e.g., "/" for root, "/documents" for a subdirectory). Supports cursor-based pagination via cursor and limit options.
Parameters Returns Promise<FileListResponse> — List of files with nextCursor for pagination. Example

upload()

Uploads a file to the session’s file mount. Accepts a file path (local or URL), a native File object, or a raw buffer. The file is stored in the virtual filesystem associated with the tool router session. URL inputs require a Node.js or Bun runtime so the destination can be DNS-validated; edge runtimes must fetch the file themselves and pass a File or ArrayBuffer.
Parameters Returns Promise<RemoteFile> — Metadata about the uploaded file. Example