overleaf-claude-mcp
Allows Claude to read, write, and push LaTeX projects on Overleaf, with token-efficient editing and smart diff.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@overleaf-claude-mcpfix the typo in my paper's abstract"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
📝 Overleaf Claude MCP
✨ Let Claude read, write, and push your Overleaf LaTeX projects — all from the chat, with minimum tokens.
An MCP (Model Context Protocol) server that connects Claude Code / Claude Desktop with your Overleaf projects — built for real LaTeX workflows where every token counts.
⚡ Why This MCP?
Large LaTeX files (a thesis main.tex is often 80–100 KB / ~35K tokens) make naive MCP workflows expensive: every "rewrite this section" would normally force Claude to emit the full file again.
v1.1.0 fixes that. Three optimizations give you order-of-magnitude token savings on real editing sessions:
Scenario | Naive MCP | This MCP (v1.1.0) | Saving |
Read a 35K-token file twice | 70K tokens | ~35K + diff | 🟢 ~50% |
Replace a 50-word sentence | 35K tokens | ~100 tokens ( | 🟢 >99% |
Clone a repo with many figures | Minutes, hundreds of MB | Seconds, text files only | 🟢 Fast |
Edit same file across a chat | Full file per turn | Only the diff | 🟢 Steady |
Related MCP server: Overleaf MCP
🎯 What's New in v1.1.0
🚀 Performance Optimizations
🗜️ Sparse checkout — Only syncs text files (
.tex,.bib,.bst,.cls,.sty,.bbl,.cfg). Images and PDFs are skipped, so clone and pull stay fast even on figure-heavy projects.🔀 Read/write separation — Read operations pull the latest from Overleaf; write operations skip the pull and work locally. Push always pulls first to prevent conflicts.
🧠 Smart diff mode —
read_filereturns only the changes on subsequent reads instead of the full file. Your long chat session stops paying for the same content over and over.✂️
patch_filetool — Replace specific text in a file without transferring the full content. The token cost scales with the edit size, not the file size.
🆚 vs mjyoo2/OverleafMCP
The upstream OverleafMCP is read-only. This fork adds full write support and the performance optimizations above:
Capability |
| This Project |
📖 Read files from Overleaf | ✅ | ✅ |
🧩 Parse LaTeX sections | ✅ | ✅ |
📂 List projects and files | ✅ | ✅ |
📊 Project status summary | ✅ | ✅ |
📝 Write / edit files | ❌ | ✅ |
🚢 Commit and push to Overleaf | ❌ | ✅ |
✂️ Patch files (token-efficient edits) | ❌ | ✅ |
🗜️ Sparse checkout (skip images/PDFs) | ❌ | ✅ |
🧠 Smart diff (return only changes) | ❌ | ✅ |
🛠️ All Available Tools
Tool | What it does |
📂 | List all configured Overleaf projects |
📄 | List text files in a project (images / PDFs skipped by design) |
📖 | Read a file. Smart mode returns only the diff on subsequent reads; pass |
🧩 | Extract all section / subsection headings from a LaTeX file — no need to read the body |
🔍 | Get the body of one specific section by title |
📝 | Write a full file (does not auto-pull; use |
✂️ | ⭐ v1.1.0 Replace specific text without transferring the whole file |
🚢 | Commit and push to Overleaf. Always pulls first to avoid conflicts |
📊 | Project overview including local changes ( |
📋 Prerequisites
🟢 Node.js ≥ 18
🔧 Git installed on your system
📘 An Overleaf account with Git integration enabled
🚀 Setup
1. Clone this repo
git clone https://github.com/Junfei-Z/overleaf-claude-mcp.git
cd overleaf-claude-mcp
npm install2. Get your Overleaf credentials
You need two things:
🆔 Project ID
Open your project in Overleaf and look at the URL:
https://www.overleaf.com/project/64a1b2c3d4e5f6a7b8c9d0e1
^^^^^^^^^^^^^^^^^^^^^^^^
This is your Project ID🔑 Git Token
Scroll to the Git Integration section
Click Create token
Copy the token (it starts with
olp_...)
⚠️ Keep your Git Token private. Never commit it to version control.
3. Configure your project(s)
cp projects.example.json projects.jsonEdit projects.json:
{
"projects": {
"default": {
"name": "My Paper",
"projectId": "64a1b2c3d4e5f6a7b8c9d0e1",
"gitToken": "olp_xxxxxxxxxxxxxxxxxxxx"
}
}
}You can add multiple projects:
{
"projects": {
"default": {
"name": "PhD Thesis",
"projectId": "64a1b2c3d4e5f6a7b8c9d0e1",
"gitToken": "olp_xxxxxxxxxxxxxxxxxxxx"
},
"paper2": {
"name": "Conference Paper",
"projectId": "75b2c3d4e5f6a7b8c9d0e1f2",
"gitToken": "olp_yyyyyyyyyyyyyyyyyyyy"
}
}
}4. Connect to Claude
Option A — Claude Code (CLI / IDE extension)
Create or edit .mcp.json in your project directory (or ~/.claude/.mcp.json for global access):
{
"mcpServers": {
"overleaf": {
"command": "node",
"args": ["/absolute/path/to/overleaf-claude-mcp/overleaf-mcp-server.js"]
}
}
}Then restart Claude Code.
💡 Claude Code only loads
.mcp.jsonfrom the directory where you launch it. Eithercdinto that directory first, or place it at~/.claude/.mcp.jsonfor global access:cd /path/to/your/project # where .mcp.json lives claude # start Claude Code here
Option B — Claude Desktop
Edit your Claude Desktop config file:
🍎 macOS:
~/Library/Application Support/Claude/claude_desktop_config.json🪟 Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"overleaf": {
"command": "node",
"args": ["/absolute/path/to/overleaf-claude-mcp/overleaf-mcp-server.js"]
}
}
}Then restart Claude Desktop.
💬 Usage Examples
📖 Reading
"List all files in my Overleaf project"
"Read
main.texfrom my Overleaf project"
"Show me all the sections in my paper"
"Get the content of the Introduction section"
✏️ Writing
"Add a new paragraph to the Related Work section"
"Fix the typo in line 42 of
main.tex"
"Rewrite the abstract to be more concise"
"Push the changes to Overleaf with commit message 'Update abstract'"
✂️ Token-efficient editing (v1.1.0 sweet spot)
"Patch
main.tex: replace 'old title' with 'new title'"
patch_file only transfers the specific text being changed, not the entire file. For a one-paragraph edit on a 35K-token thesis, that's the difference between ~35K tokens and ~200 tokens.
🔁 Typical Workflow
You: "Read main.tex from my Overleaf project"
Claude: [reads via MCP — first read returns full content]
You: "Rewrite the introduction to emphasize our main contribution"
Claude: [uses patch_file to replace just the introduction text]
You: "Read main.tex again"
Claude: [smart mode: returns only the diff since last read]
You: "Push to Overleaf"
Claude: [pulls latest, commits, and pushes — changes appear in Overleaf]🧭 Pairing with Direct git (Optional, for Power Users)
For very large files or team projects, you can pair this MCP with a direct git clone of the same Overleaf project. Both use the same Git bridge, so they stay consistent.
When to use each tool:
Task | Best Tool |
Discover projects, list files, get section structure | 🧩 MCP ( |
Small edits (one-paragraph or less) | ✂️ MCP |
Short new files (bib entries, short fragments) | 📝 MCP |
Large rewrites (many sections of a long | 🧰 Direct git — |
Merging edits from web collaborators | 🔄 Either — both workflows resolve via git |
This way MCP handles the fast-path (discover + targeted edits), and direct git handles the heavy lifting, with no duplicated state.
📋 Drop-in CLAUDE.md Template
Claude Code automatically loads CLAUDE.md from your project root. Paste the template below to lock in the hybrid workflow. Replace the two placeholders with your own values (never commit the filled-in file — add CLAUDE.md to .gitignore if your token lives inside it).
# Overleaf Workflow: MCP + Git Hybrid
This project's Overleaf (project id `<YOUR_PROJECT_ID>`) is synced via Git Bridge.
Use **MCP** for discovery and small edits; use **local git** for large-file edits.
Local clone: `/tmp/<project-name>-git` (clone once with the URL below).
Clone URL (do not commit this file if the token is filled in):
https://git:<YOUR_GIT_TOKEN>@git.overleaf.com/<YOUR_PROJECT_ID>
## Use MCP for (lightweight, cheap)
- `list_projects`, `list_files`, `get_sections`, `status_summary`
- `read_file` on short files
- `patch_file` for one-paragraph edits
- `write_file` only when the target file is < 5 KB
## Use local git for (large files, token-efficient)
- Edits to `main.tex` or any `.tex` > 5 KB
- Workflow:cd /tmp/-git && git pull --rebase
Edit the file locally with the Edit tool
git add -A && git commit -m "" && git push
## Standard per-edit flow
1. `git pull --rebase` first (to merge any web edits)
2. Locate the change with Grep / get_sections — do NOT Read the whole file
3. Edit with str_replace (patch_file for MCP, Edit for git)
4. Commit with a specific message, then push
## Don't
- ❌ Use `write_file` to rewrite `main.tex`
- ❌ Read the whole `main.tex` (> 20 KB) into context
- ❌ `git push --force` on conflict — stop and ask instead
- ❌ Reflow unrelated paragraphs for cosmetic reasons
## Token self-check
If a single operation will read or write > 10 KB, announce the range first and
wait for confirmation.🔐 Security reminder: the template contains placeholders
<YOUR_PROJECT_ID>and<YOUR_GIT_TOKEN>. Put your real values locally, then do not commitCLAUDE.mdif it contains the token. AddCLAUDE.mdto.gitignore, or keep the token only inprojects.jsonand reference it fromCLAUDE.mdby name.
🔧 How Sparse Checkout Works
To minimize sync time and bandwidth, the MCP server uses git sparse checkout to only download text files from your Overleaf project:
✅ Synced:
.tex,.bib,.bst,.cls,.sty,.bbl,.cfg❌ Skipped:
.png,.jpg,.pdf,.eps, and all other binaries
This means:
🏎️ Clone and pull are much faster, especially for projects with many figures
🖼️ You can still reference images in your LaTeX code (they exist on Overleaf) — they just aren't downloaded locally
🎨 To add or modify images, use the Overleaf web editor directly
🤝 Multi-Project Usage
When using multiple projects, specify which one:
"Read
main.texfrom projectpaper2"
"List files in my PhD Thesis project"
The projectName parameter matches the key in your projects.json (e.g. "default", "paper2").
🔐 Security
🚫
projects.jsonis in.gitignoreand will never be committed🔒 Git tokens are only used locally to talk to Overleaf's Git bridge
🔄 You can rotate your token anytime in Overleaf Account Settings
❓ Troubleshooting
Problem | Solution |
MCP server not showing up | Restart Claude Code / Claude Desktop after editing config |
| Run |
Git clone fails | Double-check your project ID and git token |
Push fails | Make sure your git token has write access; check if someone else is editing the same file on Overleaf |
File not found after sparse checkout | Only text files are synced. Images and PDFs are skipped by design |
Token usage still feels high | Use |
🌟 Credits
Original read-only MCP server:
mjyoo2/OverleafMCPWrite/push functionality and performance optimizations by Junfei-Z with Claude Code
📄 License
MIT — see LICENSE.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Junfei-Z/overleaf-claude-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server