# Overleaf MCP server

> Lets an AI agent pull, push, sync, diff and compile Overleaf LaTeX projects, and manage files, comments and tracked changes.

- Repository: https://github.com/aloth/olcli
- Page: https://hostedmcp.org/servers/aloth/olcli
- Transport: stdio
- Stars: 257
- License: MIT
- Latest version: 0.17.0

## Install

### Claude Code

```sh
claude mcp add --env 'OVERLEAF_SESSION=<YOUR_OVERLEAF_SESSION>' olcli -- npx -y @aloth/olcli
```

### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "olcli": {
      "command": "npx",
      "args": [
        "-y",
        "@aloth/olcli"
      ],
      "env": {
        "OVERLEAF_SESSION": "<YOUR_OVERLEAF_SESSION>"
      }
    }
  }
}
```

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "olcli": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@aloth/olcli"
      ],
      "env": {
        "OVERLEAF_SESSION": "<YOUR_OVERLEAF_SESSION>"
      }
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"olcli","type":"stdio","command":"npx","args":["-y","@aloth/olcli"],"env":{"OVERLEAF_SESSION":"<YOUR_OVERLEAF_SESSION>"}}'
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "olcli": {
      "command": "npx",
      "args": [
        "-y",
        "@aloth/olcli"
      ],
      "env": {
        "OVERLEAF_SESSION": "<YOUR_OVERLEAF_SESSION>"
      }
    }
  }
}
```

### Codex

```sh
codex mcp add olcli --env 'OVERLEAF_SESSION=<YOUR_OVERLEAF_SESSION>' -- npx -y @aloth/olcli
```

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.olcli]
command = "npx"
args = ["-y", "@aloth/olcli"]

[mcp_servers.olcli.env]
OVERLEAF_SESSION = "<YOUR_OVERLEAF_SESSION>"
```

### Gemini CLI

```sh
gemini mcp add -s user -e 'OVERLEAF_SESSION=<YOUR_OVERLEAF_SESSION>' olcli npx -- -y @aloth/olcli
```

### Gemini settings.json (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "olcli": {
      "command": "npx",
      "args": [
        "-y",
        "@aloth/olcli"
      ],
      "env": {
        "OVERLEAF_SESSION": "<YOUR_OVERLEAF_SESSION>"
      }
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `OVERLEAF_SESSION` | yes | yes | Overleaf session cookie value (overleaf_session2 on overleaf.com) |
| `OVERLEAF_BASE_URL` | no | no | Base URL of a self-hosted Overleaf instance |
| `OVERLEAF_COOKIE_NAME` | no | no | Session cookie name, for self-hosted instances that use overleaf.sid |

## FAQ

### Does the Overleaf MCP server require a paid Overleaf plan?

No. It works on the free overleaf.com plan and on self-hosted Community Edition, signing in with your normal Overleaf session. The one exception is tracked changes, which Overleaf only offers in premium projects.

### How do I add the Overleaf MCP server to Claude Code or Cursor?

Add an mcpServers entry named overleaf with command npx and args -y, --package, @aloth/olcli, olcli-mcp to .mcp.json or .cursor/mcp.json. The server reuses the session stored by olcli auth.

### Will the AI agent write to my Overleaf project without asking?

Every tool that changes a project, such as pushing a file, deleting, renaming, commenting or accepting tracked changes, shows what it will do and writes only after you confirm in the client.

### How does the MCP server authenticate to Overleaf?

It uses the session cookie saved by running olcli auth, or an OVERLEAF_SESSION environment variable you provide instead.

### Can the MCP server compile the LaTeX project and download the PDF?

Yes. The olcli compile and pdf commands compile on Overleaf and download the PDF, and output downloads compile outputs such as .bbl or .log.
