Skip to main content
Glama

overleaf-mcp

License

An MCP server that lets Claude (Claude Code and Claude Desktop) read and edit one Overleaf project at a time. Edits are pushed straight to Overleaf and appear in your browser editor within seconds.

It talks to Overleaf through Overleaf's official Git integration, which needs a paid Overleaf plan (or a self-hosted Server Pro). There is no unofficial scraping of the web editor.

How access is limited

Three layers, from loosest to tightest:

  1. Registry. The server can only attach projects you have registered with overleaf-mcp add. Claude cannot register projects through the MCP tools, so it cannot widen its own access.

  2. Attach. A server process holds at most one attached project. Every file path is resolved inside that project's working copy; .., absolute paths and .git are refused. Nothing else is reachable.

  3. Pin. Set OVERLEAF_PROJECT in a server's config and it is locked to that one project: it auto-attaches, and attach_project / detach_project refuse.

Per session: Claude Code starts a separate server process for every session, so each session has its own attachment and its own working copy. Two sessions can work on two different projects (or the same one) at once. Claude Desktop starts one server for all chats, so there an attachment is shared by every chat until changed.

What this does not protect against: the Overleaf Git token is account-wide (Overleaf has no per-project tokens), and it sits in ~/.overleaf-mcp/token. The scoping above is enforced by this server. A Claude Code session that also has unrestricted shell access could read the token file directly. If that matters, deny shell reads of ~/.overleaf-mcp in your Claude Code permissions.

Related MCP server: overleaf-claude-mcp

Setup

1. Install

git clone https://github.com/rutwikg/overleaf-mcp C:\path\to\overleaf-mcp
cd C:\path\to\overleaf-mcp
uv sync

The server executable is C:\path\to\overleaf-mcp\.venv\Scripts\overleaf-mcp.exe. Always give clients this full path; they do not inherit your shell's PATH.

2. Store your Overleaf Git token

In Overleaf: Account Settings > Git integration > Generate token. Then, in a terminal (the token is read with hidden input and saved to ~/.overleaf-mcp/token):

C:\path\to\overleaf-mcp\.venv\Scripts\overleaf-mcp.exe login

3. Register the projects Claude may use

The alias is what you will say to Claude. The URL is the one in your browser when the project is open.

C:\path\to\overleaf-mcp\.venv\Scripts\overleaf-mcp.exe add thesis https://www.overleaf.com/project/0123456789abcdef01234567

add checks that the token can reach the project. Other commands: list, rename OLD NEW, remove ALIAS, check [ALIAS].

4a. Claude Code: attach per session

Register the server once, for all your sessions:

claude mcp add --scope user overleaf -- C:\path\to\overleaf-mcp\.venv\Scripts\overleaf-mcp.exe

Then, in any session, either say "attach my thesis project" or use the slash command the server provides:

/mcp__overleaf__attach thesis

That session can now edit thesis and nothing else. Another session is unaffected until you attach something there.

4b. Claude Code: pin a folder to one project

To make every session started in a folder work on one project only, put a .mcp.json in that folder (see examples/pinned.mcp.json):

{
  "mcpServers": {
    "overleaf": {
      "command": "D:\\Work\\AgenticAI\\OverleafMCP\\.venv\\Scripts\\overleaf-mcp.exe",
      "env": { "OVERLEAF_PROJECT": "thesis" }
    }
  }
}

If you also registered the server at user scope, the project-scope entry of the same name takes precedence in that folder.

4c. Claude Desktop

Add to claude_desktop_config.json (Settings > Developer > Edit Config) and restart Claude Desktop:

{
  "mcpServers": {
    "overleaf": {
      "command": "D:\\Work\\AgenticAI\\OverleafMCP\\.venv\\Scripts\\overleaf-mcp.exe"
    }
  }
}

Then tell Claude "attach thesis" in a chat. Add "env": {"OVERLEAF_PROJECT": "thesis"} to lock Desktop to a single project.

Tools

Tool

What it does

list_projects

Registered aliases and which one is attached

attach_project / detach_project

Bind / unbind this session's project

project_status

Attached project, sync state, push mode

list_files, read_file, search_project

Read the project

outline

Section structure in reading order, following \input / \include

edit_file

Exact find/replace, pushed to Overleaf

apply_edits

Several find/replace edits to one file as one atomic change

write_file

Create a file or replace one wholesale

upload_file

Copy a local file (figure, PDF, .bib) into the project

delete_file, move_file

File management

project_history, show_diff

Overleaf's version history

sync_project, push_changes, discard_unpushed

Manual sync control

How editing works

On attach the server clones the project into ~/.overleaf-mcp/work/<alias>-<pid>-<id>/. Before each operation it pulls if the last pull is more than 15 s old, so edits you make in the browser are seen. Each write is committed and pushed immediately. If you edited the same text in the browser at the same moment, the push is rejected, the server rebases, and if the edits truly collide it drops its own change and reports CONFLICT so Claude re-reads and redoes it. Your browser edits always win.

The working copy is deleted when the session ends. Copies left behind by a crashed process are cleaned up on the next start, unless they hold changes that never reached Overleaf, which are kept for you.

Docker

The server needs only git and network access, so it runs fully in a container. Pass the token by environment and pin the project by id:

docker build -t overleaf-mcp .
docker run --rm -i -e OVERLEAF_GIT_TOKEN=<token> -e OVERLEAF_PROJECT=<project-id> overleaf-mcp

