Get the FREE Ultimate OpenClaw Setup Guide →

mcp-latex

A comprehensive Model Context Protocol (MCP) server that provides advanced LaTeX file creation, editing, and management capabilities for Large Language Models and AI assistants.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio robertodure-mcp-latex-server python latex_server.py \
  --env LATEX_BASE_PATH="<path-to-your-latex-files>"

How to use

The MCP LaTeX Server provides tools to create, edit, read, and manage LaTeX documents through the MCP interface. It supports document classes such as article, report, book, letter, beamer, and a minimal class, along with automatic package handling and basic syntax validation. You can ask Claude or your MCP client to create new LaTeX files from templates, edit existing files with operations like replace, insert, or append, and list or read files from configured base directories. The server exposes a simple set of commands via MCP that let you specify the target file, document type, title, author, and content sections, as well as a range of common LaTeX packages and settings. For integration with Claude Desktop or VS Code, point the MCP configuration to the latex_server.py script and set the base path where your LaTeX files live. This enables AI-assisted document generation and editing directly within your editor or Claude workflow.

How to install

Prerequisites:

  • Python 3.8+ installed on your system
  • A LaTeX distribution installed (MiKTeX/TeX Live for Windows, MacTeX for macOS, TeX Live for Linux)
  • Optional: VS Code and Claude Desktop or Claude integration setup

Method 1: Quick Setup (Recommended)

  1. Clone or download the repository:
git clone https://github.com/RobertoDure/mcp-latex-server
cd mcp-latex-server
  1. Run the setup script to install dependencies:
python setup.py

Method 2: Manual Installation

  1. Create a virtual environment (recommended):
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS/Linux
source .venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Verify installation:
python latex_server.py --help

Method 3: Using uv (Fast Python Package Manager) - optional for performance

  1. Install uv if not already installed:
pip install uv
  1. Install dependencies with uv:
uv pip install -r requirements.txt

Configure and run the server after installation by pointing to your latex files directory with LATEX_BASE_PATH and starting latex_server.py. You can adjust the base path, logging level, and other options via environment variables or a config.json as described in the README.

Additional notes

Tips and common considerations:

  • LATEX_BASE_PATH controls where the server reads and writes LaTeX files. Set it to a safe, writable directory, and consider using a dedicated project folder structure.
  • LATEX_LOG_LEVEL can be set to DEBUG, INFO, WARNING, or ERROR to control verbose output.
  • The server supports a configuration file (config.json) to specify allowed extensions, maximum file size, validation options, default document class, and default packages.
  • When integrating with Claude Desktop, ensure the cwd points to the server directory and the env var LATEX_BASE_PATH is correctly set to your LaTeX workspace path.
  • Basic syntax validation is provided, but it is not a full compiler. Always run a full latex build locally to confirm compilation results.
  • If using beamer or other special document classes, verify that required packages are installed in your LaTeX distribution.
  • For Windows paths in Claude config, escape backslashes or use forward slashes as appropriate, and ensure the path exists.

Related MCP Servers

Sponsor this space

Reach thousands of developers