olcli 标志

olcli

社区
aloth

Overleaf CLI - pull, push, sync, compile LaTeX projects from your terminal. Git remote helper, MCP server for AI agents, and TypeScript library.

发布者aloth
代码仓库olcli
语言TypeScript
复刻数
24
星标数
194
可用工具
0
传输类型stdio
分类
许可协议MIT
链接
  • 将工具接入 AI 工作流

    olcli 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 0 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 194 个 Star 和 24 个 Fork。

olcli — Overleaf CLI

Command-line interface for Overleaf — Sync, manage, and compile LaTeX projects from your terminal.

CI npm version npm downloads GitHub stars License: MIT AgentSkills

Work with Overleaf projects directly from your command line. Edit locally with your favorite editor, version control with Git, and sync seamlessly with Overleaf's cloud compilation.

Features

  • 📋 List all your Overleaf projects
  • ✨ Create blank or example projects
  • ⬇️ Pull project files to local directory for offline editing
  • ⬆️ Push local changes back to Overleaf
  • 🔄 Sync bidirectionally with smart conflict detection
  • 🔍 Diff local files against the live remote before pushing
  • 📝 Marked-up revisions — diff --latexdiff produces the struck-through/underlined PDF advisors and journals ask for
  • 🔀 Git remote — use Overleaf as a native git remote (docs)
  • ✌️ Two-way deletions — files removed locally are deleted on Overleaf on next sync
  • 🗑️ Delete and ✏️ rename remote files by path
  • 🚫 Smart ignore — LaTeX build artifacts and OS noise filtered automatically; extend with .olignore
  • 📄 Compile PDFs using Overleaf's remote compiler
  • 📦 Download individual files or full project archives
  • 📤 Upload files to projects
  • 💬 Review comments — list, add, resolve, reopen, delete, and reply to threads
  • 🗂️ Preserve folder structure when pushing nested files
  • ⏱️ Configurable timeout for slow connections
  • 🔑 Password login for self-hosted instances (no browser required)
  • ⚙️ Self-hosted Overleaf/ShareLaTeX support
  • 📊 Output compile artifacts (.bbl, .log, .aux for arXiv submissions)
  • 🤖 MCP server for AI assistants (docs)

Perfect for:

  • Editing LaTeX in your preferred text editor (Vim, VS Code, Emacs, etc.)
  • Version control with Git while using Overleaf's compiler
  • Automating workflows and CI/CD pipelines
  • Offline work with periodic sync

Installation

Homebrew (macOS/Linux)

bash
brew tap aloth/tap
brew install olcli

npm (all platforms)

bash
npm install -g @aloth/olcli

Or use with npx without installation:

bash
npx @aloth/olcli list

For AI agents (via AgentSkills)

bash
npx skills add aloth/olcli

Quick Start

1. Authenticate

Session cookie (overleaf.com and self-hosted):

bash
olcli auth --cookie "your_session_cookie_value"

Email/password (self-hosted without reCAPTCHA):

bash
olcli auth --email "you@example.com"
# prompts for the password, so it stays out of your shell history

The password is not stored unless you pass --save-password. A session cookie is saved either way and is what later commands use; the password only buys an automatic re-login once that cookie expires. For scripts, set OVERLEAF_EMAIL and OVERLEAF_PASSWORD — every command reads them, so a scripted run never needs olcli auth at all.

2. List Projects

bash
olcli list

3. Pull, Edit, Push

bash
olcli pull "My Thesis"
cd My_Thesis/
vim main.tex
olcli push

4. Compile PDF

bash
olcli pdf
# Compile a specific .tex file (for multi-doc projects):
olcli pdf -r appendix.tex

5. Or use native git commands

bash
git clone overleaf::https://www.overleaf.com/project/<id>
cd <project>
# edit, commit, push — standard git workflow
git push

See Git Remote Helper docs for details.

Commands

All commands auto-detect the project when run from a synced directory (contains .olcli.json).

