Skip to main content
Glama

LaTeX MCP Server

A Model Context Protocol (MCP) server for LaTeX compilation and document generation.

Features

  • LaTeX Compilation: Compile LaTeX source to PDF using various engines (pdflatex, xelatex, lualatex)

  • Template System: Manage reusable LaTeX templates

  • Snippets/Macros: Use predefined LaTeX components (equations, figures, multiple choice questions, etc.)

  • Automatic Cleanup: Old files are automatically cleaned up during compilation

  • Caching: Compiled documents are cached to avoid recompilation

  • Security: Dangerous LaTeX commands are blocked

Related MCP server: MCP Docling Server

MCP Tools

Core Tools

  • compile_latex - Compile LaTeX source to PDF

  • list_templates - List available LaTeX templates

  • get_template - Get template source code

Snippets System

  • list_snippets - List available LaTeX snippets/macros

  • get_snippet_info - Get detailed info about a snippet including parameters

  • render_snippet - Render a snippet with provided parameters

Available Snippets

  • multiple_choice - Creates multiple choice questions with 4 options

  • equation - Creates numbered equations with optional labels

  • figure - Creates figures with captions and optional labels

Installation

  1. Build the image:

docker build -f Dockerfile.simple -t mcp-latex-simple .
  1. Run the container:

docker run -d --name mcp-latex-server --restart unless-stopped -p 8083:8080 mcp-latex-simple

Manual Installation

  1. Install system dependencies:

# Install LaTeX sudo apt-get install texlive-latex-base texlive-fonts-recommended texlive-latex-extra # Install Python dependencies pip install fastmcp jinja2 pydantic pyyaml uvicorn
  1. Run the server:

python server.py

Configuration

Set environment variables:

  • PORT - Server port (default: 8080)

  • LATEX_BASE_URL - Base URL for compiled files

  • LATEX_MAX_FILE_AGE_HOURS - File cleanup age in hours (default: 24)

Usage with Claude

Configure Claude Desktop to connect to your MCP server:

  • URL: https://your-domain.com/

  • Transport: HTTP

API

The server exposes a Model Context Protocol interface on the configured port and path.

Security

  • Dangerous LaTeX commands are blocked

  • File system access is restricted

  • No shell escapes allowed during compilation

  • Automatic cleanup prevents disk space issues

Development

See the included configuration files:

  • docker-compose-standalone.yml - Docker Compose setup

  • mcp-latex.service - Systemd service

  • nginx-include.conf - Nginx configuration

-
security - not tested
F
license - not found
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TheTailorRetailored/latex-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server