Skip to main content
Glama

get_full_document

Read-only

Flatten a LaTeX project into one document by recursively expanding input/include directives, with source maps for tracing edits and unresolved include details.

Instructions

Flatten a LaTeX document latexpand-style: starting from rootFilePath, or from the project's root document when it is left out, every \input, \include, \subfile, and \import (also \subimport, \inputfrom, \subinputfrom, \includefrom, \subincludefrom) is replaced by the text of the file it names, recursively, and the rest of the text is kept exactly. Directives inside % comments and verbatim text are skipped. A path resolves relative to the project root first and then to the including file's folder (the other way round for \subimport and its relatives); \input and \subfile try the name as written and then with .tex, \include always means .tex, and \subfile takes in only the named file's document body. \include does not add its page breaks to the text. A directive that cannot be followed stays as written and is listed in unresolved with file, line (1-based), target, and reason: missing (no document at any candidate path), binary_file (the path is an uploaded file, not a text document), macro_argument (the path uses a macro or parameter), or excluded_by_includeonly (an \include an \includeonly list leaves out; includeOnly lists it). Returns rootFilePath, text, files (every file visited, each once, in order), unresolved, includeOnly when a file sets it, and sourceMap: one entry per run of text copied from one file, { flattenedStart, flattenedEnd, filePath, docId, originalStart, originalEnd, revision }, offsets in UTF-16 code units, half-open, into text and into that file's LF-normalized content. revision is the file's revision as read_file returns it: route an edit decided on in the flattened view back with write_file or write_section on that file, with that revision, never by writing the flattened text anywhere. Each file is read separately, so files can change between reads; each revision matches the text it was read with. text joins each file's text to what follows its directive with nothing in between, as written; a comment on a file's last line therefore reads on into the next text if text is compiled as is, though section parsing treats each file separately. An include cycle is INCLUDE_CYCLE with details.chain; nesting deeper than maxDepth is INCLUDE_DEPTH_EXCEEDED (it never cuts the result short); a result longer than 8388608 code units is DOC_TOO_LARGE with details.kind flattened, and includes that take in files more than 10000 times in all, counting a file once per inclusion, are DOC_TOO_LARGE with details.kind includes: start from a file further down, or read the files one at a time.

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": {
      "projectId": "<projectId>"
    },
    "name": "get_full_document"
  }
}

Input Schema

NameRequiredDescriptionDefault
maxDepthNoLevels of includes to follow below the root document, 1 to 32; default 10
projectIdYesOverleaf project ID
rootFilePathNoDocument to start from; defaults to the root document configured in Overleaf

Output Schema

NameRequiredDescriptionDefault
textYes
filesYes
sourceMapYes
unresolvedYes
includeOnlyNo
rootFilePathYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.3.0

TDQS

A4.5/5.0
Behavior5/5

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

Annotations only declare readOnlyHint, so the description carries the real burden and does: cycle detection via INCLUDE_CYCLE, depth limit INCLUDE_DEPTH_EXCEEDED with the note it never truncates, two distinct DOC_TOO_LARGE kinds with concrete thresholds (8388608 code units, 10000 inclusions). It also discloses non-obvious semantics — files read separately and can change mid-run, revisions matching the text they were read with, and the comment-on-last-line concatenation caveat.

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

Conciseness3/5

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

The core intent is front-loaded, but the body is a very long chain of semicolon-linked clauses covering path precedence, extension fallbacks, unresolved reasons, and a full return-shape enumeration. Much of the return-shape detail (sourceMap entry fields, unresolved fields) duplicates the output schema and could be trimmed without losing call-site guidance.

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?

For a tool with substantial hidden complexity — recursive expansion, cycle and size failure modes, a source map back to original offsets, and cross-file revision consistency — the description covers everything an agent needs to call it correctly and to act on its output. The output schema handles structure, and the description still supplies the semantics (UTF-16, half-open, LF-normalized) that make the offsets usable.

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

Parameters4/5

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

Schema coverage is 100%, so baseline is 3, but the description adds real meaning: the rootFilePath default resolves to the project's configured root document, and maxDepth is tied to a specific failure mode rather than just a numeric bound. Path resolution precedence for rootFilePath-relative vs. including-file-relative paths is behavior the schema does not express.

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?

Opens with a specific verb and resource ('Flatten a LaTeX document latexpand-style') and immediately scopes it to the root document and the directive set it expands. An agent can distinguish this from read_file or get_section_content without opening any schema.

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

Usage Guidelines4/5

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

Gives clear operating context: start from rootFilePath or the configured root, and when limits are hit, 'start from a file further down, or read the files one at a time'. It also redirects edits away from the flattened output ('route an edit ... back with write_file or write_section ... never by writing the flattened text anywhere'). It stops short of explicitly contrasting with read_file for the single-file case, so not a 5.

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