Skip to main content
Glama

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 exposing read_paper and update_and_push_paper tools over HTTP

  • main.py — stdio bridge that translates JSON-RPC (MCP protocol) to HTTP calls; this is what MCP clients connect to

Related MCP server: overleaf-mcp

Prerequisites

  • Python 3.10+

  • pdflatex (for LaTeX compilation)

  • git

Setup

  1. Clone your Overleaf project:

    git clone https://git.overleaf.com/<your-project-id> ~/path/to/your-paper
  2. Configure the repository path:

    cp .env.example .env
    # Edit .env and set REPO_DIR to the absolute path of your local clone
  3. 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 tools

  • POST /mcp/execute — execute a tool

  • GET /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):

{
  "mcpServers": {
    "overleaf": {
      "command": "python",
      "args": ["/path/to/overleaf_mcp/main.py"]
    }
  }
}

Or run the bridge directly for testing:

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.

Related MCP Connectors

Related MCP Servers