Read a project file
read_fileRead project files from Overleaf after pulling commits, including line ranges, sections, included files, images, or revision history, to inspect content before editing.
Instructions
Read one 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. sectionTitle returns one section of a .tex file instead, so the rest of a long paper stays out of context: from its heading to the next heading at the same or a shallower level, stopping before trailing matter such as \appendix, the bibliography or \end{document}. It is compared case-insensitively with the title in braces, not an optional [short] title: an exact match wins, otherwise the first heading in document order that contains it, and if nothing matches the reply lists the titles that exist. 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. With revision, reads the file as it was at that commit from read_history instead, as plain text; line ranges and sectionTitle work, mode does not. followIncludes returns a .tex file with the files it includes inlined, to read a paper split across files in one call. A PNG, JPEG, GIF or WebP file comes back as an image the model can see, after a line giving its format, size in pixels and bytes; it may have at most 3,750,000 bytes and 8000 pixels a side, and takes no other read argument. A figure a text-only checkout keeps off disk is read from Git without changing the checkout. Fails without reading for a missing file, any other binary file (a PDF or EPS figure is refused with the command that renders it to PNG), a path outside the project, a line range or sectionTitle combined with mode, sectionTitle combined with a line range, followIncludes combined with any other read argument or on a file that is not .tex, startLine after endLine, or startLine past the last line.
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": {
"path": "<path>"
},
"name": "read_file"
}
}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 or sectionTitle. | |
| 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 or sectionTitle. | |
| project | No | Which project to use: its Overleaf address, its 24-character id, or a registered project name. Omit to use the default project. | |
| revision | No | Read the file as it was at this commit hash, as read_history prints it. Cannot be combined with mode. | |
| startLine | No | First line to return, 1-indexed. Cannot be combined with mode or sectionTitle. | |
| sectionTitle | No | Read only this section of a .tex file, by its title as it appears inside the sectioning command, e.g. Introduction for \section{Introduction}. read_project (view outline) lists the titles. Cannot be combined with startLine, endLine or mode; revision works. | |
| followIncludes | No | true returns this .tex file with every file it reaches through \input, \include, \subfile or \import inlined in place, between comment lines naming each file, then lists the includes that were not found or not inlined. Combines with no other read argument. | |
| previousRevision | No | A 64-character revision hash this server returned for this same file earlier in this session. Requires mode=smart. |