Skip to main content
Glama

Read a project file

read_file
Read-only

Read 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

NameRequiredDescriptionDefault
modeNoReturn 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.
pathYesPath to the file relative to the project root, e.g. sections/intro.tex.
endLineNoLast line to return, inclusive. Cannot be combined with mode or sectionTitle.
projectNoWhich project to use: its Overleaf address, its 24-character id, or a registered project name. Omit to use the default project.
revisionNoRead the file as it was at this commit hash, as read_history prints it. Cannot be combined with mode.
startLineNoFirst line to return, 1-indexed. Cannot be combined with mode or sectionTitle.
sectionTitleNoRead 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.
followIncludesNotrue 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.
previousRevisionNoA 64-character revision hash this server returned for this same file earlier in this session. Requires mode=smart.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed6 schema fields changedv0.5.0
    • changedInput schema / properties / endLine / description
      Previous value: -"Last line to return, inclusive. Cannot be combined with mode."New value: +"Last line to return, inclusive. Cannot be combined with mode or sectionTitle."
    • addedInput schema / properties / followIncludes
      Added value: +{
      +  "description": "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.",
      +  "type": "boolean"
      +}
    • changedInput schema / properties / mode / description
      Previous value: -"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."New value: +"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."
    • changedInput schema / properties / revision / description
      Previous value: -"Read the file as it was at this commit hash from list_history. Cannot be combined with mode."New value: +"Read the file as it was at this commit hash, as read_history prints it. Cannot be combined with mode."
    • addedInput schema / properties / sectionTitle
      Added value: +{
      +  "description": "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.",
      +  "type": "string"
      +}
    • changedInput schema / properties / startLine / description
      Previous value: -"First line to return, 1-indexed. Cannot be combined with mode."New value: +"First line to return, 1-indexed. Cannot be combined with mode or sectionTitle."
  2. Changed1 schema field changedv0.4.0
    • addedInput schema / properties / revision
      Added value: +{
      +  "description": "Read the file as it was at this commit hash from list_history. Cannot be combined with mode.",
      +  "pattern": "^[0-9a-f]{7,40}$",
      +  "type": "string"
      +}
  3. First observedv0.3.8

TDQS

A4.9/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The annotations already mark this as read-only and open-world, but the description adds substantial behavior: it pulls the latest commits before reading, truncates plain text after 60,000 characters, returns revision-aware JSON in mode=full, and can return image content with size and pixel limits. It also discloses how deltas must be applied and enumerates failure modes such as binary files, out-of-project paths, incompatible argument combinations, and invalid line ranges.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The definition is front-loaded with the core read behavior and every major sentence carries substantive information. It is dense and relies on long run-on sentences, so it is less scannable than it could be, but the size is defensible for a tool with nine parameters and many interacting modes.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, so the description carries the full burden of explaining return behavior, and it does: plain text, line numbering, JSON with revision hash, smart deltas, historical plain-text reads, image responses, include expansion, truncation, and failure cases. For this complexity level, an agent has what it needs to choose and invoke the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline would be 3, but the description adds meaningful semantics beyond the schema. It explains case-insensitive sectionTitle matching, exact-match precedence, fallback container matching, how to apply a smart delta, how revision reads differ from normal reads, and what followIncludes inlines and reports.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: reading one file from the project after pulling the latest Overleaf commits. It distinguishes the plain read, revision-aware read, section read, image read, and include-expanded read, giving an agent enough to identify the tool and its boundaries without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives explicit when-to-use guidance: line ranges to sample large files, mode=full before an edit that passes expectedRevision, mode=smart to re-read an already-read file, and revision to read at a historical commit. It also states when not to combine arguments and what failure conditions exist, leaving little to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.