fs_read
Get file, download file, fetch file contents, view file, cat, ls — read a file or list a directory from the project filesystem. If the path ends with / or matches a directory, returns a directory listing; otherwise returns the file content.
There are two file surfaces: deployed source is read with project_files_list / project_file_read; fs_read, fs_write, and fs_upload use runtime storage via sw.fs. Project source such as src/App.tsx or api/foo.ts is read with project_file_read, not fs_read.
Optional lines returns only a line range from a text file as JSON with { content, lines: [start, end], total_lines } — useful for peeking into large files without downloading them whole.
For a directory listing, recursive: true returns every descendant in one call, with an optional depth cap.
Example:
// Read a whole file:
{ "project_id": "my-saas", "path": "/uploads/users/alice/avatar.png" }
// Read lines 50–75 of a stored text file:
{ "project_id": "my-saas", "path": "/logs/import-run.txt", "lines": "50-75" }
// List a directory (immediate children):
{ "project_id": "my-saas", "path": "/uploads/users/" }
// List a directory tree, two levels deep:
{ "project_id": "my-saas", "path": "/uploads/", "recursive": true, "depth": 2 }Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"project_id": "<project_id>",
"path": "<path>"
},
"name": "fs_read"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Full path with leading slash. A trailing slash (or a directory path) returns a listing. | |
| depth | No | Optional. When recursive, cap how many levels below the directory to include. | |
| lines | No | Optional line range as "START-END" (1-indexed, inclusive). Text files only. | |
| recursive | No | Optional. For a directory listing, include every descendant (not just immediate children). | |
| project_id | Yes | Project ID (UUID), subdomain, or slug — resolved server-side, no UUID lookup needed. 'default' also works when the account has exactly one project; multi-project accounts must name one (the error lists them). |