ferritex-mcp

v0.1.0
ferritex-mcp Checked 1 day ago Published 3 days ago

Model Context Protocol server exposing FerriTeX LaTeX-to-PDF compilation to AI agents.

Turn LaTeX into PDF bytes. Leave TeX Live out of the deployment. Created by Rauhan Ahmed Siddiqui · GitHub Your notebook, CI job, or agent already has the LaTeX. It shouldn't need a system-wide typesetting installation just to render a résumé, a report, or an equation-rich handout. FerriTeX gives Python and Rust an in-process PDF pipeline, with a CLI for files and an MCP server for agent workflows. Same 50 generated reports, median of three warm runs on an Intel i7-9750H Mac. This compares workflows, not identical layouts. Method and reproduction.

Summary extracted from the README.

Your notebook, CI job, or agent already has the LaTeX. It shouldn't need a system-wide typesetting installation just to render a résumé, a report, or an equation-rich handout. FerriTeX gives Python and Rust an in-process PDF pipeline, with a CLI for files and an MCP server for agent workflows.

LaTeX in. PDF out.

from pathlib import Path

import ferritex

pdf = ferritex.compile(r"""
\documentclass{article}
\begin{document}
\section{Results}
The model predicts $E = mc^2$.
\end{document}
""")
Path("report.pdf").write_bytes(pdf)

compile() returns bytes; Python writes the file only if you ask it to. The fast engine converts a supported LaTeX subset through Tylax and Typst, using embedded New Computer Modern fonts. It does not start a TeX executable, write scratch files, or fetch packages.

Install

The Python packages require CPython 3.10+. Check Releases and the wheel workflow for platform availability. To build from this checkout:

python -m pip install .

Once published, use pip install ferritex for the default engine, pip install "ferritex[full]" for the optional companion, or pip install ferritex-mcp for the MCP server. Source builds require Rust; prebuilt wheels do not. See CONTRIBUTING.md for the native dependencies needed to build the companion from source.

Pick the engine that fits the document

Engine Use it for What to expect
fast Reports, résumés, and papers using supported LaTeX In-memory PDF bytes, embedded fonts, structured errors, and parallel batch rendering
full Documents that rely on native TeX behavior, such as TikZ Embedded Tectonic, no external TeX executable; uses disk and may fetch support files
auto Workflows that explicitly allow fallback Tries fast first and switches on a detected UnsupportedFeatureError, not on syntax failures

The fast path covers common titlesec and fancyhdr settings, scoped colors, side-by-side minipages, multicols, tabularx, compact lists, code listings, theorem blocks, and common siunitx commands. It embeds Inter and Font Awesome alongside New Computer Modern. The fixture gallery includes résumés, reports, and papers that exercise these features.

Fast mode supports the two-column, single-switch form of paracol; independent column streams and packages such as wrapfig, pdfpages, algorithm2e, and biblatex need the full engine. Package support is not a promise of complete TeX semantics or pixel parity, and not every unsupported construct is detected. For submission-critical documents, check the rendered output against your target engine.

If you can choose a new source format, Typst is a strong option in its own right. If you need TeX package semantics, use a native TeX engine. FerriTeX connects those options for teams that already have LaTeX and want a simple Python API, a low-latency path for compatible documents, and a native fallback they can opt into.

Use it in your workflow

Workflow Start here
Render one file ferritex compile paper.tex -o paper.pdf --engine fast
Render multiple files ferritex batch chapter1.tex chapter2.tex --outdir build
Get warnings and engine provenance ferritex.compile_detailed(source, engine="fast")
Render in parallel from Python ferritex.compile_batch([source_a, source_b])
Diagnose a document without writing a PDF ferritex.validate(source)
Connect an agent MCP setup and tools
Embed in Rust ferritex-core

For in-memory images and includes, pass a byte map such as assets={"figures/chart.png": chart_bytes}. compile_file and ferritex compile discover directly referenced local assets under the source directory, reject symlinks and out-of-root paths, and enforce a 50 MiB discovery budget. Use include_sibling_assets=False or --no-sibling-assets to disable discovery.

Safe deployment

The fast renderer's in-memory asset world is not a process sandbox. Isolate untrusted work with CPU, memory, and time limits. With MCP, set FERRITEX_MCP_OUTPUT_DIR to a dedicated output directory, use trusted clients, and restrict filesystem permissions. See SECURITY.md.

Contribute

Have a résumé template or report that doesn't render as expected? Open an issue with a minimal .tex example and the engine you used. If you can share the expected output, include it. See CONTRIBUTING.md and CHANGELOG.md.

FerriTeX code is MIT-licensed. Bundled fonts and dependencies retain their own terms; see the font notices.