Skip to main content

The most comprehensive MCP server for Overleaf โ€” full CRUD, compile, PDF download, git history, diff, and more. (The `overleaf-mcp` name on PyPI is taken by a smaller read-only project, hence the `-plus` suffix; the CLI command is still `overleaf-mcp`.)

Project description

๐Ÿƒ Overleaf MCP Server

The most comprehensive Model Context Protocol (MCP) server for Overleaf.

18 tools covering full CRUD, LaTeX structure analysis, git history & diff, PDF compilation, and download โ€” all from your AI assistant.

Simple setup โ€” set two environment variables (OVERLEAF_SESSION, optional OVERLEAF_GIT_TOKEN) when registering the MCP server, and you're done.

You: "List my projects"
AI:  [list_projects] You have 5 projects. Which one?

You: "Read main.tex from my thesis"
AI:  [read_file] Here's the content: โ€ฆ

You: "Rewrite the abstract to be more concise"
AI:  [edit_file] โœ“ Edited and pushed

You: "Compile and download the PDF"
AI:  [compile_project + download_pdf] PDF saved to ~/Desktop/thesis.pdf โœ“

Note: earlier versions shipped an overleaf_setup / overleaf_save_credentials wizard. These tools have been removed โ€” credentials are now read straight from environment variables.


๐Ÿ†š Comparison with Other Overleaf MCP Servers

Capability This Project tamirsida GhoshSrinjoy anu2711 Junfei-Z mjyoo2
Language Python Python JS Python JS JS
Auth Git + Cookie Git Git Cookie Git Git
list_projects โœ… โœ… โœ… โœ… โœ… โœ…
list_files โœ… โœ… โœ… โœ… โœ… โœ…
read_file โœ… โœ… โœ… โœ… โœ… โœ…
get_sections โœ… โœ… โœ… โŒ โœ… โœ…
get_section_content โœ… โœ… โœ… โŒ โœ… โœ…
create_file โœ… โœ… โŒ โœ… โŒ โŒ
create_project โœ… โœ… โŒ โŒ โŒ โŒ
edit_file (surgical) โœ… โœ… โœ…* โœ… โœ…* โŒ
rewrite_file โœ… โœ… โœ… โœ… โœ… โŒ
update_section โœ… โœ… โŒ โŒ โŒ โŒ
delete_file โœ… โœ… โŒ โŒ โŒ โŒ
list_history โœ… โŒ โœ… โŒ โŒ โŒ
get_diff โœ… โŒ โœ… โŒ โŒ โŒ
compile_project โœ… โŒ โŒ โœ… โŒ โŒ
download_pdf โœ… โŒ โŒ โœ… โŒ โŒ
download_log โœ… โŒ โŒ โŒ โŒ โŒ
sync_project โœ… โœ… โŒ โŒ โŒ โŒ
status_summary โœ… โŒ โœ… โŒ โœ… โœ…
Multi-project โœ… โœ… โœ… โœ… โœ… โœ…
Thread-safe locking โœ… โŒ โœ… (Redis) โŒ โŒ โŒ
Docker support โœ… โŒ โœ… โŒ โŒ โŒ
Free Overleaf tier โœ…โ€  โŒ โŒ โœ… โŒ โŒ
Total tools 18 12 9 6 8 6

* Full file rewrite only, not surgical oldโ†’new replacement. โ€  Compile/download tools work on the free tier via session cookie; Git-based tools require Git integration.


โœจ Key Advantages

  • 18 tools โ€” the most of any Overleaf MCP server
  • Zero config โ€” just two env vars, no config files, no per-project setup
  • Dual auth โ€” Git tokens for read/write + session cookies for compile/download
  • Surgical edits โ€” edit_file does exact search-and-replace (like sed), not full rewrites
  • LaTeX-aware โ€” section hierarchy parsing with indented previews
  • Git history & diff โ€” review changes, compare versions, filter by file/date
  • Compilation โ€” trigger builds and download PDFs without leaving your AI chat
  • Compilation logs โ€” download_log for debugging LaTeX errors
  • Thread-safe โ€” per-project locks prevent concurrent git corruption
  • Clean Python โ€” modular architecture, type hints, async throughout

๐Ÿ“ฆ Installation

Option 1: pip (recommended)

# Core (git-based tools only)
pip install overleaf-mcp

# With compile/download support
pip install overleaf-mcp[compile]

Option 2: From source

git clone https://github.com/rangehow/overleaf-mcp.git
cd overleaf-mcp
pip install -e .

# Or with uv
uv venv && uv pip install -e .

Option 3: Docker

