MagicTeX

io.github.ZoeLinUTS由 GitHub 帳號 ZoeLinUTS 發布v0.1.10更新於 Oct 24, 2026

LaTeX editor for AI agents: live PDF preview, PDF comments that drive edits, git history

概覽

AI 產生的概覽

MagicTeX 是為 AI 代理打造的本地 LaTeX 編輯器:編譯論文、開啟即時 PDF 工作區,並把錨定在 PDF 上的註解轉成代理的修改指令。

可以做什麼
編譯 LaTeX 專案並開啟或更新即時 PDF 工作區,自動偵測主檔案,可選引擎與編譯後端(render_preview)。讀取已接受的 PDF 註解,回傳頁碼、引用段落與原始檔行號等工作項目(check_comments)。在段落上新增註解、於討論串回覆、編輯後附註說明標記完成(add_comment、reply_to_comment、resolve_comment)。列出最近的編譯檢查點,並以圖片呈現並排差異(list_checkpoints、show_diff)。
適用情境
適合讓助理協助修改 LaTeX 論文時使用:你在渲染後的 PDF 上審閱並留下註解,代理據此修改原始碼並逐項解決,同時有檢查點歷史可回溯。
執行需求
透過 npx magictex-mcp 以 stdio 在本機執行。需要 Node 20.19+、Playwright 的 Chromium(自動安裝,或沿用已安裝的 Chrome),以及首次執行時約 650 MB 的 WASM TeX Live 資源下載,依使用者快取;可用 MAGICTEX_ASSETS_DIR 變更快取位置。本機安裝 TeX 與 latexmk 為選項,可得到與 Overleaf 一致的輸出。
安裝前請注意
此伺服器會寫入你的專案:修改原始檔、存檔時重新編譯,並保存註解與隱藏的 git 檢查點。可選的自動工作流程會自動接受註解並直接修改,沒有逐輪確認,請檢查檢查點與差異。它也會啟動本機 HTTP 預覽服務與隱藏瀏覽器,並在首次執行時下載大量資源。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 MagicTeX,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

MagicTeX — LaTeX Editor for AI Agents

[npm] [MCP registry] [CI] [stars] [last commit] [license] [Sponsor]

English · 简体中文 · 日本語 · 한국어 · Español · Français · Deutsch · Português

MagicTeX is a LaTeX editor built for AI agents — an Overleaf-like one-window workspace for Claude Code, served by an MCP server, with no local TeX install and no Overleaf account: live PDF preview, a source editor with a Visual (WYSIWYG) mode, change history, and comments you anchor on the rendered PDF that become edit instructions for the agent. (npm package: magictex-mcp.)

It compiles with a WASM TeX Live 2026 engine (texlyre-busytex) running inside a headless browser, so there's nothing multi-gigabyte to install — just a one-time WASM asset download.

[The MagicTeX workspace: file tree, source editor, live PDF, and a reviewer comment]

See it before you install

A guided walkthrough of the comment → agent loop lives at zoelin.dev/tools/magictex, built from real tool output. It's a replay, not a hosted instance — the TeX engine is a one-time ~650 MB download and the agent half is Claude itself, so MagicTeX runs next to your project rather than in a web page.

The workspace

One browser window (inspired by Typst's one-surface editor and LiquidText's anchored annotations):

┌──────────────────────────────────────────────────────────────┐│  ✓ up to date · 13 pages        Export .zip · Download PDF   │├────────────┬──────────────────────────────┬──────────────────┤│ Source /   │          PDF (live)          │    Comments      ││ History    │  select text → 💬 comment    │  accepted → ask  ││  editor,   │  highlights stay anchored    │  Claude to       ││  timeline  │  auto-reloads on every edit  │  address them    ││  + diffs   │                              │  → resolved ✓    │└────────────┴──────────────────────────────┴──────────────────┘
  • Comment → Claude loop (the point of it all). Review the rendered document like a supervisor marking up a printout: select text, attach a comment ("tighten this paragraph"). Then tell Claude to "address my comments" — it pulls them via check_comments as located work items (page + quoted passage
    • the source file:line it anchors to + your ask), edits the source, and resolves each card with a note. You interact with the document; Claude interacts with the source. Run it hands-off with /loop — see docs/AGENT-LOOP.md.
  • Editable source panel. A CodeMirror LaTeX editor with the project's files — save (Ctrl+S) recompiles and refreshes the PDF, Typst-style. Or keep using your own editor: any save triggers the same live loop.
  • Live reload. A file watcher recompiles on every save — Claude's edits, the built-in editor's, or your external editor's.
  • Change history. Each successful compile is auto-snapshotted to a hidden git ref (refs/latex-preview/checkpoints) — never touching your branches, git log, or working tree. The History tab shows the timeline and each checkpoint's colorized diff beside the PDF.
  • Get to Overleaf. Download PDF, Export .zip (clean build-inputs bundle), and a one-click Open in Overleaf link for public GitHub repos; Premium Git-bridge sync is a documented git push. See docs/USER-GUIDE.md.
  • Review workflow (reviewer → gate → resolver). A reviewer/defender agent posts comments via add_comment; you Accept/Reject them (or flip Auto-accept for copilot mode); an author loop resolves the accepted ones. Comments carry roles and a reply thread. See docs/AGENT-LOOP.md.
  • Save vs. recompile, your call. The built-in editor auto-saves every 30s without recompiling; Ctrl+S / Save / Recompile rebuild the PDF on demand. (Flip ⚡ Live for recompile-as-you-type.) Your own editor and Claude's edits still auto-recompile via the watcher.
  • Real projects. Auto-detects the main file, gathers multi-file \input/\include, .bib, in-repo .cls/.sty/.bst and figures, runs BibTeX and reruns when needed; common missing packages are auto-injected.
  • Compile backend. Uses your local latexmk when you have one — full package fidelity, output matching Overleaf — and the bundled zero-install WASM TeX Live when you don't. Force either with backend: "system" / "wasm". Every compile reports which one ran.
  • Document classes. IEEEtran is bundled, because no venue class ships in the WASM TeX Live and a missing class can't be worked around the way a package can. Conference classes (NeurIPS, ICML, CVPR, ACL, AAAI …) carry no redistributable licence, so put the .cls from the author kit beside your source — it's picked up automatically.
  • MCP tools: render_preview (compile + open the workspace), check_comments / resolve_comment / add_comment / reply_to_comment (the review loop), show_diff (side-by-side diff as an image — useful on image-capable clients).
  • Actionable errors. Failed compiles return parsed {file, line, message} errors so Claude can self-correct, and show in the workspace.

Setup

MagicTeX is on npm as magictex-mcp and listed in the official MCP registry as io.github.ZoeLinUTS/magictex — so any client that reads the registry can find it. There's nothing to clone and no TeX install; npx fetches it on first use.

  1. Add it to your paper project's .mcp.json (see .mcp.json.example):

    json
    {  "mcpServers": {    "magictex": { "command": "npx", "args": ["-y", "magictex-mcp"] }  }}

    For local development from a clone, point it at the source instead: "command": "npx", "args": ["tsx", "/absolute/path/to/magictex-mcp/src/server.ts"]

  2. Restart Claude Code (or /mcp reconnect) so it picks up the server.

  3. Ask Claude to render. e.g. "render a preview of this paper" → the first call downloads the WASM TeX Live assets (~650 MB, one time), compiles, and opens the live preview tab. Subsequent edits reload it automatically.

The WASM assets are not in this repo. They're fetched on first run into a per-user cache — ~/Library/Caches/magictex on macOS, $XDG_CACHE_HOME/magictex on Linux, %LOCALAPPDATA%\magictex on Windows — so upgrading MagicTeX doesn't re-download them, and a checkout, a global install and an npx run share one copy. Set MAGICTEX_ASSETS_DIR to put them elsewhere. To pre-fetch: npx texlyre-busytex download-assets <that directory>.

Install as a Claude Code plugin (slash commands)

For a low-typing workflow, install MagicTeX as a plugin — one install gives you the MCP server and the slash commands:

/plugin marketplace add ZoeLinUTS/MagicTeX-mcp/plugin install magictex

Then, in your paper project, use the workflow commands for the common flows:

  • /magic-latex — compile and open the workspace (the live preview).
  • /ai-review [skill] — review the paper with a skill (default academic-paper-revision; pass any skill name) and post comments for you to Accept/Reject. Missing skills are reported with an install hint.
  • /address-comments — resolve your accepted comments (loop it with /loop 60s /address-comments).
  • ⚡ /ultra-agents [skill] [depth] — fully autonomous: review, auto-accept, fix, repeat, up to depth rounds (default 2), stopping early the moment a round finds nothing new. No per-round approval — that's the point, and the risk. depth > 5 asks you to confirm before starting. Ends with a summary (what was raised, what changed, which checkpoints to look at) — every round is still an ordinary, revertible checkpoint. See docs/AGENT-LOOP.md.

One command per tool

Every MCP tool also has a slash command with the same name, so you can drive any single step by typing the tool name. The rule to teach: the tool is X → type /X.

Type thisRuns toolWhat it does
/render_previewrender_previewCompile the paper and open/refresh the live preview.
/check_commentscheck_commentsList the comments you've accepted, as edit instructions (no edits yet).
/resolve_comment [id] [note]resolve_commentMark a comment done after the edit; it turns green for your review.
/add_comment ["quote"] [note]add_commentAnchor a comment onto a passage for you to Accept/Reject.
/reply_to_comment [id] [text]reply_to_commentAdd a threaded reply to a comment.
/show_diff [checkpoint]show_diffSide-by-side visual diff as an image (current changes, or a checkpoint).
/list_checkpoints [limit]list_checkpointsRecent checkpoints with their sha, newest first — find one to pass into /show_diff.

You never have to type these — plain English works too ("render a preview", "address my comments"). The commands are just a fast, teachable shorthand.

The plugin bundles the MCP server (npx magictex-mcp), so installing the plugin is all you need — the .mcp.json above is the alternative if you'd rather not install a plugin. The slash commands work either way.

Tools

The MCP surface, for any client that speaks MCP. (In Claude Code you can just ask in plain English, or use the slash commands above — these are the underlying tools.)

ToolParametersWhat it does
render_previewmainFile? · engine? (pdflatex | xelatex | lualatex, default xelatex) · backend? (wasm | system | auto, default auto — local latexmk if installed, else the bundled WASM engine)Compiles the project and opens/refreshes the live workspace. The main file is auto-detected by scanning for \documentclass if omitted.
check_commentsincludeResolved? (default false)Returns the accepted comments as located work items — page, quoted passage, the source file:line, and the ask. Reviewer suggestions awaiting your decision are reported but not returned as work.
add_commentquote · comment · role? (reviewer | defender) · page? · accepted?Anchors a comment onto a passage. Posts as a suggestion awaiting your Accept/Reject unless accepted is set — that flag is what makes autonomous mode autonomous.
resolve_commentid · noteMarks a comment done after the edit, with one line describing what changed. It turns green in the workspace for your review.
reply_to_commentid · text · role? (author | reviewer | defender)Adds a threaded reply, so a disagreement can be worked out on the comment instead of in chat.
show_diffcheckpoint?Renders a side-by-side diff as an image, shown inline in the conversation. Defaults to the current uncommitted changes; pass a checkpoint sha for a saved version.
list_checkpointslimit? (default 10, max 50)Recent checkpoints with their sha, newest first — use it to find one to pass to show_diff.

The headline workflows are built on top of these, not among them. /magic-latex, /ai-review, /address-comments and ⚡ /ultra-agents are Claude Code plugin commands that orchestrate the tools above — /ultra-agents chains review → auto-accept → fix for as many rounds as you allow, and is the reason add_comment takes an accepted flag. They are not part of the MCP surface, so another MCP client sees the seven tools only. See the plugin section and docs/AGENT-LOOP.md.

See it in the terminal

These are real tool outputs, captured verbatim from an actual run against the sample paper — not mocked up. This is what you see in Claude Code while the browser workspace (screenshot above) reflects the same state live.

You type:

/magic-latex

Claude calls render_preview and replies:

✓ Compiled main.tex with xelatex in 1900ms — 2 files. Workspace (live preview,source editor, history, PDF comments — auto-reloads on edits):http://127.0.0.1:52042/app

You (or a reviewer skill) leave a comment, then ask what's ready to act on. Claude calls check_comments:

1 accepted comment — edit each at its source location per the instruction, thencall resolve_comment with its id and a one-line note:
[id: 2fce9e3c8b5f] p.1 — "Sorting widgets efficiently is a long-standing problem"  ↳ source: main.tex:15  → Tighten this opening sentence.
(1 reviewer suggestion still awaits the human's accept in the workspace — notactionable yet.)

Claude makes the edit and calls resolve_comment:

✓ Resolved comment 2fce9e3c8b5f ("Sorting widgets efficiently is a long-standingproblem…") — the card now shows: Rewrote the opening sentence.

Ask again, and the accepted queue is empty — only the still-unaccepted suggestion remains, waiting on you:

No accepted comments. (2 already resolved.)
(1 reviewer suggestion still awaits the human's accept in the workspace — notactionable yet.)

How it works

Claude edits .tex ─┐ file watcher ─────┼─▶ compile coordinator ─▶ headless Chromium ─▶ WASM TeX ─▶ PDF render_preview ───┘         (serialized)         (engine host)                │                                                                               ▼                     your workspace (/app)  ◀── WebSocket "reload" ◀── local HTTP server                     Source · PDF · History · Comments        (serves /app + /latest.pdf)

The WASM engines need DOM/Worker globals, so the server hosts a hidden headless Chromium as its compile worker; the workspace you open is a lightweight React + pdf.js app with no WASM in it. See docs/ARCHITECTURE.md.

mermaid
flowchart LR  H["👤 You<br/>Source · PDF · History · Comments"]  A["🤖 Claude Code<br/>+ review / author agents"]
  H <-->|"select text →<br/>anchor comment"| SRV["Preview server<br/>HTTP + WebSocket · serves /app"]  A -->|"7 MCP tools"| MCP["MCP server<br/>render_preview · show_diff · list_checkpoints<br/>check / resolve / add / reply_comment"]
  SRV --> CO["Compile coordinator<br/>(serialized)"]  MCP --> CO  A -. edits source .-> FILES[("Paper files · git repo")]  FILES --> WATCH["File watcher"] --> CO  CO --> ENG["WASM busytex<br/>(headless Chromium)"] --> PDF["/latest.pdf"]  PDF -. live reload .-> H  CO --> CK["git checkpoints<br/>(hidden ref) → History"]
  SRV <--> CJSON[(".latex-preview/<br/>comments.json")]  MCP <--> CJSON  CJSON -->|"check_comments<br/>(your accepted asks)"| A

Both front doors — you in the workspace, agents through the 7 MCP tools — meet at the same coordinator, comment store, and git history. You act on the rendered document (anchor a comment); Claude acts on the source (reads your comments via check_comments, edits, resolve_comment). That shared substrate is what makes the comment loop, the review workflow, and traceable history possible.

Requirements

  • Node 20.19+ (the floor chokidar and playwright actually need; the server checks at startup and says so)
  • Playwright's Chromium (installed automatically; ~150–300 MB) — or set it to reuse your installed Chrome.
  • ~650 MB disk for the one-time WASM TeX Live assets — all of it fetched on the first run, in three package sets (basic 87 MB, recommended 190 MB, extra 324 MB, plus the 31 MB engine). A normal paper only loads the basic set; the larger two sit on disk until something needs them. Cached per user, not per install, so upgrading MagicTeX doesn't re-download them. Override the location with MAGICTEX_ASSETS_DIR.
  • A local TeX install is optional. See below for when it matters.

Do I need a local TeX distribution?

No — the bundled WASM engine compiles with nothing installed, which is the whole point. But it ships a subset of TeX Live, so some things aren't in it: svg, most venue document classes, and various less common packages. When one is missing you'll be told, rather than handed a silently wrong PDF.

Install a distribution when you want output that matches Overleaf exactly. MagicTeX picks it up on its own — no configuration:

macOSMacTeX
Linuxtexlive-full, via your package manager
WindowsTeX Live, or MiKTeX plus Strawberry Perl

latexmk is what MagicTeX looks for on PATH, but it isn't something you install on its own — it's a driver script that comes inside the distributions above. Check with latexmk -version, not which latexmk: latexmk is a Perl script, and MiKTeX puts latexmk.exe on your PATH without shipping a Perl to run it with — so the file is found and still cannot execute. On macOS you may need eval "$(/usr/libexec/path_helper)" or a fresh terminal first.

Every compile tells you which one ran — xelatex · system or xelatex · wasm.

Development

bash
npm installnpm run typecheck    # tsc for the server and the UInpm run build:ui     # build the React workspace to ui/distnpm test             # the unit suite — engine-free, no browser, secondsnpm start            # run the server on stdio (for a manual MCP client)

Two tiers, on purpose. npm test covers the comment store, anchor matching, line and column geometry, the history repo, asset paths, compile-log classification, the preview server's shutdown, and an MCP workflow E2E — all without a browser or a TeX engine, so it stays fast and deterministic. CI (.github/workflows/ci.yml) runs typecheck + UI build + that suite on Node 20 and 22 for every push and pull request.

The things a unit test structurally cannot see — highlight geometry at several zoom levels, what a failed render actually tells the reader, whether shutting down closes the server and warns any open window — live in scripts/smoke-*.mjs and run against a real browser and a real compile in .github/workflows/smoke-macos.yml. Each of those exists because something shipped broken that the unit suite was green through. Please keep both green and add coverage with changes.

Documentation

  • User guide — everyday use, the comment loop, Visual mode, the file tree, getting your paper into Overleaf, package coverage.
  • The agent loop — comments as triggers, running it hands-off with /loop, the reviewer → gate → resolver workflow, and ⚡ /ultra-agents.
  • Roadmap — what's shipped for concurrent agents, and what real parallel multi-agent editing still needs.
  • Architecture — why a headless browser, what every module does, the compile flow.

All four are translated into the same 8 languages as this README — each page has its own language switcher at the top.

Roadmap

Multiple Claude Code sessions can already work the same project concurrently without corrupting comments or the checkpoint history (see docs/ROADMAP.md) — true parallel multi-agent editing (reviewer/author/defender on their own git branches, merged back together) is the next milestone.

Sponsor this project

MagicTeX is free and open source (AGPL-3.0). If it saves you time on your papers, please consider sponsoring the project — it funds continued development. A ⭐ on the repo helps too.

Acknowledgements

MagicTeX is written and maintained by Zoe Lin, built with Claude Code.

Thanks to David Turnbull, who told me the story of Knuth spending ten years building his own typesetter rather than accept how his book looked — the story this project keeps arguing with. And to the maintainers of texlyre-busytex, without whose WASM TeX Live none of this would run locally at all.

License

AGPL-3.0-or-later — matching the texlyre-busytex engine it builds on. See THIRD_PARTY_NOTICES.md.

來源:README.md,提交 b1e5dae

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.10最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分