> ## 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, and check that the connection works.

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.

## 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 17 tools.

```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 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.

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

`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 and what each role may do, see [Tools](https://ayakaleaf-pro.mintlify.site/on-premises/configuration/overleaf-toolkit/integrations/mcp-server.md#tools) and [Permissions](https://ayakaleaf-pro.mintlify.site/on-premises/configuration/overleaf-toolkit/integrations/mcp-server.md#permissions).

## 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.