Skip to main content
Glama
README.md
# ๐Ÿƒ Overleaf MCP Helper

> Let AI assistants read, edit, and manage your Overleaf LaTeX projects โ€” safely.

[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](./LICENSE)
[![MCP](https://img.shields.io/badge/MCP-v1.0-blue.svg)](https://modelcontextprotocol.io)

**Overleaf MCP Helper** is a [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server paired with a VSCode extension that bridges AI assistants (Claude, ChatGPT, Copilot, etc.) to your Overleaf projects. Write, refactor, and manage LaTeX papers with AI โ€” without ever leaving Overleaf.

## โœจ Features

- ๐Ÿ“– **Read** any file in your Overleaf project
- โœ๏ธ **Edit** files with safe, exact-match substring replacement (no full-file overwrites!)
- ๐Ÿ“„ **Create** new files (with overwrite protection)
- ๐Ÿ—‘๏ธ **Delete** files (directory deletion blocked for safety)
- ๐Ÿ“ **Rename / Move** files within the project
- ๐Ÿ” **Search** across all project files with regex
- ๐Ÿ“Š **Parse LaTeX logs** โ€” extract errors, warnings, and bad boxes from compile output
- ๐ŸŒณ **Tree view** of the project structure
- ๐Ÿ”„ **Auto-retry** with connection recovery on network failures

## ๐Ÿ—๏ธ Architecture

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   AI Assistant                          โ”‚
โ”‚            (Claude / ChatGPT / Copilot)                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚ MCP (stdio)
                       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              MCP Server (Node.js)                       โ”‚
โ”‚                                                         โ”‚
โ”‚  Tools: edit_file ยท create_file ยท delete_file           โ”‚
โ”‚         rename_file ยท read_file ยท search_in_project     โ”‚
โ”‚         get_compile_log ยท tree ยท list_files             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚ HTTP (localhost:23119)
                       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚          VSCode Extension (HTTP Bridge)                  โ”‚
โ”‚                                                         โ”‚
โ”‚  Exposes vscode.workspace.fs via REST API               โ”‚
โ”‚  Endpoints: /ws/read ยท /ws/write ยท /ws/delete           โ”‚
โ”‚             /ws/rename ยท /ws/ls ยท /ws/stat ยท /ws/tree   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚ VSCode VFS API
                       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Overleaf                              โ”‚
โ”‚          (overleaf-workshop:// protocol)                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

## ๐Ÿ“ฆ Installation

### Prerequisites

- [VSCode](https://code.visualstudio.com/)
- [Overleaf Workshop](https://marketplace.visualstudio.com/items?itemName=iamhyc.overleaf-workshop) extension (to open Overleaf projects in VSCode)
- Node.js โ‰ฅ 18

### Step 1: Install the VSCode Extension

**Option A: Use the pre-built `.vsix` (recommended)**

A pre-built extension is available in the [`dist/`](./dist/) directory:

1. Download `dist/overleaf-mcp-helper-extension-1.0.0.vsix`
2. In VSCode: **Extensions โ†’ ยทยทยท โ†’ Install from VSIX...** โ†’ select the downloaded file

**Option B: Build from source**

```bash
cd extension
npm install
npm run compile
npm run package
```

This will generate a `.vsix` file in the `extension/` directory (e.g. `extension/overleaf-mcp-helper-extension-1.0.0.vsix`).

Install it in VSCode: **Extensions โ†’ ยทยทยท โ†’ Install from VSIX...** โ†’ select the generated `.vsix` file.

### Step 2: Configure the MCP Server

First, install MCP server dependencies:

```bash
cd mcp-server
npm install
```

Then add to your MCP configuration file (e.g. Claude Desktop `claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "overleaf": {
      "command": "node",
      "args": ["/path/to/overleaf-mcp-helper/mcp-server/index.mjs"]
    }
  }
}
```

### Step 3: Open an Overleaf Project

1. Open an Overleaf project in VSCode via the **Overleaf Workshop** extension
2. The bridge extension auto-starts an HTTP server on `localhost:23119`
3. The MCP server auto-discovers the bridge and connects

That's it! Your AI assistant can now interact with your Overleaf project. ๐ŸŽ‰

## ๐Ÿ› ๏ธ Available Tools

### File Operations

| Tool | Description | Safety |
|------|-------------|--------|
| `read_file` | Read a single file by path | โœ… Read-only |
| `read_multiple_files` | Read multiple files at once | โœ… Read-only |
| `edit_file` | Replace an exact substring (must match uniquely) | โœ… Safe โ€” rejects ambiguous matches |
| `create_file` | Create a new file (rejects if exists) | โœ… Safe โ€” no overwrite |
| `delete_file` | Delete a file (rejects directories) | โš ๏ธ Destructive โ€” files only |
| `rename_file` | Rename or move a file (rejects if dest exists) | โš ๏ธ Destructive โ€” no overwrite |

### Search & Navigation

| Tool | Description |
|------|-------------|
| `list_projects` | List all open workspaces/projects |
| `list_files` | Recursively list all files |
| `tree` | Visual directory tree (configurable depth) |
| `search_in_project` | Regex search across text files |

### LaTeX-Specific

| Tool | Description |
|------|-------------|
| `get_compile_log` | Parse `.log` file โ€” extract errors, warnings, bad boxes |

## โš™๏ธ Configuration

### Environment Variables (MCP Server)

| Variable | Default | Description |
|----------|---------|-------------|
| `VFS_BRIDGE_PORT` | `23119` | Base port for bridge discovery |
| `VFS_BRIDGE_TIMEOUT` | `10000` | HTTP request timeout (ms) |
| `VFS_BRIDGE_WRITE_TIMEOUT` | `15000` | Write request timeout (ms) |
| `VFS_BRIDGE_RETRIES` | `2` | Max retries on connection failure |

### Extension Settings (VSCode)

| Setting | Default | Description |
|---------|---------|-------------|
| `overleafMcpHelper.port` | `23119` | HTTP server port |
| `overleafMcpHelper.autoStart` | `true` | Auto-start when VFS workspace detected |

## ๐Ÿ”’ Safety Design

This project prioritizes **safety** to protect your precious LaTeX manuscripts:

1. **No full-file overwrite** โ€” We deliberately removed the `write_file` tool. All edits go through `edit_file` which requires an exact, unique match.
2. **Overwrite protection** โ€” `create_file` rejects if the file exists. `rename_file` rejects if the destination exists.
3. **Directory protection** โ€” `delete_file` only works on files, not directories.
4. **Automatic retry** โ€” Network failures trigger port re-discovery and retry, not data corruption.
5. **Overleaf version history** โ€” Even if something goes wrong, Overleaf keeps full version history for recovery.

## ๐Ÿ“„ License

[MIT](./LICENSE) โ€” use it however you like.

---

**Made with โค๏ธ for the academic community.**

*If this tool helps you write papers faster, consider giving it a โญ!*