Skip to main content
Glama

TeXFlow MCP

License PyPI Python

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).

Related MCP server: MagicTeX MCP Server

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:

  1. Scaffold — document(action="create") builds an empty document skeleton. Add content with edit(action="insert").

  2. 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"},
    {"tool": "edit", "action": "insert", "block_type": "section", "title": "Methods", "level": 1},
    {"tool": "layout", "font": "palatino", "columns": 2}
  ])

> render(action="compile")

Development

git clone https://github.com/aaronsb/texflow-mcp
cd texflow-mcp
uv sync
uv run pytest tests/ -v    # 222 tests
uv run texflow              # Start MCP server

License

MIT

Available Tools

6 tools
documentB

Create, ingest, and inspect documents.

Actions:

  • create: Scaffold a new empty document. Optionally set class, title, author.

  • ingest: Parse markdown text, .tex file, or .md file into the document model.

  • outline: Show document structure (sections, block counts).

  • read: Read content of a specific section as prose text.

  • update: Update document metadata (title, author, date, abstract).

  • reset: Clear the current document and saved state. Next create/ingest starts fresh.

  • bib_add: Add a bibliography entry (provide BibTeX-format entry as source).

  • bib_remove: Remove a bibliography entry by key (provide key as source).

  • bib_list: List all bibliography entries.

  • bib_style: Set bibliography style (provide style name as source, e.g. "authoryear", "numeric").

Inputs: action (required), document_class, title, author, +4 more. Returns: result

editC

Manipulate document content structurally.

Actions:

  • insert: Add a new block at a position within a section.

  • replace: Replace a block at a position with new content.

  • delete: Remove a block at a position.

  • move: Move a block from one location to another.

  • read_raw: Read a RawLatex block with line numbers.

  • replace_raw: Update a RawLatex block (full or line-level) with lint check.

Sections are addressed by title path (e.g., 'Methods/Data Collection'). Blocks within a section are addressed by 0-based index.

page_break: For sections — "before", "after", "both", or "" to clear. Emits \clearpage before/after the section.

Inputs: action (required), block_type, section, position, +14 more. Returns: result

layoutB

Configure document typesetting and layout.

Only provided parameters are changed; others are left as-is.

section_break: Page break before level-1 sections. "before" inserts \clearpage before each \section. Works in any column mode. Individual sections can override via edit(page_break="before").

Inputs: columns, font, font_sans, font_mono, +15 more. Returns: result

queueA

Execute multiple operations in a single call.

Each operation is a dict with 'tool' (document, layout, edit, render, reference) plus the arguments for that tool. Operations run sequentially; disk is written once at the end.

Example: queue(operations=[ {"tool": "document", "action": "create", "title": "My Doc"}, {"tool": "edit", "action": "insert", "block_type": "section", "title": "Intro", "level": 1}, {"tool": "edit", "action": "insert", "content": "Hello world.", "section": "Intro"}, {"tool": "layout", "columns": 2, "font": "palatino"} ])

Args: operations: List of operation dicts. continue_on_error: If False (default), stop on first error.

Inputs: operations (required), continue_on_error. Returns: result

referenceA

Search LaTeX documentation, symbols, packages, and error solutions.

Actions:

  • search: Search for LaTeX commands or general topics.

  • symbol: Find symbols by description (e.g., "approximately equal").

  • package: Get information about a LaTeX package.

  • check_style: Analyze a .tex file for best practices.

  • error_help: Get help for LaTeX error messages.

  • example: Get working examples for a topic (table, equation, figure, list, code).

  • templates: Browse available LaTeX templates. Optionally filter by category or slug.

  • capabilities: Enumerate system LaTeX support (engines, tools, packages).

  • styles: Browse document style presets. Optionally filter by slug or keyword.

Inputs: action (required), query, description, name, +3 more. Returns: result

renderA

Compile and export the document.

Actions:

  • compile: Serialize model to .tex, compile to PDF. Returns PDF path.

  • preview: Render a specific page as PNG file. Returns file path and dimensions.

  • tex: Export the raw .tex source. Returns the LaTeX content.

Inputs: action (required), output_path, page, dpi. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: document management, structural editing, layout, queued operations, reference, and rendering. Even within document and edit, actions are well-separated with no overlap.

    Naming Consistency5/5

    All tool names are lowercase descriptive nouns (document, edit, layout, queue, reference, render) and actions follow a consistent verb_noun pattern (e.g., create, ingest, bib_add, insert, replace). No naming irregularities.

    Tool Count5/5

    6 top-level tools with well-organized sub-actions cover the full LaTeX workflow without being excessive. The count is appropriate for the domain, avoiding both sparse and bloated tool sets.

    Completeness5/5

    The tool set provides comprehensive coverage: document creation/ingestion, structural editing, layout configuration, batched operations, reference lookup, and full compilation pipeline (PDF/preview/TeX). No obvious gaps for a typical writing session.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers