> ## Documentation Index
> Fetch the complete documentation index at: https://ayakaleaf-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Server

> Connect an AI client such as Claude Code to a project through MCP, check that the connection works, and see what the client can do.

Each project has its own MCP server, so an AI client on your computer can read and edit the project, compile it and answer its comments. The client signs in with a Git authentication token.

> [!NOTE]
>
> If you see no **MCP server** card, see [MCP Server](https://ayakaleaf-pro.mintlify.site/on-premises/configuration/overleaf-toolkit/integrations/mcp-server.md) for your administrator.

## New in v6.3.3

From v6.3.3, the client can also work with the project history: list the changes, compare two versions, read a file as it was, save and delete versions, and restore a file or the whole project. It can list the tracked changes and accept or reject them, and make its own edits tracked changes when you ask it to. It can comment on a piece of text and edit or delete comment messages, read and send messages in the project chat, move and rename files and folders, create folders, and change the spell check language. Who may do what follows your role in the project, as in the editor, because the client works with your token: see [Who may do what](#who-may-do-what).

The MCP server was introduced in v6.3.1. v6.3.1 and v6.3.2 have the same 17 tools; v6.3.3 has 33.

| Tools | v6.3.1 and v6.3.2 | v6.3.3 |
| - | - | - |
| `get_clone_info`, `get_settings`, `list_files`, `delete_file`, `compile`, `get_compile_log`, `get_output_file_link`, `word_count`, `reply_to_comment`, `resolve_comment`, `reopen_comment` | Yes | Yes, unchanged |
| `read_file` | The latest content | Also a file as it was at a `version` |
| `edit_file`, `write_file` | Follow the track changes setting of the project | Also `trackChanges`, to make the edit a tracked change |
| `update_settings` | Compiler, TeX Live image and main document | Also the spell check language |
| `list_versions` | Version, comment and date | Also the `id` that `delete_version` takes, and who saved it |
| `list_comments` | Messages without an id | Also the `id` of each message, which `edit_comment_message` and `delete_comment_message` take |
| `list_changes`, `diff`, `create_version`, `delete_version`, `restore_file`, `restore_project`, `list_tracked_changes`, `accept_tracked_changes`, `reject_tracked_changes`, `add_comment`, `edit_comment_message`, `delete_comment_message`, `list_chat_messages`, `send_chat_message`, `move_file`, `create_folder` | No | Yes |

## Connect a client

**1. Open the dialog**

Open the project. In the left bar, click **Integrations**, then **MCP server**.

![The Integrations panel with the MCP server card](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/mcp-server-integrations.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=c38ad3def0079dc27b1774c7e0487482)

The Integrations panel

The dialog shows the address of this project's server and a tab for each client: **Claude Code**, **Codex**, **Cursor**, **VS Code** and **Gemini CLI**.

![The MCP server dialog with the address, a tab for each client and the command for Claude Code](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/mcp-server-dialog.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=e8554732779d9c6c7fb0cf0240364ce5)

The MCP server dialog

**2. Create a token**

Click **Go to settings**. Your account settings open in a new tab. Under **Git integration**, click **Generate token**, or **Add another token** if you already have one. Click **Copy** and keep the token somewhere safe, because you only see it once. Then click **Close**.

![The Git authentication token dialog with a Copy button](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/mcp-server-token.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=f4661b468dd1d409ef19967216955ae4)

Your new token

A token you already use for [Git integration](https://ayakaleaf-pro.mintlify.site/on-premises/user-guide/users/git-integration.md) works too, and so does one token for all your projects.

**3. Add the server to your client**

Back in the dialog, click the tab of your client and click **Copy** next to the configuration.

| Tab | Where it goes | The token |
| - | - | - |
| **Claude Code** | Run the command in a terminal | Replace `<token>` in the command |
| **Codex** | `~/.codex/config.toml` | Put it in the environment variable `OVERLEAF_TOKEN` |
| **Cursor** | `~/.cursor/mcp.json` | Put it in the environment variable `OVERLEAF_TOKEN` |
| **VS Code** | `.vscode/mcp.json` | The file has a password prompt called `overleaf-token` instead of the token |
| **Gemini CLI** | Run the command in a terminal | Replace `<token>` in the command |

The address belongs to one project. To connect another project, add it under another name, because `overleaf` is taken. For Claude Code, for example, change `overleaf` in the command to `overleaf-lab`.

## Check the connection

### With Claude Code

```bash theme={null}
claude mcp list
```

The server is listed as connected:

```text theme={null}
overleaf: https://<your-site>/project/<project-id>/mcp (HTTP) - ✔ Connected
```

### With curl

This works whatever your client is. Replace the address and the token, and send the `initialize` request of the MCP protocol:

```bash theme={null}
curl -X POST https://<your-site>/project/<project-id>/mcp \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"1.0"}}}'
```

The answer names the server, followed by its instructions for clients:

```json theme={null}
{"result":{"protocolVersion":"2025-06-18","capabilities":{"tools":{"listChanged":true}},"serverInfo":{"name":"overleaf","version":"1.0.0"},"instructions":"This server works on one Overleaf project. ..."},"jsonrpc":"2.0","id":1}
```

To see the tools, send `tools/list` with the same command. The answer lists 33 tools, or 31 if your site has the project chat turned off. Before v6.3.3 it lists 17.

```bash theme={null}
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'
```

To call one, send `tools/call`:

```bash theme={null}
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"list_files","arguments":{}}}'
```

```json theme={null}
{"result":{"content":[{"type":"text","text":"[\n  {\n    \"path\": \"main.tex\",\n    \"type\": \"doc\"\n  }\n]"}]},"jsonrpc":"2.0","id":3}
```

### In your account settings

Under **Git integration**, **Last used** shows the date for a token the server has received.

![The token list, with a date under Last used for the first token and N/A for the second](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/mcp-server-last-used.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=2abe32cb469d17b8b8c5eb18f1c0c2d3)

The first token has been used

### If it does not connect

| What you see | What it means |
| - | - |
| Status `401`, or in Claude Code `✘ Failed to connect` with `HTTP 401` | The token is missing, wrong or deleted |
| Status `404` | No project has this ID |
| Status `405` | The request was not a `POST` |
| Status `406` with `Not Acceptable` | The `Accept` header is missing: the client must accept both `application/json` and `text/event-stream` |

## What you see when a client works

Edits appear in an open editor as the client makes them, like a collaborator's, without reloading. New files and folders, moves and renames appear in the file tree.

![The editor showing a line that edit\_file added, with no dialog and no reload](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/mcp-server-live-edit.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=51163f1de5bec88d50bd96089bd1a9a2)

A line added by edit\_file

`edit_file` only changes text that appears exactly once. Otherwise the client gets an error, such as `oldString not found in main.tex, read_file again` or `oldString appears 2 times in main.tex, add context`, and nothing changes.

From v6.3.3, `move_file` moves or renames a file or folder, creating the folders of the new path as needed, and `create_folder` creates a folder. If the file is not found or the new path exists already, the client gets an error and nothing changes. `update_settings` can also change the spell check language, for example to `de`, or turn spell check off.

Replies to comments appear in the review panel under your name, because the token is yours. A comment resolved through the server leaves the panel, and reopening it brings it back.

![A comment in the review panel with a reply sent by reply\_to\_comment](https://mintcdn.com/ayakaleaf-pro/IsGnx0wnzqtV4hI8/images/on-premises/mcp-server-comment.png?fit=max\&auto=format\&n=IsGnx0wnzqtV4hI8\&q=85\&s=7b5cd74110b014b389bae7209b1330f0)

A reply sent by reply\_to\_comment

From v6.3.3, `add_comment` comments on a piece of text. The text must appear exactly once in the file; when it appears more than once, the client also gives a longer piece around it that appears once, and only the text is commented. The comment appears in the review panel under your name and stays on its text as the file changes. `edit_comment_message` changes one of your own messages. `delete_comment_message` deletes a message, and deleting the first one deletes the whole comment, as in the review panel.

`compile` compiles the project and returns the list of output files. `get_output_file_link` then gives a link to download the PDF or another output file. The link needs no token and stops working after 5 minutes.

For the full list of tools, see [Tools](https://ayakaleaf-pro.mintlify.site/on-premises/configuration/overleaf-toolkit/integrations/mcp-server.md#tools).

## Tracked changes

From v6.3.3, you can ask the client to make its edits tracked changes, for example *Rewrite the abstract as a tracked change*. `edit_file` and `write_file` then make the change to an existing file a tracked change under your name, even when track changes is off in the project, and you accept or reject it in the review panel. A new file is never a tracked change. If you do not ask, edits follow the track changes setting of the project, as yours do in the editor: they are tracked when track changes is on for you or for everyone.

If the project owner's account does not have track changes, the client gets `Track changes is off for this project` and nothing changes.

To have every edit of the client reviewed, turn track changes on for yourself. To tell its edits from yours in the review panel, give the client the token of another account that you share the project with.

`list_tracked_changes` lists the tracked changes with their file, the inserted or deleted text, the author and the time. `accept_tracked_changes` and `reject_tracked_changes` take the ids of the changes and work like the review panel: an accepted change stays in the text, a rejected insert is removed and a rejected delete comes back. An open editor shows the result without reloading. The tools tell the client to accept or reject only the changes you ask for.

## History

From v6.3.3, the client sees the project history as the history panel shows it.

| Tool | What it does |
| - | - |
| `list_changes` | Lists the changes, newest first: who changed which files and when, with the versions before and after each change. Older changes come in further batches. |
| `diff` | Compares two versions: one file as a unified diff, like `git diff`, or the files that were added, removed, edited or renamed |
| `read_file` with `version` | Reads a file as it was at a version |
| `list_versions` | Lists the saved versions, with their comment and who saved them |
| `create_version` | Saves the latest version, or an earlier one, with a comment, like **Label this version** |
| `delete_version` | Deletes a saved version; its changes stay |
| `restore_file` | Restores a file as it was at a version, like **Restore this version** |
| `restore_project` | Restores the whole project as it was at a version, like **Restore project to this version** |

A restore is a new change of its own, so you can undo it the same way. The tools tell the client to restore only when you ask.

If the project owner does not have full project history, the client sees only the changes of the last 24 hours, or the latest change if all are older, as in the history panel. It cannot compare, read or restore older versions.

## Project chat

From v6.3.3, `list_chat_messages` reads the project chat, newest first, 50 messages at a time. `send_chat_message` sends a message under your name, and it appears in an open chat at once. If your site has the project chat turned off, the client has neither tool.

## Who may do what

The client may do what your role in the project allows.

| What the client does | Owner | Editor | Reviewer | Viewer (named collaborator) | Viewer (link sharing) |
| - | -: | -: | -: | -: | -: |
| Read files and settings, compile, read the log, download the PDF | Yes | Yes | Yes | Yes | Yes |
| Write, edit, move and delete files, create folders, change the settings | Yes | Yes | No | No | No |
| See the history, comments and tracked changes | Yes | Yes | Yes | Yes | No |
| Read and send chat messages | Yes | Yes | Yes | Yes | No |
| Add comments and reply to them | Yes | Yes | Yes | No | No |
| Resolve, reopen or delete a comment | Yes | Yes | The ones they started | No | No |
| Edit a comment message | Their own | Their own | Their own | No | No |
| Delete a comment message | Yes | Yes | Their own | No | No |
| Accept or reject tracked changes | Yes | Yes | No | No | No |
| Save a version | Yes | Yes | Yes | No | No |
| Delete a saved version | Yes | The ones they saved | The ones they saved | No | No |
| Restore a file or the project | Yes | Yes | No | No | No |

Editors who joined by link count as editors. Reviewers cannot edit files through MCP, not even as tracked changes.

## Disconnect a client

Delete the token: see [Delete a token](https://ayakaleaf-pro.mintlify.site/on-premises/user-guide/users/git-integration.md#delete-a-token). From then on, the server answers `401` to that token. If you also use it for Git, Git stops accepting it too.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.