CommandDescription
olcli authSet session cookie or login with email/password
olcli whoamiCheck authentication status
olcli logoutClear the global config and the local .olauth, reporting each
olcli listList all projects
olcli info [project]Show project details and file list
olcli pull [project] [dir]Download project files to local directory
olcli push [dir]Upload local changes to Overleaf (--delete also removes files deleted locally)
olcli sync [dir]Bidirectional sync (pull + push)
olcli diff [project] [dir]Show content-level changes between local files and the remote
olcli upload <file> [project]Upload a single file (--to <path> sets the remote destination)
olcli download <file> [project]Download a single file
olcli delete <file> [project]Delete a remote file or folder (alias: rm)
olcli rename <old> <new> [project]Rename a remote file or folder (alias: mv)
olcli project create <name>Create a blank or example project (--template blank|example)
olcli project rename <new> [project]Rename the project itself (--dry-run)
olcli project rename-bulkRename many projects by pattern (dry-run unless --apply)
olcli compile [project]Trigger PDF compilation
olcli pdf [project]Compile and download PDF
olcli output [type]Download compile output files
olcli zip [project]Download project as zip archive
olcli comments list [project]List comments (--status, --context)
olcli comments add <file> <msg>Add a comment to selected text
olcli comments reply <id> <body>Reply to a comment thread
olcli comments resolve <id>Resolve a comment thread
olcli comments reopen <id>Reopen a resolved thread
olcli comments delete <id>Delete a comment thread
olcli ignored [dir]List ignore patterns in effect
olcli config set-url <url>Set self-hosted base URL
olcli config get-urlShow the configured base URL
olcli config set-cookie-name <name>Set session cookie name
olcli config get-cookie-nameShow the configured session cookie name
olcli config set-timeout <ms>Set default HTTP timeout
olcli config get-timeoutShow the configured HTTP timeout
olcli checkShow config paths and credential sources

Compile Options

The compile-related commands (compile, pdf, output) accept:

FlagDescription
-r, --resource <path>Compile a specific .tex file as the root document (e.g. appendix.tex, folder/test.tex)

Useful in multi-doc projects: each -r run compiles the file as if it were the main document.

Global Options

FlagDescription
--verbosePrint HTTP requests and responses to stderr
--base-url <url>Override Overleaf instance URL
--cookie-name <name>Override session cookie name
--timeout <ms>Override HTTP timeout (default: 10000)

Sync Behavior

