Labsco
RobertoDure logo

MCP LaTeX Server

โ˜… 16

from RobertoDure

Create, edit, and manage LaTeX files. Requires an external LaTeX distribution like MiKTeX, TeX Live, or MacTeX.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

MCP LaTeX Server

A Model Context Protocol (MCP) server for LaTeX file creation, editing, validation, and compilation. Built with FastMCP and Pydantic for type-safe, structured output.

Features

  • Create LaTeX documents from parameters or bundled templates (article, beamer, report)
  • Edit files with replace, insert, append, and prepend operations
  • Read and list .tex files within a secure base directory
  • Validate syntax โ€” braces, environments, references, required declarations
  • Compile to PDF with pdflatex, xelatex, or lualatex
  • Resources โ€” browse and retrieve bundled templates via latex:// URIs

Tools

create_latex_file

Create a new LaTeX document from parameters.

ParameterTypeDefaultDescription
file_pathstrrequiredPath for the new .tex file
document_typearticle|report|book|letter|beamer|minimalarticleDocument class
titlestr""Document title
authorstr""Document author
datestr\todayDocument date
contentstr""Body content
packageslist[str][]Extra LaTeX packages
geometrystr""Geometry settings (e.g. margin=1in)

create_from_template

Create a document from a bundled template.

ParameterTypeDefaultDescription
file_pathstrrequiredPath for the new .tex file
templatearticle|beamer|reportarticleTemplate name

edit_latex_file

Edit an existing LaTeX file.

ParameterTypeDefaultDescription
file_pathstrrequiredPath to the file
operationreplace|insert_before|insert_after|append|prependrequiredEdit operation
new_textstrrequiredText to insert or replace with
search_textstr|nullnullText to find (required for replace/insert)
line_numberint|nullnull1-based line number (alternative to search_text)

read_latex_file

Read and return the contents of a .tex file.

ParameterTypeDefaultDescription
file_pathstrrequiredPath to the file

list_latex_files

List all .tex files in a directory.

ParameterTypeDefaultDescription
directory_pathstr.Directory to search
recursiveboolfalseSearch subdirectories

validate_latex

Check LaTeX syntax: required declarations, balanced braces, environment matching, undefined references.

ParameterTypeDefaultDescription
file_pathstrrequiredPath to the file

get_latex_structure

Extract document structure: class, title, author, packages, and section hierarchy.

ParameterTypeDefaultDescription
file_pathstrrequiredPath to the file

compile_latex

Compile a .tex file to PDF (runs the engine twice for references/TOC).

ParameterTypeDefaultDescription
file_pathstrrequiredPath to the file
enginepdflatex|xelatex|lualatexpdflatexLaTeX engine

Resources

URIDescription
latex://templatesList available bundled templates
latex://template/{name}Get the content of a specific template

Testing

Test with the MCP Inspector:

uv run mcp dev latex_server.py

Or run the included test suite:

python test_server.py