> ## 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 服务器

> 通过项目的 MCP 服务器，将 Claude Code 或 Codex 等 AI 客户端连接到项目。

每个项目都有一个 MCP 服务器，因此 Claude Code、Codex、Cursor、VS Code 或 Gemini CLI 等 AI 客户端可以处理该项目：读取和编辑其文件、编译项目、读取 LaTeX 日志、下载 PDF 以及回复评论。

> [!NOTE]
>
> 此功能由 [ayaka-notes/ayakaleaf-pro](https://github.com/ayaka-notes/ayakaleaf-pro) 开发。它自 v6.3.1 起引入。

![](https://mintcdn.com/ayakaleaf-pro/75JEUzv4DcYJF7Z-/images/on-premises/8b4eca630b3083da54177b4e7a431571.png?fit=max\&auto=format\&n=75JEUzv4DcYJF7Z-\&q=85\&s=73546d80edf492bf43df53303023ca29)

![](https://mintcdn.com/ayakaleaf-pro/z0f8sws6lnhMSWO4/images/on-premises/img-c48f4f64.png?fit=max\&auto=format\&n=z0f8sws6lnhMSWO4\&q=85\&s=b6f33a465bae9952ce7be3bcb15c57c5)

### 设置

MCP 服务器随 Git 集成一起提供：启用 [git-bridge](https://ayakaleaf-pro.mintlify.site/zh-CN/on-premises/configuration/overleaf-toolkit/integrations/git-integration.md) 后，MCP 服务器也随之可用。无需其他配置。

### 连接 AI 客户端

1. 在 **Account Settings** 中生成一个 Git 身份验证令牌。MCP 服务器和 Git 使用同一个令牌。
2. 在编辑器中打开 **Integrations**，然后点击 **MCP server**。它会显示项目 MCP 服务器的地址 `https://<your-overleaf>/project/<project_id>/mcp`，以及如何将其添加到各个 AI 客户端：复制命令，并将 `<token>` 替换为你的令牌。

令牌通过 HTTP 请求头 `Authorization: Bearer <token>` 发送。例如，Claude Code 的命令为：

```bash theme={null}
claude mcp add --transport http overleaf \
  https://<your-overleaf>/project/<project_id>/mcp \
  --header "Authorization: Bearer <token>"
```

### 使用

连接完成后，用自然语言向 AI 客户端提出请求即可。例如：

| 你的请求 | AI 客户端使用的工具 |
| - | - |
| *修正引言中的拼写错误。* | `read_file`、`edit_file`：编辑会实时显示在编辑器中 |
| *编译项目并修复 LaTeX 错误。* | `compile`、`get_compile_log`、`edit_file` |
| *回复未解决的评论，然后将其标记为已解决。* | `list_comments`、`reply_to_comment`、`resolve_comment` |
| *切换到 XeLaTeX 并下载 PDF。* | `update_settings`、`compile`、`get_output_file_link` |

### 工具

| 分组 | 工具 |
| - | - |
| 项目 | `get_clone_info`、`get_settings`、`update_settings`、`list_versions` |
| 文件 | `list_files`、`read_file`、`edit_file`、`write_file`、`delete_file` |
| 编译 | `compile`、`get_compile_log`、`get_output_file_link`、`word_count` |
| 评论 | `list_comments`、`reply_to_comment`、`resolve_comment`、`reopen_comment` |

通过 `edit_file` 和 `write_file` 所做的编辑会实时显示在编辑器中，并与协作者的编辑合并。对于一次处理大量文件、二进制文件或重命名操作，AI 客户端也可以使用 Git 克隆项目并推送。

### 权限

与 Git 一样，MCP 服务器遵循项目的共享设置：

* 所有可以查看项目的人都可以读取项目、编译项目并下载其输出。
* 只有所有者和编辑者可以更改其文件和设置。
* 审阅者还可以回复评论，并将自己发起的评论标记为已解决或重新打开。
* 通过链接加入的查看者无法看到评论，与在编辑器中一致。

### 问答

> [accordion] 我在编辑器中看不到 Integrations 或 MCP server
>
> \*\*回答：\*\*MCP 服务器没有自己的环境变量。它通过 `config/overleaf.rc` 中的 `GIT_BRIDGE_ENABLED=true` 启用，参见 [Git 集成](https://ayakaleaf-pro.mintlify.site/zh-CN/on-premises/configuration/overleaf-toolkit/integrations/git-integration.md)。修改后，请运行 `bin/up -d`。如果没有 git-bridge，编辑器左侧栏中将不会显示 **Integrations** 标签页。


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