Skip to main content
Glama

Overleaf MCP 服务器

一个通过 Git 集成提供对 Overleaf 项目访问的 MCP(模型上下文协议)服务器。它允许 Claude 和其他 MCP 客户端读取 LaTeX 文件、分析文档结构、提取内容,以及向 Overleaf 项目读写文件。

功能特性

  • 📄 文件管理:从 Overleaf 项目中列出、读取和写入文件

  • 📋 文档结构:解析 LaTeX 的章节和子章节

  • 🔍 内容提取:按标题提取特定章节

  • 📊 项目摘要:获取项目状态和结构的概览

  • 🏗️ 多项目支持:管理多个 Overleaf 项目

Related MCP server: Github MCP Server

快速入门(推荐)

无需克隆,无需 npm install。将此代码块添加到您的 Claude Desktop 配置文件中并重启 Claude Desktop。

配置文件位置

操作系统

路径

Windows

%APPDATA%\Claude\claude_desktop_config.json

macOS

~/Library/Application Support/Claude/claude_desktop_config.json

Linux

~/.config/claude/claude_desktop_config.json

macOS / Linux

{
  "mcpServers": {
    "overleaf": {
      "command": "npx",
      "args": ["-y", "@mjyoo2/overleaf-mcp"],
      "env": {
        "OVERLEAF_PROJECT_ID": "YOUR_OVERLEAF_PROJECT_ID",
        "OVERLEAF_GIT_TOKEN": "YOUR_OVERLEAF_GIT_TOKEN"
      }
    }
  }
}

Windows — Windows 上的 Claude Desktop 需要 cmd /c 来查找 npx

{
  "mcpServers": {
    "overleaf": {
      "command": "cmd",
      "args": ["/c", "npx", "-y", "@mjyoo2/overleaf-mcp"],
      "env": {
        "OVERLEAF_PROJECT_ID": "YOUR_OVERLEAF_PROJECT_ID",
        "OVERLEAF_GIT_TOKEN": "YOUR_OVERLEAF_GIT_TOKEN"
      }
    }
  }
}

重启 Claude Desktop。overleaf 工具应该会出现在 🔧 菜单中。

多项目设置

环境变量快速入门仅适用于单个项目。对于多个项目,请将 projects.json 文件放入用户配置目录,并跳过 Claude Desktop 配置中的 env 代码块。

文件位置

操作系统

路径

Windows

%APPDATA%\overleaf-mcp\projects.json

macOS / Linux

~/.config/overleaf-mcp/projects.json (或设置了 $XDG_CONFIG_HOME 则为 $XDG_CONFIG_HOME/overleaf-mcp/projects.json)

文件内容

{
  "projects": {
    "default": {
      "name": "Main Paper",
      "projectId": "...",
      "gitToken": "olp_..."
    },
    "thesis": {
      "name": "PhD Thesis",
      "projectId": "...",
      "gitToken": "olp_..."
    }
  }
}

Claude Desktop 配置 — 与快速入门相同,但没有 env 代码块:

{
  "mcpServers": {
    "overleaf": {
      "command": "cmd",
      "args": ["/c", "npx", "-y", "@mjyoo2/overleaf-mcp"]
    }
  }
}

(在 macOS / Linux 上去掉 cmd /c。)

在工具调用中通过 projectName 引用特定项目:

Use read_file with filePath: "main.tex", projectName: "thesis"

如果省略 projectName,则使用 default 条目。要将 projects.json 放在标准位置之外的地方,请在 env 代码块中将其指向 OVERLEAF_PROJECTS_CONFIG=/absolute/path/projects.json

获取 Overleaf 凭据

  1. 项目 ID — 打开您的 Overleaf 项目;ID 位于 URL 中:https://www.overleaf.com/project/[PROJECT_ID]

  2. Git 令牌 — Overleaf → 账户设置 (Account Settings) → Git 集成 (Git Integration) → “创建令牌” (Create Token)

配置参考

服务器会选择第一个匹配的配置源:

  1. 环境变量(单个项目)OVERLEAF_PROJECT_ID + OVERLEAF_GIT_TOKEN。可选:OVERLEAF_PROJECT_NAME 用于显示名称。

  2. 来自文件的令牌 — 设置 OVERLEAF_PROJECT_ID 以及 OVERLEAF_GIT_TOKEN_FILE=/path/to/token.txt(代替 OVERLEAF_GIT_TOKEN)。当您不想在 Claude Desktop JSON 中包含令牌时非常有用。文件在启动时读取一次,并会修剪末尾的空格/换行符。

  3. 多项目文件OVERLEAF_PROJECTS_CONFIG=/absolute/path/projects.json

  4. 用户配置目录projects.json 位于:

    • Windows: %APPDATA%\overleaf-mcp\projects.json

    • macOS / Linux: $XDG_CONFIG_HOME/overleaf-mcp/projects.json (默认为 ~/.config/overleaf-mcp/projects.json)

  5. 工作目录./projects.json

  6. 包目录 — 服务器脚本旁边的 projects.json(旧版,用于基于克隆的安装)。

