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 "Install 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 ServerCreate 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: LaTeX PDF 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
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/RobertoDure/mcp-latex-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server