Pull

  • Downloads all files from Overleaf
  • Skips local files modified after last pull (won't overwrite your changes)
  • Use --force to overwrite local changes

Push

  • Uploads files modified after last pull
  • Preserves nested folder structure
  • Filters out LaTeX build artifacts and OS noise
  • Use --all to upload all files, --dry-run to preview

Sync

  • Pulls remote changes, then pushes local changes
  • Local modifications win if newer
  • Propagates local deletions — use --no-delete to opt out
  • Use --dry-run to preview without applying

Diff

olcli diff compares the bytes of your local files against the project's current contents and prints a unified diff.

bash
olcli diff                 # every changed file, as patches
olcli diff --name-only     # just the changed paths
olcli diff --file main.tex # one file
olcli diff -U 8            # wider context
olcli diff --exit-code     # exit 1 if anything differs, for CI

The remote side is fetched fresh on every run. The diff describes the project as it is at that moment — which is what a subsequent push would overwrite — not a comparison against your last pull. .olcli.json records remote paths, never remote contents, so there is no stored snapshot to compare against; and the whole project arrives in a single request, the same one pull makes, so fetching fresh costs one round trip rather than one per file. A collaborator editing between diff and push can still change the outcome, which is why the fetch time is printed.

In the output, a/ is the remote and b/ is local: a + line is content push would upload, a - line is content it would overwrite. Files that differ only in bytes that are not text (PDFs, images) are reported as Binary files ... differ. Both sides pass through the same ignore layers, so build artifacts sitting on Overleaf are not reported as locally deleted.

diff --name-only and push --dry-run answer different questions and will disagree. push --dry-run lists files whose modification time is newer than the last pull, because that is what push uploads; diff lists files whose contents actually differ. A file you touched without editing appears in the first and not the second.

Marked-up revisions with latexdiff

A unified diff is the right artifact for a developer and the wrong one for a thesis advisor. --latexdiff marks the same revision up inside the document instead — deletions struck through, additions underlined — which is what advisors and journals ask for.

bash
olcli diff --latexdiff          # write .olcli-diff/main-diff.tex
olcli diff --latexdiff --pdf    # ...and compile it, download .olcli-diff/main-diff.pdf

Requires latexdiff on your PATH. It ships with TeX Live and MacTeX; nothing else in olcli diff needs an external tool.

--pdf compiles on Overleaf, so you do not need a local TeX installation. The compile endpoint can only build a file that is in the project, so the marked-up document is uploaded as olcli-latexdiff.tex next to your root document, compiled, downloaded, and then removed. The command says so before it does it, refuses to overwrite a file of that name if one already exists, and prints the exact olcli rm command if the cleanup itself fails.

\input and \include are inlined before comparing (--no-flatten to opt out). Without that, a remote compile would resolve those against the files sitting in the project — the old content — and quietly produce a PDF showing every input file as unchanged.

Output goes to .olcli-diff/, which is dotted so that push and sync never pick it up; -o <path> puts it elsewhere. The root document is the .tex file declaring \documentclass; if several do, --main <path> picks one rather than the command guessing. --latexdiff-opt passes anything else straight through, e.g. --latexdiff-opt --math-markup=0.

One limit worth knowing: --pdf compiles against the project, not against your working directory, so anything the markup needs must already be on Overleaf. A .sty or .cls you added locally fails the compile — the compiler log is written next to the marked-up source when that happens. A figure you added locally does not fail it; Overleaf draws a placeholder box naming the missing file and the rest of the PDF is fine.

Using diff as a CI gate

--exit-code turns the command into a check, with the statuses diff(1) uses:

StatusMeaning
0Nothing differs
1Something differs
2The run failed — bad flags, no session, project unreachable
yaml
- name: Fail if the paper on Overleaf has drifted from the repo
  run: olcli diff --exit-code --name-only
  env:
    OVERLEAF_SESSION: ${{ secrets.OVERLEAF_SESSION }}

The 1 versus 2 split is the point of the flag. Without it a pipeline cannot tell a changed file from an expired session cookie, and a job that goes red for the second reason sends whoever reads the log hunting for a diff that was never computed. Every other olcli command reports failure as 1, and olcli diff still does when --exit-code is absent, so adding the flag does not change what existing scripts see.

The gate covers whatever was compared: --file main.tex narrows it to one file, the way a git diff --exit-code pathspec does, and a --file that matches nothing is 0 rather than an error. Under --latexdiff it still reports on the project as a whole — a changed figure is a real difference even though a marked-up root document cannot show it.

Note that this compares against Overleaf now, not against your last pull, so the check is "has anyone drifted from what is committed here", which is what makes it worth running on a schedule as well as on a push.

How deletion propagation works

olcli records a manifest of remote files in .olcli.json. On next sync:

  • File missing locally + still on remote → deleted on Overleaf
  • File new locally → uploaded
  • File modified locally → uploaded (local wins)
  • File only on remote → downloaded

First-time syncs skip the deletion phase (no prior manifest to compare).

Ignoring Files

Three layers

LayerSourcePurpose
1Built-inLaTeX intermediates, OS noise, build dirs. Always on.
2.olignoreProject-level patterns (gitignore syntax).
3.olignore.localMachine-specific patterns.

Later layers override earlier ones. Negation (!important.aux) is supported.

Special PDF rule

X.pdf is ignored only if X.tex (or .ltx) exists in the same folder.

Inspecting and overriding

bash
olcli ignored                  # list patterns in effect
olcli push --show-ignored      # see what was skipped
olcli sync --no-default-ignore # only .olignore applies
olcli sync --no-ignore         # upload everything

Configuration

Credentials are checked in order:

  1. OVERLEAF_SESSION environment variable
  2. .olauth file in current directory
  3. Global config — run olcli check to see the exact path

The global config path is platform-dependent (conf resolves it), so it is not hardcoded here: on macOS it lands under ~/Library/Preferences/, on Linux under ~/.config/. olcli auth prints the path it wrote to.

⚠️ olcli auth --save-local writes .olauth into the current directory, which is usually your LaTeX project. Add it to that project's .gitignore before committing.

What is stored, and how to clear it

Everything is stored in plaintext, so it is worth knowing what is on disk:

CredentialStored by defaultWhere
Session cookieyesglobal config, or .olauth with --save-local
Email + passwordno — only with --save-passwordglobal config

olcli check reports what exists without printing any secret.

olcli logout clears the global config and the .olauth file in the current directory, then lists what it removed. It cannot unset environment variables, so if OVERLEAF_SESSION or OVERLEAF_EMAIL/OVERLEAF_PASSWORD are set, it says so instead of implying you are logged out — those take precedence over anything on disk.

Self-hosted Overleaf

bash
olcli config set-url https://latex.example.org
olcli config set-cookie-name overleaf.sid

Or pass per-command: olcli --base-url https://latex.example.org list

Timeout

bash
olcli config set-timeout 60000          # persist
olcli --timeout 60000 pull "Big Thesis" # one-off
export OVERLEAF_TIMEOUT=60000           # env var

Precedence: --timeout > OVERLEAF_TIMEOUT > config > default (10000ms).

Examples

bash
# Daily thesis workflow
olcli pull "PhD Thesis" thesis && cd thesis
vim chapters/methods.tex
olcli sync && olcli pdf -o draft.pdf

# Quick PDF download
olcli pdf "Conference Paper" -o paper.pdf

# Compile a specific root document
olcli pdf "Conference Paper" -r appendix.tex -o appendix.pdf
olcli compile "Conference Paper" -r folder/test.tex

# Upload figures
olcli upload figures/diagram.png          # relative path is preserved
olcli upload /tmp/build/diagram.png       # absolute path lands in the project root
olcli upload /tmp/build/diagram.png --to figures/diagram.png   # explicit destination

# arXiv submission prep
olcli output bbl -o main.bbl
olcli output bbl -r folder/test.tex -o main.bbl  # compile artifacts from a specific root doc
olcli zip -o arxiv-submission.zip

# Backup all projects
for proj in $(olcli list --json | jq -r '.[].name'); do
  olcli zip "$proj" -o "backups/${proj}.zip"
done

Programmatic Usage (Library API)

@aloth/olcli exposes OverleafClient and all public interfaces as a library.

Install

bash
npm install @aloth/olcli

Basic example

ts
import { OverleafClient } from '@aloth/olcli';

const client = await OverleafClient.fromSessionCookie(cookie);

const created = await client.createProject('My Paper');
const projects = await client.listProjects();
const info = await client.getProjectInfo(projectId);
const zipBuf = await client.downloadProject(projectId);
const pdfBuf = await client.downloadPdf(projectId);

await client.uploadFile(projectId, null, 'main.tex', readFileSync('main.tex'));

const comments = await client.listComments(projectId, { status: 'open' });

Available exports

ts
import {
  OverleafClient,
  // Types
  Project, ProjectInfo, ProjectTemplate, CreateProjectOptions, CreatedProject,
  FolderEntry, DocEntry, FileEntry,
  CommentMessage, ProjectComment, CommentContext, CommentStatus,
  ListCommentsOptions, AddCommentOptions, Credentials, SessionCookiePair,
  // Config utilities
  getBaseUrl, setBaseUrl, getSessionCookie, setSessionCookie,
  getSessionCookieName, setSessionCookieName, getCsrf, setCsrf,
  getLastProject, setLastProject, clearConfig, getConfigPath, saveOlAuth,
  getTimeout, setTimeout, getPasswordCredentials, setPasswordCredentials,
  clearPasswordCredentials, type PasswordCredentials,
  // Ignore utilities
  DEFAULT_IGNORE_PATTERNS, loadIgnore, shouldIgnore, buildTexSiblingSet,
  IgnoreContext, LoadIgnoreOptions,
} from '@aloth/olcli';

Further Documentation

Troubleshooting

Session expired — Get a fresh cookie from the browser and run olcli auth again.

Compilation fails — Check the Overleaf web editor for detailed error logs (missing packages, syntax errors, missing bibliography files).

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

See CONTRIBUTING.md for local setup, which tests need a real Overleaf account, and what to expect from CI on a pull request.

docs/ARCHITECTURE.md explains how the client works — there is no public Overleaf API, so it authenticates as a browser session.

License

MIT © Alexander Loth

安装

TypingMind
{
  "mcpServers": {
    "olcli": {
      "command": "npx",
      "args": [
        "@aloth/olcli",
        "{{config.COMMAND}}"
      ],
      "env": {
        "COMMAND": "<COMMAND>"
      }
    }
  }
}

将 olcli MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 olcli 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请保持终端窗口及其中的进程运行。
3

将 olcli 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 olcli MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "olcli": {
      "command": "npx",
      "args": [
        "-y",
        "@aloth/olcli"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 olcli MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 olcli MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 olcli 帮我完成这项任务吗?
olcli
当然。我已阅读。
以下是我使用 olcli 得到的结果。

常见问题

olcli MCP 服务器有什么用途?

olcli 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 olcli MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您可以让 Claude、ChatGPT、Gemini 等不同 AI 模型,或您在 TypingMind 中配置的其他模型使用 olcli,而无需为每个模型单独配置 MCP 服务器。

为什么在 TypingMind 中使用 olcli MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是优秀的大语言模型聊天前端之一。连接 olcli 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 olcli MCP 连接到 TypingMind?

olcli 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

olcli MCP 在 TypingMind 中提供哪些工具?

olcli 提供 MCP 功能,您可以在 TypingMind 的插件页面启用这些功能,然后在聊天中使用,或将其分配给 AI 智能体。

使用 olcli MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行掌控模型提供商、API 密钥、提示词和 MCP 配置。如果 olcli 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