git clone https://github.com/rangehow/overleaf-mcp.git
cd overleaf-mcp
docker compose build

๐Ÿ”ง Setup

Configure credentials via environment variables. There are two credentials for two different sets of features โ€” you can supply either or both.

Step 1 โ€” Get the session cookie (required)

The overleaf_session2 cookie is HttpOnly, so it can only be read from the browser's DevTools panel (not from JavaScript / the console).

  1. Log into https://www.overleaf.com.
  2. Press F12 โ†’ Application tab (Firefox: Storage; Safari: Storage).
  3. Expand Cookies โ†’ https://www.overleaf.com.
  4. Copy the Value of the row named overleaf_session2. It starts with s%3Aโ€ฆ.

Step 2 โ€” Get the git token (optional, for edit tools)

  1. Open https://www.overleaf.com/user/settings.
  2. Scroll to Git Integration โ†’ Create Token.
  3. Copy the token (it starts with olp_; shown only once).

Step 3 โ€” Pass them to the server

Point your MCP client at overleaf-mcp and provide the env vars. In Claude Desktop / Claude Code (claude_desktop_config.json or .mcp.json):

{
  "mcpServers": {
    "overleaf": {
      "command": "overleaf-mcp",
      "env": {
        "OVERLEAF_SESSION": "s%3A...",
        "OVERLEAF_GIT_TOKEN": "olp_..."
      }
    }
  }
}

In chatui's MCP catalog the Overleaf card prompts for these two fields at install time โ€” no shell setup needed.

Two credentials, different purposes

Credential What you can do When you need it
Session cookie (overleaf_session2) list_projects, compile, download PDF, download log, create project Works on the free tier. Expires ~30 days โ€” refresh when tools start failing with auth errors.
Git token (olp_...) Read/write/edit files, commit history, diffs Optional. Only if you want to edit files. Requires a paid plan.

You can start with just the cookie and add the git token later.

All Environment Variables

