Read a project file
read_fileFetch a single Overleaf project text file after syncing latest commits; use line ranges to sample or revision modes to support guarded edits and deltas.
Instructions
Read one text file from the project after pulling the latest commits from Overleaf. Plain calls return the text, line-numbered when startLine or endLine is given; startLine alone reads to the end, and endLine is clamped to the file. mode=full returns JSON with the content and a revision hash for a guarded edit; mode=smart with previousRevision returns kind unchanged, a delta, or full content when this server process does not know that revision or a delta would be no smaller. Use a line range to sample a large file, mode=full before an edit that passes expectedRevision, and mode=smart to re-read a file already read. Apply a delta only to its exact baseline: split on newline, replace deleteLineCount lines at the 1-based startLine with change.lines, and join on newline. Plain text is cut off after 60,000 characters; in a revision mode, a file too large to return whole comes back truncated with no revision. Fails without reading for a missing or binary file, a path outside the project, a line range combined with mode, or startLine after endLine.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | Return revision-aware JSON instead of plain text: "full" for whole content plus a revision, "smart" for a delta against previousRevision. Cannot be combined with startLine/endLine. | |
| path | Yes | Path to the file relative to the project root, e.g. sections/intro.tex. | |
| endLine | No | Last line to return, inclusive. Cannot be combined with mode. | |
| project | No | Which project to use: its Overleaf address, its 24-character id, or a registered project name. Omit to use the default project. | |
| startLine | No | First line to return, 1-indexed. Cannot be combined with mode. | |
| previousRevision | No | A 64-character revision hash this server returned for this same file earlier in this session. Requires mode=smart. |