Overleaf MCP
An MCP (Model Context Protocol) server that lets LLM agents (Claude Code, etc.) read and update Overleaf LaTeX papers via git.
Architecture
overleaf_mcp.py— FastAPI server exposingread_paperandupdate_and_push_papertools over HTTPmain.py— stdio bridge that translates JSON-RPC (MCP protocol) to HTTP calls; this is what MCP clients connect to
Prerequisites
- Python 3.10+
pdflatex(for LaTeX compilation)git
Setup
- Clone your Overleaf project:
git clone https://git.overleaf.com/<your-project-id> ~/path/to/your-paper
- Configure the repository path:
cp .env.example .env
# Edit .env and set REPO_DIR to the absolute path of your local clone
- Install dependencies:
pip install -e .
Usage
Step 1: Start the MCP server
python overleaf_mcp.py
The server starts on http://localhost:8000 and exposes:
GET /mcp/tools— list available toolsPOST /mcp/execute— execute a toolGET /health— health check
Step 2: Connect an MCP client
The bridge (main.py) speaks JSON-RPC over stdio, the standard MCP transport. Point your MCP client to it.
Claude Code (via claude.json): ``json { "mcpServers": { "overleaf": { "command": "python", "args": ["/path/to/overleaf_mcp/main.py"] } } } ``
Or run the bridge directly for testing: ``bash python main.py ``
Tools
| Tool | Description | Parameters | |------|-------------|------------| | read_paper | Reads the current content of main.tex | None | | update_and_push_paper | Writes new main.tex, compiles with pdflatex, commits, and pushes to Overleaf | latex_content (required), commit_message (optional) | | read_bibliography | Reads a .bib file from the repo | bib_file (optional, default: references.bib) | | update_and_push_bibliography | Writes new .bib content, compiles, commits, and pushes | bib_content (required), bib_file (optional), commit_message (optional) |
Example
See mcp_sample.json for a sample request payload.











