MCP LaTeX Server
Provides comprehensive tools for creating, editing, and managing LaTeX documents, including document class customization, package management, and basic syntax validation.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP LaTeX Server Create a new article template for a research paper on machine learning."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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
.texfiles within a secure base directoryValidate syntax — braces, environments, references, required declarations
Compile to PDF with
pdflatex,xelatex, orlualatexResources — browse and retrieve bundled templates via
latex://URIs
Related MCP server: GoLatex MCP Server
Prerequisites
Python 3.11.9+
LaTeX distribution (for compilation):
Installation
Using uv (recommended)
git clone https://github.com/RobertoDure/mcp-latex-server
cd mcp-latex-server
uv pip install -e .Using pip
git clone <repository-url>
cd mcp-latex-server
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS/Linux
source .venv/bin/activate
pip install -e .Quick setup (Windows)
python quick_setup.pyThis checks Python version, installs dependencies, verifies the server imports correctly, and optionally configures Claude Desktop.
Configuration
The server uses a single environment variable:
Variable | Description | Default |
| Root directory for all file operations |
|
All file paths passed to tools are resolved relative to this base directory. Access outside it is denied.
MCP client configuration
Claude Desktop
Add to your claude_desktop_config.json:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"latex-server": {
"command": "uv",
"args": [
"--directory",
"/path/to/mcp-latex-server",
"run",
"latex_server.py"
],
"env": {
"LATEX_SERVER_BASE_PATH": "/path/to/your/latex/files"
}
}
}
}VS Code (GitHub Copilot)
Add to .vscode/mcp.json in your workspace:
{
"servers": {
"latex-server": {
"command": "uv",
"args": [
"--directory",
"/path/to/mcp-latex-server",
"run",
"latex_server.py"
],
"env": {
"LATEX_SERVER_BASE_PATH": "${workspaceFolder}"
}
}
}
}Tools
create_latex_file
Create a new LaTeX document from parameters.
Parameter | Type | Default | Description |
|
| required | Path for the new |
|
|
| Document class |
|
|
| Document title |
|
|
| Document author |
|
|
| Document date |
|
|
| Body content |
|
|
| Extra LaTeX packages |
|
|
| Geometry settings (e.g. |
create_from_template
Create a document from a bundled template.
Parameter | Type | Default | Description |
|
| required | Path for the new |
|
|
| Template name |
edit_latex_file
Edit an existing LaTeX file.
Parameter | Type | Default | Description |
|
| required | Path to the file |
|
| required | Edit operation |
|
| required | Text to insert or replace with |
|
|
| Text to find (required for replace/insert) |
|
|
| 1-based line number (alternative to |
read_latex_file
Read and return the contents of a .tex file.
Parameter | Type | Default | Description |
|
| required | Path to the file |
list_latex_files
List all .tex files in a directory.
Parameter | Type | Default | Description |
|
|
| Directory to search |
|
|
| Search subdirectories |
validate_latex
Check LaTeX syntax: required declarations, balanced braces, environment matching, undefined references.
Parameter | Type | Default | Description |
|
| required | Path to the file |
get_latex_structure
Extract document structure: class, title, author, packages, and section hierarchy.
Parameter | Type | Default | Description |
|
| required | Path to the file |
compile_latex
Compile a .tex file to PDF (runs the engine twice for references/TOC).
Parameter | Type | Default | Description |
|
| required | Path to the file |
|
|
| LaTeX engine |
Resources
URI | Description |
| List available bundled templates |
| Get the content of a specific template |
Testing
Test with the MCP Inspector:
uv run mcp dev latex_server.pyOr run the included test suite:
python test_server.pyTroubleshooting
Server won't start — Verify Python 3.10+ (python --version) and that mcp is installed (pip list | grep mcp).
Compilation fails — Ensure a LaTeX distribution is on your PATH (pdflatex --version). Install MiKTeX or TeX Live if missing.
"Access denied" errors — The requested file path resolves outside LATEX_SERVER_BASE_PATH. Use relative paths or adjust the env variable.
Claude can't connect — Double-check file paths in your MCP config, restart Claude Desktop, and verify with uv run mcp dev latex_server.py.
License
MIT
Available Tools
8 toolscompile_latexB
Compile a LaTeX file to PDF using the specified engine.
Inputs: file_path (required), engine. Returns: Result of LaTeX compilation.
create_from_templateB
Create a LaTeX document from a bundled template file.
Inputs: file_path (required), template. Returns: Result of a file operation.
create_latex_fileC
Create a new LaTeX document with specified content and structure.
Inputs: file_path (required), document_type, title, author, +4 more. Returns: Result of a file operation.
edit_latex_fileB
Edit an existing LaTeX file by replacing, inserting, or appending content.
Inputs: file_path (required), operation (required), new_text (required), search_text, +1 more. Returns: Result of a file operation.
get_latex_structureA
Extract document structure: class, title, author, packages, and section hierarchy.
Inputs: file_path (required). Returns: Extracted structure of a LaTeX document.
list_latex_filesB
List all .tex files in a directory.
Inputs: directory_path, recursive. Returns: Result of listing LaTeX files.
read_latex_fileB
Read and return the contents of a LaTeX file.
Inputs: file_path (required). Returns: Result of a file operation.
validate_latexB
Perform LaTeX syntax validation (structure, braces, environments, references).
Inputs: file_path (required). Returns: Result of LaTeX validation.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a clearly distinct purpose with no ambiguity: compile, create from template, create new file, edit file, get structure, list files, read file, and validate syntax. The descriptions reinforce unique functions, preventing misselection.
All tool names follow a consistent verb_noun pattern using snake_case (e.g., compile_latex, edit_latex_file). This predictability makes the set easy to navigate and understand.
With 8 tools, the server is well-scoped for LaTeX document management. Each tool earns its place by covering essential operations like creation, editing, reading, validation, and compilation without bloat.
The toolset provides strong coverage for core LaTeX workflows, including CRUD operations and validation. A minor gap is the lack of tools for managing bibliographies or handling complex LaTeX errors, but agents can work around this with existing tools.
Maintenance
Related MCP Connectors
Persistent AI LaTeX workspace: edit and compile multi-file projects, export publication-ready PDFs.
A hosted LaTeX editor your assistant can actually use. Search 1,019 free templates, create and edit projects, and compile them to PDF on a real TeX Live farm, getting back the PDF or the compile log when a build fails. Thirteen tools behind OAuth 2.1, with nothing to install and nothing to run locally.
Overleaf alternative online LaTeX editor. AI agents edit, comment, and chat. Keep or revert edits.
Write, compile and share Typst documents (papers, slides, drawings) from any AI agent.
1
Related MCP Servers
- AlicenseBqualityCmaintenanceEnables AI assistants to convert LaTeX source code into professionally formatted PDF documents with comprehensive error handling and local file generation capabilities.110 npm2MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to read, write, and compile LaTeX projects locally, view PDF pages as images, and manage project files, with live updates reflected in a web-based editor.-
- AlicenseAqualityBmaintenanceEnables AI agents to edit LaTeX documents with live PDF preview, commenting, and visual editing via the Model Context Protocol.7103 npmAGPL 3.0
- FlicenseNot gradedqualityAmaintenanceEnables AI models to work with a markup-based typesetting system by converting LaTeX snippets, validating syntax, browsing the documentation, and rendering code as PNG images. This lets assistants produce and verify typeset documents and illustrations before sharing them with users.-