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 comprehensive Model Context Protocol (MCP) server that provides advanced LaTeX file creation, editing, and management capabilities for Large Language Models and AI assistants.
Overview
The MCP LaTeX Server enables AI assistants like Claude to seamlessly work with LaTeX documents through a standardized protocol. It provides tools for creating, editing, reading, and validating LaTeX files, making it easy to generate professional academic papers, reports, presentations, and other LaTeX documents.
Features
π Create LaTeX Documents: Generate new LaTeX files from templates or custom specifications
βοΈ Edit Existing Files: Modify LaTeX documents with various edit operations
π Read File Contents: Access and analyze LaTeX file content
π File Management: List and organize LaTeX files in directories
β Syntax Validation: Basic LaTeX syntax checking and error detection
π― Document Types: Support for article, report, book, letter, beamer, and minimal document classes
π¦ Package Management: Automatic handling of LaTeX packages and dependencies
π§ Template System: Built-in templates for common document types
Prerequisites
Before installing the MCP LaTeX Server, ensure you have:
Python 3.8+ installed on your system
LaTeX Distribution (recommended for full functionality):
Windows: MiKTeX or TeX Live
macOS: MacTeX
Linux: TeX Live
VS Code (for VS Code integration)
Claude Desktop or Claude in VS Code (for Claude integration)
Installing LaTeX Distribution
Windows (MiKTeX)
Download MiKTeX from https://miktex.org/download
Run the installer and follow the setup wizard
Choose "Install packages on-the-fly" for automatic package management
Windows (TeX Live)
Download TeX Live from https://www.tug.org/texlive/
Run the installer (this may take some time as it's a large distribution)
macOS
# Using Homebrew
brew install --cask mactex
# Or download directly from https://www.tug.org/mactex/Linux (Ubuntu/Debian)
sudo apt-get update
sudo apt-get install texlive-fullLinux (Fedora/RHEL)
sudo dnf install texlive-scheme-fullInstallation
Method 1: Quick Setup (Recommended)
Clone or download the repository:
git clone https://github.com/RobertoDure/mcp-latex-server
cd mcp-latex-serverRun the setup script:
python setup.pyThis will automatically install all required dependencies.
Method 2: Manual Installation
Create a virtual environment (recommended):
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS/Linux
source .venv/bin/activateInstall dependencies:
pip install -r requirements.txtVerify installation:
python latex_server.py --helpMethod 3: Using uv (Fast Python Package Manager)
Install uv (if not already installed):
pip install uvInstall dependencies with uv:
uv pip install -r requirements.txtConfiguration
Basic Configuration
The server can be configured to work with specific directories for LaTeX files. By default, it allows access to the current working directory and subdirectories.
Environment Variables
You can set the following environment variables:
# Set the base path for LaTeX files
export LATEX_BASE_PATH="/path/to/your/latex/files"
# Set logging level
export LATEX_LOG_LEVEL="INFO" # DEBUG, INFO, WARNING, ERRORConfiguration File
Create a config.json file in the server directory:
{
"base_path": "/path/to/your/latex/files",
"allowed_extensions": [".tex", ".sty", ".cls", ".bib"],
"max_file_size": "10MB",
"enable_validation": true,
"default_document_class": "article",
"default_packages": [
"amsmath",
"amsfonts",
"amssymb",
"graphicx",
"hyperref"
]
}MCP Integration
Claude Desktop Integration
Locate Claude Desktop Configuration:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
Add MCP Server Configuration:
{
"mcpServers": {
"latex-server": {
"command": "python",
"args": [
"C:\\path\\to\\mcp-latex-server\\latex_server.py"
],
"env": {
"LATEX_BASE_PATH": "C:\\path\\to\\your\\latex\\files"
},
"cwd": "C:\\path\\to\\mcp-latex-server"
}
}
}For uv (recommended for better performance):
{
"mcpServers": {
"latex-server": {
"command": "uv",
"args": [
"--directory",
"C:\\path\\to\\mcp-latex-server",
"run",
"latex_server.py"
],
"env": {
"LATEX_BASE_PATH": "C:\\path\\to\\your\\latex\\files"
},
"cwd": "C:\\path\\to\\mcp-latex-server"
}
}
}Restart Claude Desktop for changes to take effect.
VS Code Integration with Claude
Install the Claude extension in VS Code
Configure MCP Server in VS Code settings:
Open VS Code settings (Ctrl+, or Cmd+,) and add:
{
"claude.mcpServers": {
"latex-server": {
"command": "python",
"args": ["C:\\path\\to\\mcp-latex-server\\latex_server.py"],
"cwd": "C:\\path\\to\\mcp-latex-server",
"env": {
"LATEX_BASE_PATH": "${workspaceFolder}"
}
}
}
}Alternative: Using tasks.json
Create .vscode/tasks.json in your workspace:
{
"version": "2.0.0",
"tasks": [
{
"label": "Start LaTeX MCP Server",
"type": "shell",
"command": "python",
"args": ["C:\\path\\to\\mcp-latex-server\\latex_server.py", "--base-path", "${workspaceFolder}"],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "new"
},
"isBackground": true,
"problemMatcher": []
}
]
}Testing the Integration
Start Claude Desktop or Claude in VS Code
Test the connection by asking Claude:
Can you list the available LaTeX tools?Create a test document:
Please create a simple LaTeX article with the title "Test Document" and some sample content.
Usage Examples
Basic Document Creation
# Example interaction with Claude
"Create a LaTeX article titled 'My Research Paper' with author 'John Doe' and include sections for Introduction, Methodology, Results, and Conclusion."Advanced Document Creation
# Creating a complex document
{
"name": "create_latex_file",
"arguments": {
"file_path": "research_paper.tex",
"document_type": "article",
"title": "Advanced Machine Learning Techniques",
"author": "Jane Smith",
"date": "\\today",
"packages": ["amsmath", "amsfonts", "graphicx", "booktabs", "hyperref"],
"geometry": "margin=1in",
"content": "\\section{Introduction}\nThis paper explores...\n\n\\section{Methodology}\nWe employed..."
}
}Editing Operations
# Replace content
{
"name": "edit_latex_file",
"arguments": {
"file_path": "document.tex",
"operation": "replace",
"search_text": "\\section{Old Section}",
"new_text": "\\section{New Section}"
}
}
# Insert content
{
"name": "edit_latex_file",
"arguments": {
"file_path": "document.tex",
"operation": "insert_after",
"search_text": "\\section{Introduction}",
"new_text": "\nThis section provides an overview of the research topic."
}
}
# Append content
{
"name": "edit_latex_file",
"arguments": {
"file_path": "document.tex",
"operation": "append",
"new_text": "\n\\section{Conclusion}\nIn conclusion, this study demonstrates..."
}
}Available Tools
1. create_latex_file
Creates a new LaTeX document with specified parameters.
Parameters:
file_path(required): Path where the file should be createddocument_type: Document class (article, report, book, letter, beamer, minimal)title: Document titleauthor: Document authordate: Document date (default: \today)packages: List of LaTeX packages to includegeometry: Page geometry settingscontent: Main document content
2. edit_latex_file
Edits an existing LaTeX file with various operations.
Parameters:
file_path(required): Path to the file to editoperation(required): Type of edit (replace, insert_before, insert_after, append, prepend)new_text(required): New text to insert or replace withsearch_text: Text to search for (required for replace, insert_before, insert_after)line_number: Line number for insertion (alternative to search_text)
3. read_latex_file
Reads and returns the contents of a LaTeX file.
Parameters:
file_path(required): Path to the file to read
4. list_latex_files
Lists all LaTeX files in a directory.
Parameters:
directory_path: Directory to search (default: current directory)recursive: Whether to search subdirectories (default: false)
5. validate_latex
Performs basic LaTeX syntax validation.
Parameters:
file_path(required): Path to the file to validate
6. get_latex_structure
Extracts the structure of a LaTeX document (sections, subsections, etc.).
Parameters:
file_path(required): Path to the file to analyze
Troubleshooting
Common Issues
1. Server Won't Start
# Check Python version
python --version # Should be 3.8+
# Check dependencies
pip list | grep mcp
# Run with debug logging
python latex_server.py --log-level DEBUG2. Claude Can't Connect to Server
Verify the file paths in your configuration are correct
Check that Python is in your system PATH
Restart Claude Desktop after configuration changes
Check Claude Desktop logs for error messages
3. Permission Errors
# Windows: Run as administrator if needed
# macOS/Linux: Check file permissions
chmod +x latex_server.py4. LaTeX Compilation Issues
Ensure LaTeX distribution is properly installed
Check that required packages are available
Use the validation tool to check syntax
Debug Mode
Run the server in debug mode for detailed logging:
python latex_server.py --log-level DEBUG --base-path /your/latex/pathLog Files
Check log files for troubleshooting:
Server logs: Available in console output
Claude Desktop logs: Check Claude's log directory
VS Code logs: Check VS Code's output panel
Advanced Configuration
Custom Templates
Create custom templates in the templates/ directory:
% templates/custom_article.tex
\documentclass[12pt]{article}
\usepackage{your_custom_packages}
\title{{{TITLE}}}
\author{{{AUTHOR}}}
\date{{{DATE}}}
\begin{document}
\maketitle
{{{CONTENT}}}
\end{document}Security Considerations
The server only allows access to specified directories
File operations are limited to LaTeX-related extensions
Input validation prevents malicious LaTeX code execution
Performance Optimization
Use SSD storage for LaTeX files
Keep LaTeX distribution up to date
Use
uvinstead ofpipfor faster dependency management
Contributing
Contributions are welcome! Please follow these guidelines:
Fork the repository
Create a feature branch
Add tests for new functionality
Update documentation
Submit a pull request
License
This project is licensed under the MIT License. See the LICENSE file for details.
Support
For support and questions:
Check the troubleshooting section above
Review GitHub issues
Create a new issue with detailed information about your problem
Changelog
Version 1.0.0
Initial release
Basic LaTeX file operations
MCP integration support
Template system
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.