Variable Description
OVERLEAF_SESSION Session cookie. Required for list_projects / compile / pdf / create_project.
OVERLEAF_GIT_TOKEN Git token. Required for read / edit / history / diff tools.
OVERLEAF_BASE_URL Overleaf URL (default: https://www.overleaf.com)
OVERLEAF_GIT_HOST Git host (default: git.overleaf.com)
OVERLEAF_TEMP_DIR Local git cache (default: ./overleaf_cache)
OVERLEAF_GIT_AUTHOR_NAME Git author name (default: Overleaf MCP)
OVERLEAF_GIT_AUTHOR_EMAIL Git author email (default: mcp@overleaf.local)
HISTORY_LIMIT_DEFAULT Default commit limit (default: 20)
HISTORY_LIMIT_MAX Max commit limit (default: 200)
DIFF_CONTEXT_LINES Diff context lines (default: 3)
DIFF_MAX_OUTPUT_CHARS Max diff size (default: 120000)

๐Ÿ”Œ Client Setup

Docker

{
  "mcpServers": {
    "overleaf": {
      "command": "docker",
      "args": ["compose", "run", "--rm", "-T", "mcp"],
      "cwd": "/path/to/overleaf-mcp",
      "env": {
        "OVERLEAF_SESSION": "s%3A...",
        "OVERLEAF_GIT_TOKEN": "olp_..."
      }
    }
  }
}

(For Claude Desktop / Claude Code see the setup section above.)


๐Ÿ› ๏ธ Tools Reference

Create

Tool Description
create_file Create a new file (auto-creates folders), commit & push
create_project Create a new blank Overleaf project (requires session cookie)

Read

Tool Description
list_projects List all projects in your Overleaf account
list_files List files, optionally filtered by extension
read_file Read file contents
get_sections Parse LaTeX section hierarchy with previews
get_section_content Get full content of a section by title
list_history Git commit history (with date/file/limit filters)
get_diff Git diff between refs or working tree
status_summary Project overview: file count, structure, status

Update

Tool Description
edit_file Surgical search-and-replace (must match exactly once)
rewrite_file Replace entire file contents
update_section Update a LaTeX section body by title
sync_project Pull latest changes from Overleaf

Delete

Tool Description
delete_file Delete a file, commit & push

Compile & PDF

Tool Description
compile_project Trigger PDF compilation on Overleaf
download_pdf Download compiled PDF to local path
download_log Download compilation log for debugging

๐Ÿ’ก Usage Examples

"List my projects"
"List all files in project 64a1b2c3d4e5f6a7b8c9d0e1"
"Read main.tex"
"Show me the sections in chapter1.tex"
"Get the content of the Introduction section"

"Fix the typo: change 'teh' to 'the' in main.tex"
"Rewrite the abstract with: [new text]"
"Update the Methods section with: [new content]"
"Create a new file references.bib with: [content]"
"Delete the old appendix.tex file"

"Show me the last 5 commits"
"What changed in main.tex since last week?"
"Show the diff between HEAD~3 and HEAD"

"Compile my thesis and tell me if it succeeded"
"Download the PDF to ~/Desktop/thesis.pdf"
"Show me the compilation log โ€” I have an error"

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  MCP (stdio)  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  AI Assistant    โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚  overleaf-mcp server     โ”‚
โ”‚  (Claude, etc.)  โ”‚               โ”‚                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜               โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
                                   โ”‚  โ”‚ Git Client         โ”‚  โ”‚โ”€โ”€ Git HTTPS โ”€โ”€โ–บ git.overleaf.com
                                   โ”‚  โ”‚ (clone/pull/push)  โ”‚  โ”‚
                                   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
                                   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
                                   โ”‚  โ”‚ LaTeX Parser       โ”‚  โ”‚
                                   โ”‚  โ”‚ (sections/struct)  โ”‚  โ”‚
                                   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
                                   โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
                                   โ”‚  โ”‚ Compile Module     โ”‚  โ”‚โ”€โ”€ HTTPS โ”€โ”€โ–บ www.overleaf.com
                                   โ”‚  โ”‚ (PDF/log download) โ”‚  โ”‚
                                   โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
                                   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Modules:

  • credentials.py โ€” Read session cookie + git token from environment variables
  • config.py โ€” Project config + Overleaf endpoints
  • git_client.py โ€” Git operations (clone, pull, push, diff, history)
  • latex.py โ€” LaTeX document structure parsing
  • compile.py โ€” PDF compilation and download (uses session cookie)
  • server.py โ€” MCP server with 18 tool definitions

๐Ÿชช Local-copy metadata sidecar

Whenever download_source extracts a project to a local directory, or ensure_repo clones one into the git cache, the server drops a small .overleaf-project.json file at the root of that copy:

{
  "project_id": "69e46cd469c0fc49d2627320",
  "name": "[้˜ฟๅธƒ] ๆฏ•ไธš่ฎบๆ–‡้ญ”ๆ”น็‰ˆ",
  "overleaf_url": "https://www.overleaf.com/project/69e46cd469c0fc49d2627320",
  "source": "zip",
  "downloaded_at": "2026-04-22T10:54:55+00:00"
}

This lets any tool (including an AI assistant) unambiguously identify which Overleaf project a local working directory corresponds to โ€” no more guessing by file names. For git-backed copies the file is added to .git/info/exclude so it is never pushed back to Overleaf.

๐Ÿ”’ Security

  • Credentials are read only from environment variables โ€” nothing is persisted to disk by the server
  • Path traversal protection on all file operations
  • Per-project thread locks prevent concurrent git corruption
  • Session cookie expiry surfaces as a clear auth error, prompting the user to refresh OVERLEAF_SESSION

๐Ÿณ Self-Hosted Overleaf

For self-hosted Overleaf instances:

export OVERLEAF_BASE_URL="https://your-overleaf.example.com"
export OVERLEAF_GIT_HOST="your-overleaf.example.com"

๐Ÿ“„ License

MIT License โ€” see LICENSE for details.


๐Ÿ™ Acknowledgments

Inspired by and building upon ideas from:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

overleaf_mcp_plus-0.1.3.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

overleaf_mcp_plus-0.1.3-py3-none-any.whl (28.1 kB view details)

Uploaded Python 3

File details

Details for the file overleaf_mcp_plus-0.1.3.tar.gz.

File metadata

  • Download URL: overleaf_mcp_plus-0.1.3.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for overleaf_mcp_plus-0.1.3.tar.gz
Algorithm Hash digest
SHA256 b18de0892a22a2139620906799a7f5d401c75b2d8e699bef160b1170015fcd83
MD5 f5e4de8b6620f7e745e7c0b424d0a93b
BLAKE2b-256 94ea2741cd6195188a92da0dc60635893a56b518a770023ff36234d6071ce034

See more details on using hashes here.

File details

Details for the file overleaf_mcp_plus-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for overleaf_mcp_plus-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4c3269925c9c1b86ba9add673bf2f8856f404dbda0d574c85d9d19593f6e8ce3
MD5 3d84257cdca8d7a44b75cef964fd6e0d
BLAKE2b-256 cfa4d51a0be9dbbe5404bcf5c169ad2008218a2d43178ecff6d4dc9c3afa1ac3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page