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

> 透過專案的 MCP Server，將 Claude Code 或 Codex 等 AI 用戶端連接至專案。

每個專案都有一個 MCP Server，因此 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 Server 隨 Git 整合一併提供：啟用 [git-bridge](https://ayakaleaf-pro.mintlify.site/zh-TW/on-premises/configuration/overleaf-toolkit/integrations/git-integration.md) 後，MCP Server 也隨即可用。不需要其他任何設定。

### 連接 AI 用戶端

1. 在**帳號設定**中產生 Git 驗證權杖。MCP Server 與 Git 使用同一個權杖。
2. 在編輯器中開啟**整合**，然後點擊 **MCP Server**。它會顯示專案 MCP Server 的位址 `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 複製專案並推送。

### 權限

MCP Server 與 Git 一樣，遵循專案的共用設定：

* 所有可以檢視專案的人，都可以讀取、編譯專案並下載其輸出。
* 只有擁有者與編輯者可以變更其檔案與設定。
* 審閱者也可以回覆留言，並將自己發起的留言標示為已解決或重新開啟。
* 透過連結加入的檢視者無法看到留言，與在編輯器中相同。

### 問與答

> [accordion] 我在編輯器中看不到「整合」或「MCP Server」
>
> **回答：**MCP Server 沒有專屬的環境變數。它是透過 `config/overleaf.rc` 中的 `GIT_BRIDGE_ENABLED=true` 啟用，請參閱 [Git 整合](https://ayakaleaf-pro.mintlify.site/zh-TW/on-premises/configuration/overleaf-toolkit/integrations/git-integration.md)。變更後請執行 `bin/up -d`。若未啟用 git-bridge，編輯器的左側欄就不會顯示**整合**分頁。


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