Overleafmcp

Overleafmcp

🚀 Overleaf MCP 服务器

Overleaf MCP 服务器是一个基于模型上下文协议(MCP)的服务器,它通过 Git 集成提供对 Overleaf 项目的访问。借助该服务器,Claude 等 MCP 客户端能够读取 LaTeX 文件、分析文档结构,并从 Overleaf 项目中提取内容。

✨ 主要特性

  • 📄 文件管理:列出并读取 Overleaf 项目中的文件。
  • 📋 文档结构解析:解析 LaTeX 文件的章节和子章节。
  • 🔍 内容提取:按标题提取特定章节的内容。
  • 📊 项目概述:获取项目状态和结构的概览信息。
  • 🏗️ 多项目支持:管理多个 Overleaf 项目。

📦 安装指南

  1. 克隆此仓库:
git clone [仓库地址]
  1. 安装依赖:
npm install
  1. 设置项目配置:
cp projects.example.json projects.json
  1. 使用你的 Overleaf 凭证编辑 projects.json
{
"projects": {
"default": {
"name": "My Paper",
"projectId": "YOUR_OVERLEAF_PROJECT_ID",
"gitToken": "YOUR_OVERLEAF_GIT_TOKEN"
}
}
}

获取 Overleaf 凭证

1. Git 令牌

  • 访问 Overleaf 账户设置 → Git 集成。
  • 点击“创建令牌”。

2. 项目 ID

  • 打开你的 Overleaf 项目。
  • 从 URL 中获取项目 ID:https://www.overleaf.com/project/[PROJECT_ID]

Claude 桌面端设置

将以下内容添加到你的 Claude 桌面端配置文件中:

  • Windows%APPDATA%\Claude\claude_desktop_config.json
  • macOS~/Library/Application Support/Claude/claude_desktop_config.json
  • Linux~/.config/claude/claude_desktop_config.json
{
"mcpServers": {
"overleaf": {
"command": "node",
"args": [
"/path/to/OverleafMCP/overleaf-mcp-server.js"
]
}
}
}

配置完成后,重启 Claude 桌面端。

💻 使用示例

基础用法

列出所有配置的项目

使用 list_projects 工具

获取项目概述

使用 status_summary 工具

读取 main.tex 文件

使用 read_file 工具,指定 filePath 为 "main.tex"

获取 Introduction 章节

使用 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 中忽略,以保护你的凭证信息。
  • 切勿提交真实的项目 ID 或 Git 令牌。
  • 请使用提供的 projects.example.json 作为模板。

📄 许可证

本项目采用 MIT 许可证。

  • 0 关注
  • 0 收藏,20 浏览
  • system 提出于 2025-09-21 16:12

相似服务问题

相关AI产品