Using it¶
Through an assistant, you do not call tools yourself. You describe what you want, and the assistant chooses tools and sequences them. This page shows what to ask for and what happens underneath, so you can predict and check the assistant's behaviour. From a shell or a program you can call the same operations directly, with the command line or the TypeScript SDK.
Example prompts¶
Projects
- "Create a new Overleaf project called Grant renewal and make
proposal.texits root document." - "Start a project from the zip in
~/papers/manuscript.zip." - "Clone the Lab template project as Smith 2026."
- "Trash the Old draft project." The assistant will confirm the project name with you first.
Finding things
- "List my ten most recently updated Overleaf projects."
- "Find the projects with Thesis in the name, including archived ones."
- "Which projects are tagged Grant 2026? Tag the two new ones too."
- "Show me the file tree of the Thesis project. Which file is the root document?"
- "Read the abstract from
main.tex."
Editing
- "Fix the typos in the introduction of
main.tex." - "Replace the Methods section with the text in
~/drafts/methods.tex, as a tracked change." - "Create
sections/limitations.texwith a short limitations paragraph."
Files and figures
- "Upload
figures/fig3.pdfinto the project'sfiguresfolder." - "Upload
fig1.pdf,fig2.pdf, andrefs.bibfrom~/draftstofigures/andbib/, but leave anything that is already there." One call, skipping existing files. - "Which figures in
./figuresdiffer from the ones in the project? Upload only those." - "Download
references.bibto my desktop." - "Download the whole project as a zip to
~/backups/thesis.zip." - "Delete
old_draft.tex." The assistant will confirm the path with you first. - "Delete the twenty
old-*.pngfigures." One call, with the count confirmed.
Syncing a folder
- "Compare
~/papers/thesiswith the project. What would change?" - "Upload everything that changed in
~/papers/thesis, as tracked changes." - "Make the project's
figuresfolder match./figures, deleting what I removed locally." The assistant will show you what would be deleted and confirm the count first, and can save the project as a zip beforehand.
Compiling
- "Compile the paper." Builds the root document configured in Overleaf.
- "Compile with
report.texas the root instead."
Review
- "List the open comments and summarize them."
- "Reply to the comment about Figure 2 saying the caption is fixed."
- "Add a comment on the sentence starting 'We assume independence' asking for a citation."
- "List the tracked changes in
main.tex, show me each one, and accept the ones I approve." The assistant will confirm which changes, and how many, before deciding them. - "Reject the suggested deletions in the abstract."
History
- "What changed in the project since yesterday, and who changed it?"
What happens underneath¶
From nothing to a compiled PDF¶
Everything below happens through MCP tools, or the same operations as commands and SDK methods; no step needs the web UI.
create_projectwith a name returnsprojectId,url, androotDocPath: "main.tex", the stub Overleaf puts in every blank project.import_project_zipdoes the same from a local archive, andclone_projectcopies an existing project.create_fileorupload_fileadds the real manuscript, for examplepaper.tex, and any figures and bibliography files.update_project_settingswithrootFilePath: "paper.tex"makes it the root document, so bothcompile_projectand the web editor's Recompile build it. The same call can set thecompilerand TeX LiveimageName.compile_projectwith norootFilePathbuilds the configured root.- When the project is no longer needed,
manage_projectwithaction: "trash"andconfirmNameequal to the project's name moves it to the trash, where it can be restored. Permanent deletion is a separatedeleteaction that only works on an already-trashed project.
Browsing and organizing¶
list_projectsreturns projects newest first with their ids, hiding archived and trashed projects unless asked.querynarrows by name andlimitcaps the page.get_project_treereturns every file and folder with its path, plusrootDocPath,compiler,imageName, andspellCheckLanguagefor the project.create_filecreates a text document;manage_entitycreates folders and renames, moves, or deletes entities;upload_filesends a local file andbatch_uploada list of them, each to its own path, creating missing folders;download_filesaves one file locally anddownload_project_zipthe whole project as one archive.
Making a safe edit¶
read_filereturns the LF-normalized content and an opaquerevision.- The assistant edits the content.
write_filesends the complete replacement with the unchangedrevisionand awriteMode.
{
"projectId": "0123456789abcdef01234567",
"filePath": "main.tex",
"revision": "opaque-revision-from-read-file",
"content": "\\section{Introduction}\nRevised text.\n",
"writeMode": "tracked"
}
If the document changed in the meantime, the result is REVISION_CONFLICT and the assistant must
read again and reconcile. It never reuses a stale revision. write_section and create_file
follow the same pattern, and a write that changes nothing returns successfully without creating a
tracked record.
For a large replacement that already exists on disk, write_file accepts localPath instead of
content. That keeps the revision check and optional tracked changes while avoiding the client's
tool-argument budget. See choosing between write_file and upload_file.
Working by section¶
get_sections parses the headings of one file and returns section ids; get_section_content
reads one body; write_section replaces one body with the same revision check as write_file.
By default, section parsing never follows \input or \include.
For a manuscript split across files, pass followIncludes: true to all three, with filePath set
to the root document. The headings of every included file are then listed in reading order, each
with the file that holds it and that file's revision, and a write goes to that one file only. A
section that runs across a file boundary is listed with spansFiles: true and can be read but not
written; edit its files with write_file. To read the whole manuscript at once, call
get_full_document: it returns the flattened text, a source map from each run of it back to its
file and revision, and the include directives it could not follow.
Syncing a local folder¶
Two calls replace a hand-rolled comparison and one call per file.
plan_syncwithlocalFolderPath(anddestinationFolderPathwhen the folder corresponds to a project subfolder, for examplefigures) compares both sides and changes nothing. Binaries compare by the git blob hash already in the tree; text documents are read and compared by content. The plan liststoUpload, how many files areidentical, what exists only in the project (remoteOnly),conflicts, and what the ignore rules skipped.- The assistant shows you the plan, in particular
remoteOnly, which is what mirror mode deletes. Before a mirror sync it can take a backup withdownload_project_zip, which saves the whole project to a local zip and never replaces an existing file unless asked. Overleaf allows about 10 downloads per project a minute. sync_directorywith the plan'splanTokenapplies it.mode: "additive"only uploads and writes;mode: "mirror"also deletes, and needsconfirmDeleteCountequal to the number ofremoteOnlyentries you agreed to.
{
"projectId": "0123456789abcdef01234567",
"localFolderPath": "/Users/me/papers/thesis",
"mode": "mirror",
"planToken": "opaque-token-from-plan-sync",
"confirmDeleteCount": 20
}
If anything changed on either side since the plan, the result is REMOTE_DRIFT and nothing
happens; the assistant plans again. Changed documents are written with the same revision check
as write_file, so a collaborator's edit made during the sync fails that one file with
REVISION_CONFLICT instead of being overwritten. If some files fail, the result is
status: "partial" with completed, failed, and remaining; nothing was deleted, and calling
sync_directory again with the returned planToken finishes the job without repeating what
already succeeded.
To remove several entities without a sync, delete_entities takes a list of paths and
confirmCount equal to its length.
To upload a list of files to paths you choose, without comparing folders, batch_upload takes
{ localPath, destinationPath } pairs, where destinationPath includes the file name. It checks
every entry before sending anything and creates missing folders. onConflict says what to do
when a path is taken: "fail", the default, refuses the whole call before anything is uploaded,
"overwrite" replaces a binary file at a path, and "skip" leaves existing files alone. Replacing a text document this way has no revision check and also needs
uncheckedDocumentReplace: true, so for documents a collaborator may be editing, a sync or
write_file is the safer route. upload_file follows the same rules for one file, with
overwrite: true, or expectedHash from get_project_tree, for a binary. A file that fails does not undo the ones before it; the
result lists completed, skipped, failed, and remaining. Overleaf allows about 500 uploads
per project in 15 minutes, and the call stops at the first RATE_LIMITED rather than send the
rest.
The hash in get_project_tree is still there for a quick manual check of one binary: it equals
git hash-object <file>. Text documents have no hash; compare those with read_file.
Compiling¶
compile_project with no rootFilePath builds the root document configured in the project,
which is what the web editor's Recompile button builds. Passing rootFilePath overrides the root
for that call only. The result's summary says whether the paper built cleanly and lists the
first errors and warnings by file and line, with undefined references and citations and missing
files. Overleaf reports status: "success" whenever a PDF came out, even when LaTeX hit errors,
so summary.builtCleanly is the answer to "did it build?".
{
"status": "success",
"buildRef": "opaque-token-naming-this-build",
"summary": {
"builtCleanly": false,
"errorCount": 1,
"errors": [{ "file": "main.tex", "line": 5, "message": "Undefined control sequence." }],
"undefinedCitations": ["knuth84"],
"pageCount": 12
}
}
For more context, get_compile_log returns the end of the LaTeX log, or only its error lines,
without compiling again, and download_compile_output saves the PDF, or any other output such as
output.synctex.gz, to a local path. Both take the buildRef and default to the latest build in
this process. Each command line call is a new process with no latest build, so there
compile log and compile download require --build-ref, call get_compile_log without a
buildRef fails with NO_BUILD, and compile run --download compiles and saves the PDF in one
process. stopOnFirstError gives a short log with the one error that matters, and
draft skips images for faster text-only builds. stop_compile stops a running build. Compiles
use your account's compile allowance, so the assistant should read the summary rather than
compile in a loop.
Reviewing comments¶
list_commentsreturns open threads by default, with file, status, and author filters.reply_to_commentadds to an existing thread.add_commentanchors a new thread to exact text: it needs a fresh revision, 1-based line and UTF-16 column positions, andexpectedTextequal to the selected text.set_comment_statusresolves or reopens a thread using the latest revision.
Reviewing tracked changes¶
list_tracked_changeswithfilePathlists a document's tracked changes: each with itschangeId,type(insertordelete), position, an excerpt, itsauthorId, and its timestamp, plus the document'srevision. A replacement is an insert and a delete linked bypairedChangeId. WithoutfilePathit lists the documents Overleaf's range index says have changes;authorIdandtypefilter the list.- The assistant shows you the changes and asks which to accept or reject.
manage_tracked_changeswithactionacceptorreject, thatfilePathandrevision, the chosenchangeIds, andconfirmCountequal to their number decides them in one call. Accepting an insert keeps its text and accepting a delete removes it; rejecting does the opposite. Nothing is sent if the count is wrong, the document changed, an id is no longer a tracked change, or a change left out overlaps a chosen one.- List again before the next decision: ids merge and split as the document changes.
Accepting and rejecting needs owner or edit access to the project; a review-only collaborator can
suggest changes with writeMode: "tracked" but not decide them here.
Review comments and tracked changes require an Overleaf plan and deployment that support them.
Following history¶
Call monitor_project_history without a cursor to establish the current window, then pass the
returned nextSinceVersion on later polls. Only update groups newer than the cursor come back.
If gapDetected is true, the cursor predates the single window returned; the tool does not page
backward or compute diffs.
Before a large edit, label the current version with manage_history and action: "create_label".
read_file_version reads a document as it was at that label, or at any version the history lists,
and manage_history with action: "restore_file" puts one document back, with confirmPath
repeating its path. A restore replaces the document with a new one, so read it again before the
next write. 1.4.0
Checking references and the build¶
check_references lists undefined and unused labels, references, and citations from the source,
without compiling. After a compile, inspect_build maps a source line to its place in the PDF, or
a place in the PDF back to its line, through the compile's buildRef, and counts words.
1.4.0
From a shell¶
The same workflows run as commands, each printing one JSON result: files read, then
files write with the revision it returned; sync plan, then sync apply with the plan's
planToken; compile run, then compile log with its buildRef. The
command line guide shows each one, and its exit codes say whether to read
again, plan again, or wait.