Use docker run --rm -i ... as the command in a client config. To use a registry of several projects instead, mount a folder holding projects.json at /data.

Configuration

Variable

Default

Meaning

OVERLEAF_PROJECT

unset

Pin to this alias, URL or id

OVERLEAF_AUTO_PUSH

1

0 commits locally; push_changes sends them

OVERLEAF_SYNC_INTERVAL

15

Seconds before a pull is considered stale

OVERLEAF_ALLOW_UNREGISTERED

0

1 lets attach_project take any id/URL

OVERLEAF_GIT_HOST

https://git.overleaf.com

For self-hosted Server Pro

OVERLEAF_GIT_TOKEN

unset

Token via env instead of the token file

OVERLEAF_MCP_HOME

~/.overleaf-mcp

Where token, registry and working copies live

OVERLEAF_COMMIT_NAME / _EMAIL

Claude (overleaf-mcp)

Local commit identity

Overleaf's history attributes Git pushes to the token's owner, not to the commit name.

Limitations

  • Needs Overleaf's Git integration (paid plan or Server Pro).

  • Does not compile. Check the PDF in Overleaf.

  • Overleaf's main-file setting is not visible over Git; the server guesses the file containing \documentclass, preferring main.tex.

  • Overleaf's Git bridge can take a few seconds per push on large projects.

Development

uv run pytest
npx @modelcontextprotocol/inspector C:\path\to\overleaf-mcp\.venv\Scripts\overleaf-mcp.exe

Tests run against a fake Overleaf made of bare Git repos over file://; only the transport is faked.

Licence

AGPL-3.0-or-later. See LICENSE.

Available Tools

19 tools
apply_editsA

Apply several find/replace edits to one file as a single Overleaf change.

Inputs: path (required), edits (required), message.

attach_projectA

Attach an Overleaf project to this session. All other tools then act on this project only.

Clones the project locally, which takes a few seconds. Attaching a different project detaches the current one first.

Inputs: project.

delete_fileA
Destructive

Delete a file from the attached project. It stays recoverable from Overleaf's history.

Inputs: path (required), message.

detach_projectA

Detach the current project. Afterwards no project is reachable until attach_project is called again.

Inputs: no named parameters.

discard_unpushedA
Destructive

Throw away local commits that never reached Overleaf and reset to Overleaf's current version.

Inputs: no named parameters.

edit_fileA

Replace exact text in a file of the attached project and push it to Overleaf.

Inputs: path (required), new_text (required), old_text (required), message, +1 more.

list_filesA
Read-only

List files in the attached project (recursively), with sizes.

Inputs: path.

list_projectsA
Read-only

List the Overleaf projects the user has registered for use with Claude, and which one is attached.

Inputs: no named parameters.

move_fileA

Rename or move a file within the attached project. Does not update \input or \includegraphics references.

Inputs: path (required), new_path (required), message.

outlineA
Read-only

Show the document structure: sectioning commands in reading order, following \input and \include.

Inputs: path.

project_historyB
Read-only

Recent versions of the project (as recorded by Overleaf's Git bridge), newest first.

Inputs: path, limit.

project_statusA
Read-only

Show which project is attached, whether it is in sync with Overleaf, and the push mode.

Inputs: no named parameters.

push_changesA

Push local commits that have not reached Overleaf yet (only needed when auto-push is off or a push failed).

Inputs: no named parameters.

read_fileB
Read-only

Read a text file from the attached project.

Inputs: path (required), end_line, start_line, line_numbers.

search_projectA
Read-only

Search the text files of the attached project. Returns matching lines with file and line number.

Inputs: pattern (required), regex, file_glob, ignore_case, +1 more.

show_diffB
Read-only

Show what one version of the project changed.

Inputs: commit (required), path.

sync_projectA
Read-only

Pull the latest changes made in Overleaf (by the user or collaborators) right now.

Inputs: no named parameters.

upload_fileA

Copy a file from this computer (figures, data, .bib) into the attached project and push it.

Inputs: path (required), local_path (required), message.

write_fileA
Destructive

Create a new text file, or replace a file's entire content, and push it to Overleaf.

Prefer edit_file for changes to existing files: it cannot accidentally drop text.

Inputs: path (required), content (required), message.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 19 tools

    Disambiguation4/5

    Most tools have crisp, non-overlapping purposes (attach/detach/status, sync/push/discard, read/search/outline), and descriptions explicitly steer between the closest pairs. The only real friction is the edit_file / apply_edits / write_file / upload_file cluster, where an agent must read descriptions carefully to pick correctly; project_status vs list_projects also lightly overlap.

    Naming Consistency4/5

    Nearly everything is consistent snake_case verb_noun (attach_project, read_file, push_changes, show_diff). A few tools invert to noun-first or bare nouns (outline, project_status, project_history), which is a minor deviation but still readable and predictable.

    Tool Count4/5

    19 tools is at the upper end of comfortable, and a few could be merged (e.g. status into list_projects, discard_unpushed as a mode flag). Still, each tool maps to a concrete action in the attach-edit-sync-history workflow, so the surface feels earned rather than padded.

    Completeness4/5

    Strong coverage of the core lifecycle: project attachment, file CRUD plus move/upload, search/outline, edit/apply_edits with push, plus sync, history and diff. Gaps exist around LaTeX-specific needs such as compiling/viewing the PDF or build log, and Overleaf collaboration features like comments and creating new projects, but agents can largely work around them.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers