
一个全面的模型上下文协议(MCP)服务器,为大型语言模型和人工智能助手提供先进的LaTeX文件创建、编辑和管理功能。
概览
一款用于 LaTeX 文件创建、编辑、验证和编译的模型上下文协议(MCP)服务器。采用 FastMCP 和 Pydantic 构建,实现类型安全、结构化输出。 - 从参数或捆绑模板(文章、beamer、报告)获取 LaTeX 文档——带有替换、插入、附加和前置操作的文件——以及安全基目录中的.tex文件 - 语法——大括号、环境、引用、所需声明——转为PDF,包含pdflatex、xelatex或lualatex - ——通过 latex:// URI浏览和检索捆绑模板 - - (编译用):- Windows:MiKTeX 或 TeX Live - macOS:MacTeX(brew 安装 --cask mactex) - Linux:sudo apt install texlive-full(Debian/Ubuntu)或 sudo dnf install texlive-scheme-full(Fedora) 它会检查 Python 版本,安装依赖,验证服务器导入正确,并可选配置 Claude Desktop。 服务器使用单一环境变量: 所有传递给工具的文件路径都是相对于该基础目录解析的。
概述(AI 翻译)
一款用于 LaTeX 文件创建、编辑、验证和编译的模型上下文协议(MCP)服务器。采用 FastMCP 和 Pydantic 构建,实现类型安全、结构化输出。
特色
- 从参数或捆绑模板(文章、beamer、报告)创建 LaTeX文档
- 编辑带有替换、插入、附加和前置操作的文件
- 读取并列表
.tex文件,存储在安全基目录中 - 验证语法 — 大括号、环境、引用、必需声明
- 编译为PDF,格式为
pdflatex、xelatex或lualatex - Resources — 通过
latex://URI浏览和检索捆绑模板
先修条件
- Python 3.11.9+
- LaTeX 发行版(用于编译):
- Windows:MiKTeX 或 TeX Live
- macOS:MacTeX (
brew install --cask mactex) - Linux:
sudo apt install texlive-full(Debian/Ubuntu)或sudo dnf install texlive-scheme-full(Fedora)
安装
使用紫外线(推荐)
使用 pip
快速设置(Windows)
它会检查 Python 版本,安装依赖,验证服务器导入正确,并可选配置 Claude Desktop。
配置
服务器使用单一环境变量:
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
MCP LaTeX Server
A Model Context Protocol (MCP) server for LaTeX authoring: create and edit documents, analyze multi-file projects, validate structure and references, run quality checks, inspect PDFs, and compile to PDF. Built with FastMCP/MCPServer and Pydantic for structured tool output.
Highlights
- Author article, report, book, letter, beamer, and minimal documents.
- Transact multiple edits atomically, snapshot and restore files, and edit named sections.
- Build custom templates with YAML metadata and double-brace variables.
- Analyze multi-file projects: includes, labels, references, bibliographies, and duplicate labels.
- Compile single files or whole projects with bibtex/biber sequencing, conditional reruns, timeouts, and optional latexmk.
- Check braces, environments, references, word counts, TODOs, chktex, latexindent, and spelling.
- Inspect PDF metadata, page counts, text, and optional page renders.
- Support MCP Python SDK 1.x and 2.x.
Requirements
- Python 3.11.9+
- MCP Python SDK 1.x or 2.x: mcp[cli]>=1.9.4
- LaTeX distribution for compilation only:
- Windows: MiKTeX or TeX Live
- macOS: MacTeX
- Linux: texlive-full or texlive-scheme-full
- Optional external tools, detected at runtime:
- chktex, latexindent, hunspell or aspell
- latexmk, bibtex, biber
- poppler utilities (pdftoppm) for PDF page rendering
- Python dependencies: pydantic, pyyaml, pypdf.
Editing, reading, listing, validation, project analysis, word counts, and PDF reading do not require LaTeX to be installed. Tools that need an external binary report available=false or a clear install hint instead of failing the server.
Installation
Using uv
git clone https://github.com/RobertoDure/mcp-latex-server
cd mcp-latex-server
uv venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
uv pip install -e ".[dev]"
Using pip
git clone https://github.com/RobertoDure/mcp-latex-server
cd mcp-latex-server
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS/Linux
source .venv/bin/activate
pip install -e ".[dev]"
Quick setup
python scripts/quick_setup.py
The setup script checks Python, installs dependencies, verifies the server, and optionally writes a Claude Desktop configuration. Existing configs are backed up and malformed JSON is left untouched.
Entry points
After installation, launch the server with any of:
mcp-latex-server
python -m mcp_latex_server
python latex_server.py # compatibility shim
The canonical packaged entry point is mcp-latex-server. The root latex_server.py stays as a compatibility shim for existing MCP client configurations.
Docker
A container image is included for the server runtime. It does not include a TeX distribution; extend the image or mount a TeX installation if you need compilation inside the container.
docker build -t mcp-latex-server .
docker run --rm -i \
安装
docker run --rm -i \配置
{
"mcpServers": {
"latex-server": {
"command": "uv",
"args": [
"--directory",
"/path/to/mcp-latex-server",
"run",
"mcp-latex-server"
],
"env": {
"LATEX_SERVER_BASE_PATH": "/path/to/your/latex/files"
}
}
}
}