当设置了环境变量且同时存在文件时,环境变量优先,并会向 stderr 记录一条通知,以便可见该覆盖行为。

projects.json 架构(多项目)

{
  "projects": {
    "default": {
      "name": "Main Paper",
      "projectId": "...",
      "gitToken": "olp_..."
    },
    "paper2": {
      "name": "Second Paper",
      "projectId": "...",
      "gitToken": "olp_..."
    }
  }
}

然后在工具调用中指定项目:projectName: "paper2"

本地开发

如果您想修改服务器、在发布前测试更改,或者在没有 npm 包的情况下使用它,您有三种本地安装选项。

选项 1 — 直接运行克隆的脚本

git clone https://github.com/mjyoo2/OverleafMCP.git
cd OverleafMCP
npm install

然后将 Claude Desktop 指向该脚本并通过环境变量传递凭据(与 npm 包使用的加载器路径相同):

{
  "mcpServers": {
    "overleaf": {
      "command": "node",
      "args": ["/absolute/path/to/OverleafMCP/overleaf-mcp-server.js"],
      "env": {
        "OVERLEAF_PROJECT_ID": "...",
        "OVERLEAF_GIT_TOKEN": "olp_..."
      }
    }
  }
}

在 Windows 上,args 应使用 "C:\\Users\\you\\OverleafMCP\\overleaf-mcp-server.js"

如果您更喜欢使用多项目文件:

cp projects.example.json projects.json   # then edit it

脚本旁边的 projects.json 是优先级最低的后备方案,因此即使没有环境变量,这也有效。

选项 2 — 在本地测试打包的 npm 制品

验证用户通过公共注册表访问的几乎相同的代码路径,在推送发布前很有用:

npm pack
# → mjyoo2-overleaf-mcp-<version>.tgz

将 Claude Desktop 指向 tarball。注意显式的 --package= 和 bin 名称 — npx -y <tarball-path> 在 npm 10+ 中起作用(路径被错误地检测为可执行文件):

{
  "mcpServers": {
    "overleaf": {
      "command": "cmd",
      "args": [
        "/c", "npx", "-y",
        "--package=C:\\absolute\\path\\to\\mjyoo2-overleaf-mcp-<version>.tgz",
        "overleaf-mcp"
      ],
      "env": {
        "OVERLEAF_PROJECT_ID": "...",
        "OVERLEAF_GIT_TOKEN": "olp_..."
      }
    }
  }
}

在 macOS / Linux 上去掉 cmd /c 包装器:"command": "npx", "args": ["-y", "--package=/abs/path/to/...tgz", "overleaf-mcp"]

选项 3 — 从 shell 对 MCP 协议进行冒烟测试

无需 Claude Desktop:

OVERLEAF_PROJECT_ID=... OVERLEAF_GIT_TOKEN=... node overleaf-mcp-server.js

您应该会在 stderr 上看到 Overleaf MCP server running on stdio。进程保持打开状态,等待 stdin 上的 JSON-RPC;按 Ctrl+C 退出。

可用工具

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: 项目标识符(可选)

write_file

将文件的完整内容写入项目。

  • filePath: 文件路径(必填)

  • content: 要写入文件的内容(必填)

  • commitMessage: 提交信息(必填)

  • projectName: 项目标识符(可选)

write_section

将特定章节的内容写入项目。

  • filePath: LaTeX 文件路径(必填)

  • sectionTitle: 章节标题(必填)

  • newContent: 章节的替换内容,包括章节标题(必填)

  • commitMessage: 提交信息(必填)

  • projectName: 项目标识符(可选)

使用示例

# List all projects
Use the list_projects tool

# Get project overview
Use status_summary tool

# Read main.tex file
Use read_file with filePath: "main.tex"

# Get Introduction section
Use get_section_content with filePath: "main.tex" and sectionTitle: "Introduction"

# List all sections in a file
Use get_sections with filePath: "main.tex"

# Write the full content of a file to the project
Use write_file with filePath: "main.tex", content: "...", commitMessage: "..."

# Write the content of a specific section to the project
Use write_section with filePath: "main.tex", sectionTitle: "Introduction", newContent: "\\section{Introduction}\n...", commitMessage: "..."

安全说明

  • Overleaf Git 令牌授予对您项目的完全读写权限 — 请像对待密码一样对待它。

  • 如果您的配置文件已备份或同步,请优先使用 OVERLEAF_GIT_TOKEN_FILE 而不是在 Claude Desktop JSON 中内联令牌。

  • projects.json 在此仓库中已被 .gitignore 忽略。切勿提交真实的项目 ID 或 Git 令牌。

  • 通过 MCP 工具调用提供的文件路径仅限于克隆的项目目录;.. 遍历和绝对路径将被拒绝。

许可证

MIT 许可证

Install Server
A
license - permissive license
B
quality
A
maintenance

Maintenance

Maintainers
Response time
Release cycle
1Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mjyoo2/OverleafMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server