mcp-latex
# mcp-latex
**A Model Context Protocol (MCP) server for LaTeX.** Give an AI assistant (Claude
Desktop, Claude Code, Cursor…) the ability to **check your LaTeX document**, **parse
compiler logs**, and **compile** — so it can actually fix your thesis or paper instead
of guessing. Static analysis works with **no TeX install required**.
🌍 **[English](README.md)** · [Português](README.pt.md) · 📚 [Documentation](docs/README.md)
<p align="center"><img src="assets/demo.svg" alt="mcp-latex tool calls: check_document and parse_log" width="100%"></p>
[](https://github.com/marcelogdomingues/mcp-latex/actions/workflows/ci.yml)
[](https://www.npmjs.com/package/mcp-latex)
[](LICENSE)
[](https://modelcontextprotocol.io)
## Tools
| Tool | Description |
| --- | --- |
| `check_document` | Static analysis: undefined refs, duplicate/unused labels, unbalanced environments; lists labels/refs/citations. **No TeX needed.** |
| `parse_log` | Turns a `.log` into structured errors, warnings, undefined refs/citations, over/underfull boxes. |
| `compile` | Compiles a `.tex` with `latexmk`/`pdflatex` if installed; returns parsed errors (graceful if no engine). |
## Use with Claude Desktop / Claude Code
```json
{
"mcpServers": {
"latex": { "command": "npx", "args": ["-y", "mcp-latex"] }
}
}
```
Then ask: *"Check my thesis for undefined references and unbalanced environments,"* or
*"Compile main.tex and fix the first error."*
## Why
Writing a thesis in LaTeX means fighting cryptic compiler errors, dangling `\ref`s and
`\begin`/`\end` mismatches. An AI assistant is great at fixing these — **if** it can
see the actual errors. This server gives it structured eyes on your document. Built
from the pain of writing a real master's thesis.
## Run locally
```bash
npm install
npm start # stdio server
npm test # unit + stdio integration tests
npm run build # tsc -> dist/
```
Try it with the MCP Inspector:
```bash
npx @modelcontextprotocol/inspector npx -y mcp-latex
```
## License
MIT © Marcelo Domingues
TDQS
Scored across 3 tools
The three tools are largely distinct: check_document performs static analysis, parse_log consumes a log file, and compile invokes an external engine. There is minor overlap in that both check_document and parse_log can report undefined references/citations, but the input source (source file vs. log file) clarifies the intended use.
Two tools use the verb_noun pattern (check_document, parse_log), while compile uses a bare verb. This is a minor deviation from an otherwise consistent naming style, but the intent is still clear.
With only 3 tools, the server is well-scoped for LaTeX document validation and compilation. Each tool serves a distinct and necessary function without redundancy or bloat.
The toolset covers the core workflow of checking source, compiling, and parsing logs. Minor gaps exist, such as no tool for cleaning auxiliary files or managing bibliographies, but these are not essential for the server's stated purpose.