Overleaf MCP 服务器是一个基于模型上下文协议(MCP)的服务器,它通过 Git 集成提供对 Overleaf 项目的访问。借助该服务器,Claude 等 MCP 客户端能够读取 LaTeX 文件、分析文档结构,并从 Overleaf 项目中提取内容。
git clone [仓库地址]
npm install
cp projects.example.json projects.json
projects.json:{
"projects": {
"default": {
"name": "My Paper",
"projectId": "YOUR_OVERLEAF_PROJECT_ID",
"gitToken": "YOUR_OVERLEAF_GIT_TOKEN"
}
}
}
https://www.overleaf.com/project/[PROJECT_ID]。将以下内容添加到你的 Claude 桌面端配置文件中:
%APPDATA%\Claude\claude_desktop_config.json~/Library/Application Support/Claude/claude_desktop_config.json~/.config/claude/claude_desktop_config.json{
"mcpServers": {
"overleaf": {
"command": "node",
"args": [
"/path/to/OverleafMCP/overleaf-mcp-server.js"
]
}
}
}
配置完成后,重启 Claude 桌面端。
使用 list_projects 工具
使用 status_summary 工具
使用 read_file 工具,指定 filePath 为 "main.tex"
使用 get_section_content 工具,指定 filePath 为 "main.tex",sectionTitle 为 "Introduction"
使用 get_sections 工具,指定 filePath 为 "main.tex"
若要处理多个项目,可将它们添加到 projects.json 中:
{
"projects": {
"default": {
"name": "Main Paper",
"projectId": "project-id-1",
"gitToken": "token-1"
},
"paper2": {
"name": "Second Paper",
"projectId": "project-id-2",
"gitToken": "token-2"
}
}
}
然后在工具调用中指定项目名称:
使用 get_section_content 工具,指定 projectName 为 "paper2",filePath 为 "main.tex",sectionTitle 为 "Methods"
list_projects列出所有配置的项目。
list_files列出项目中的文件(默认列出 .tex 文件)。
extension:文件扩展名过滤器(可选)projectName:项目标识符(可选,默认为 "default")read_file读取项目中的特定文件。
filePath:文件路径(必需)projectName:项目标识符(可选)get_sections获取 LaTeX 文件中的所有章节。
filePath:LaTeX 文件路径(必需)projectName:项目标识符(可选)get_section_content获取特定章节的内容。
filePath:LaTeX 文件路径(必需)sectionTitle:章节标题(必需)projectName:项目标识符(可选)status_summary获取项目的综合状态概述。
projectName:项目标识符(可选)OverleafMCP/
├── overleaf-mcp-server.js # 主 MCP 服务器
├── overleaf-git-client.js # Git 客户端库
├── projects.json # 你的项目配置文件(已在 .gitignore 中忽略)
├── projects.example.json # 示例配置文件
├── package.json # 依赖文件
└── README.md # 本说明文件
projects.json 已在 .gitignore 中忽略,以保护你的凭证信息。projects.example.json 作为模板。本项目采用 MIT 许可证。