Overleaf MCP Helper
by gswxp2
README.md
# ๐ Overleaf MCP Helper
> Let AI assistants read, edit, and manage your Overleaf LaTeX projects โ safely.
[](./LICENSE)
[](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 โญ!*
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues