
带MCP接口的LaTeX文档编译器——AI代理通过结构化模型编写文档,TeXFlow负责LaTeX机制
概览
一个带有MCP接口的LaTeX文档编译器。AI代理运行在结构化文档模型上——包括章节、段落、图表——而TeXFlow则处理所有LaTeX机制:包、前言、字体和编译。 TeXFlow 使用 XeLaTeX 将文档编译成 PDF。没有它,你仍然可以构建和导出.tex文件。 页面预览(PNG)请安装poppler-utils(提供pdftoppm)。 就这些。重启Claude代码,工具就能用了。 要设置工作区目录(存放文档的地方): TeXFlow 有两个条目流,都汇聚在同一内存文档模型上: 1. — document(action=“create”) 构建一个空文档骨架。通过 edit(action=“insert”)添加内容。2. — document(action=“ingest”, source=“paper.md”)解析 markdown 到模型中。从这里细化布局。 该模型会自动保存为 JSON 格式到磁盘。LaTeX 永远只是输出的产物——你永远不会直接编辑.tex。
概述(AI 翻译)
一个带有MCP接口的LaTeX文档编译器。AI代理运行在结构化文档模型上——包括章节、段落、图表——而TeXFlow则处理所有LaTeX机制:包、前言、字体和编译。
安装
或者不安装:
系统依赖(可选)
TeXFlow 使用 XeLaTeX 将文档编译成 PDF。没有它,你仍然可以构建和导出 .tex 文件。
页面预览(PNG)时,安装 poppler-utils(提供 pdftoppm。
用Claude代码配置
就这些。重启Claude代码,工具就能用了。
要设置工作区目录(存放文档的地方):
使用 Claude Desktop 配置
补充你的claude_desktop_config.json:
它是如何运作的
TeXFlow 有两个条目流,都汇聚在同一内存文档模型上:
- 脚手架 —
document(action="create")构建一个空白的文档骨架。用edit(action="insert")添加内容。 - Markdown 导入 —
document(action="ingest", source="paper.md")将 markdown 解析到模型中。从这里细化布局。
模型会自动保存为 JSON 格式到磁盘。LaTeX 永远只是输出伪造物——你永远不会直接编辑 .tex。
工具
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
TeXFlow MCP
A LaTeX document compiler with an MCP interface. AI agents operate on a structured document model — sections, paragraphs, figures, tables — while TeXFlow handles all LaTeX mechanics: packages, preamble, fonts, and compilation.
Install
pip install texflow-mcp
Or run without installing:
uvx texflow-mcp
System dependencies (optional)
TeXFlow compiles documents to PDF using XeLaTeX. Without it, you can still build and export .tex files.
# Arch
pacman -S texlive-xetex texlive-fontsrecommended texlive-fontsextra
# Debian/Ubuntu
apt install texlive-xetex texlive-fonts-recommended texlive-fonts-extra
# Fedora
dnf install texlive-xetex texlive-collection-fontsrecommended texlive-collection-fontsextra
For page preview (PNG), install poppler-utils (provides pdftoppm).
Configure with Claude Code
claude mcp add texflow -- uvx texflow-mcp
That’s it. Restart Claude Code and the tools are available.
To set a workspace directory (where documents are saved):
claude mcp add texflow -- uvx texflow-mcp ~/Documents/TeXFlow
Configure with Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"texflow": {
"command": "uvx",
"args": ["texflow-mcp"]
}
}
}
How it works
TeXFlow has two entry flows, both converging on the same in-memory document model:
- Scaffold —
document(action="create")builds an empty document skeleton. Add content withedit(action="insert"). - Markdown ingest —
document(action="ingest", source="paper.md")parses markdown into the model. Refine layout from there.
The model auto-saves to disk as JSON. LaTeX is only ever an output artifact — you never edit .tex directly.
Tools
| Tool | Purpose |
|---|---|
document |
Create, ingest markdown, show outline, read sections |
layout |
Columns, fonts, paper, margins, headers/footers, TOC |
edit |
Insert, replace, delete, move blocks (section, paragraph, figure, table, code, equation, list, raw) |
render |
Compile to PDF, preview page as PNG, export .tex |
reference |
Search LaTeX commands, symbols, packages, error help |
queue |
Batch multiple operations in one call |
Every response includes a workflow state hint showing where you are and what to do next.
Example session
> document(action="create", title="My Paper", document_class="article")
> queue(operations=[
{"tool": "edit", "action": "insert", "block_type": "section", "title": "Introduction", "level": 1},
{"tool": "edit", "action": "insert", "content": "This paper explores...", "section": "Introduction"},
安装
uvx texflow-mcp配置
{
"mcpServers": {
"texflow": {
"command": "uvx",
"args": ["texflow-mcp"]
}
}
}