apolosan/latex-pdf-mcp-server
3.2
If you are the rightful owner of latex-pdf-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The LaTeX PDF MCP Server is a robust solution for compiling LaTeX templates into PDF files, optimized for integration with n8n workflows.
LaTeX PDF MCP Server
MCP (Model Context Protocol) server for compiling LaTeX templates to PDF files, designed for seamless integration with n8n workflows.
Features
- ✅ Complete LaTeX Distribution - TeXLive Full with 6000+ packages
- ✅ Universal Document Support - Books, presentations, posters, magazines, spreadsheets, banners
- ✅ Advanced Graphics - TikZ/PGF diagrams, plots, circuits, chemical structures
- ✅ Professional Typography - Multiple font collections and international language support
- ✅ Dynamic Templates - Parameter substitution with LaTeX special character escaping
- ✅ Multiple Compilers - pdflatex, xelatex, lualatex with automatic selection
- ✅ Scientific Publishing - Mathematical formulas, bibliographies, complex tables
- ✅ Business Documents - Reports, invoices, presentations with corporate branding
- ✅ Educational Materials - Slides, handouts, exams, academic papers
- ✅ Marketing Materials - Flyers, banners, brochures, catalogs
- ✅ Docker Optimized - 5GB container with pre-compiled formats for fast startup
- ✅ n8n Integration - Seamless workflow integration via REST API
Quick Start
Development
# Install dependencies
npm install
# Start development server
npm run dev
# Test compilation
curl -X POST http://localhost:3000/api/compile \
-H "Content-Type: application/json" \
-d '{
"template": "\\documentclass{article}\\begin{document}Hello {{name}}!\\end{document}",
"parameters": {"name": "World"}
}'
Production (Docker)
# Build and run
npm run build
docker-compose up -d
# Health check
curl http://localhost:3000/api/health
API Endpoints
POST /api/compile
Compile LaTeX template to PDF.
Request:
{
"template": "\\documentclass{article}\\begin{document}Hello {{name}}!\\end{document}",
"parameters": {
"name": "World"
},
"compiler": "pdflatex",
"filename": "output.pdf"
}
Response:
{
"success": true,
"filename": "output.pdf",
"size": 12345,
"data": "base64-encoded-pdf-content",
"contentType": "application/pdf"
}
GET /api/health
Check server and LaTeX availability.
Response:
{
"status": "ok",
"version": "1.0.0",
"latex": {
"available": true,
"compilers": ["pdflatex", "xelatex", "lualatex"]
},
"uptime": 3600
}
n8n Integration
- Add HTTP Request node to your workflow
- Configure:
- Method: POST
- URL:
http://your-server:3000/api/compile
- Body: JSON with template and parameters
- Add Save Binary Data node to handle PDF output
Example n8n Workflow
{
"nodes": [
{
"name": "LaTeX Compiler",
"type": "n8n-nodes-base.httpRequest",
"parameters": {
"url": "http://latex-server:3000/api/compile",
"method": "POST",
"jsonParameters": true,
"options": {},
"bodyParametersJson": {
"template": "\\documentclass{article}\\begin{document}Invoice for {{customerName}}\\end{document}",
"parameters": {
"customerName": "{{$json.customer}}"
}
}
}
}
]
}
Template Syntax
Use {{variableName}}
syntax for dynamic content:
\documentclass{article}
\begin{document}
\title{{{title}}}
\author{{{author}}}
\date{{{date}}}
\maketitle
{{content}}
\end{document}
Development Scripts
npm run dev
- Start development server with hot reloadnpm run build
- Build TypeScript to JavaScriptnpm run start
- Start production servernpm run test
- Run testsnpm run lint
- Lint code
Docker Commands
npm run docker:build
- Build Docker imagenpm run docker:run
- Run containerdocker-compose up -d
- Start with composedocker-compose --profile dev up
- Start development mode
Environment Variables
PORT
- Server port (default: 3000)NODE_ENV
- Environment (development/production)
Requirements
- Node.js 18+
- LaTeX distribution (TeXLive recommended)
- Docker (for containerized deployment)
License
MIT