latex-workspace-mcp
Provides tools for managing local LaTeX projects, including scanning project structure, reading and editing .tex files, compiling with latexmk, analyzing build logs, checking citations and labels, validating image assets, and verifying generated PDFs.
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., "@latex-workspace-mcpScan my LaTeX project and show the main file, figures, and citations."
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.
LaTeX Workspace MCP
Restricted Model Context Protocol tools for local LaTeX projects. The server lets an AI assistant inspect a configured workspace, make narrow .tex edits, compile with a fixed latexmk command, and verify that the generated PDF and image assets are usable.
Features
Scan LaTeX projects and infer the main file, engine, bibliography mode, included files, figure references, citations, and labels.
Read
.texfiles, create or overwrite.texfiles only with explicit overwrite approval, and replace exactly one unique text occurrence.Compile a selected main file with
pdflatexorxelatexthroughlatexmkinto the document-localbuild/directory.Analyze build logs for errors, warnings, undefined references, and undefined citations.
Check citation keys, duplicate labels, undefined labels, and figure path existence.
Validate image assets before a build with
validate_latex_assets, including reachable\input/\includefiles, first-page PDF metadata, dimensions for PNG/JPEG/PDF assets, and similar-path suggestions.Verify generated PDFs with
verify_latex_pdf, including MIME type, page count, page sizes, and embedded image metadata frompdfimages.Run the full asset-check, build, and PDF-verification flow with
build_and_verify_latex.Use either stdio MCP for local editors or Streamable HTTP MCP for ChatGPT-style clients.
Related MCP server: chatgpt-codex-tools-mcp
Security Model
Every path is resolved under the configured
--rootdirectory. Paths outside the root are rejected.Write tools only accept project-relative
.texfiles. There is no delete, rename, arbitrary shell, or generic file-write API.write_tex_filerefuses to overwrite existing files unlessoverwrite: trueis supplied.replace_tex_textrequires one exact unique match. Empty, missing, or multiple matches are rejected.Compilation uses a fixed
latexmkcommand withshell: false, disabled shell escape, bounded output, and build artifacts underbuild/.The HTTP server requires an API key from
LATEX_MCP_API_KEY_FILEand accepts eitherAuthorization: Bearer ...orX-API-Key.The HTTP server binds to
127.0.0.1by default and allows onlylocalhost,127.0.0.1host headers unlessLATEX_MCP_ALLOWED_HOSTSis set.
Requirements
Node.js 20 or newer.
TeX Live or another LaTeX distribution with
latexmk,pdflatex, and optionallyxelatex.PDF utilities:
file,pdfinfo, andpdfimages.
On Debian or Ubuntu, the PDF utilities are usually provided by file and poppler-utils.
Install
git clone https://github.com/YOUR_GITHUB_USER/latex-workspace-mcp.git
cd latex-workspace-mcp
npm installUse an absolute project root when starting either server:
node server.mjs --root /path/to/latex/projectStdio MCP
Use stdio when the MCP client launches local commands directly.
{
"mcpServers": {
"latex-workspace": {
"command": "node",
"args": ["/path/to/latex-workspace-mcp/server.mjs", "--root", "/path/to/latex/project"]
}
}
}HTTP MCP
Create an API key file with permissions limited to the service user:
install -d -m 700 ~/.config/latex-workspace-mcp
openssl rand -base64 48 > ~/.config/latex-workspace-mcp/api-key
chmod 600 ~/.config/latex-workspace-mcp/api-keyStart the loopback HTTP server:
LATEX_MCP_API_KEY_FILE="$HOME/.config/latex-workspace-mcp/api-key" \
LATEX_MCP_HTTP_HOST=127.0.0.1 \
LATEX_MCP_HTTP_PORT=8787 \
LATEX_MCP_ALLOWED_HOSTS=localhost,127.0.0.1 \
node http-server.mjs --root /path/to/latex/projectThe MCP endpoint is http://127.0.0.1:8787/mcp. Unauthenticated calls should return 401.
If you put a trusted reverse proxy in front of the server, keep the origin private and set LATEX_MCP_ALLOWED_HOSTS to the exact host headers your proxy sends.
systemd
Copy examples/latex-mcp-http.service.example and replace YOUR_PROJECT_ROOT with the absolute LaTeX workspace root. Keep LATEX_MCP_HTTP_HOST=127.0.0.1 when the proxy runs on the same machine.
ChatGPT Prompt Pattern
Use a prompt that keeps edits precise and makes the verification flow explicit:
Use the LaTeX Workspace MCP for this project. Before changing figure paths, call validate_latex_assets with the project-relative main_file. For source edits, prefer replace_tex_text and only use write_tex_file with overwrite: true when I explicitly ask for a full-file replacement. After any document or image-path change, call build_and_verify_latex. If the build fails, use analyze_log and validate_latex_assets to make the smallest precise repair.For projects with multiple main.tex files, always pass a project-relative main_file, such as paper/main.tex.
Image And First-Page Validation Workflow
Put images under the configured project root and reference them with paths relative to the main file directory.
Call
validate_latex_assetsbefore compiling. Missing\includegraphicsassets stopbuild_and_verify_latexbefore LaTeX runs.For PNG and JPEG assets, the tool reports dimensions from the file header.
For PDF assets, the tool calls
pdfinfoand reports first-page page-size metadata without extracting binary content.After compilation, call
verify_latex_pdforbuild_and_verify_latexto confirm the expectedbuild/<stem>.pdfexists, has pages, and lists embedded images.
Tool Summary
get_project_infoscan_projectanalyze_logcheck_citationscheck_labelscheck_figuresvalidate_latex_assetsverify_latex_pdfbuild_and_verify_latexlist_tex_filesread_tex_filewrite_tex_filereplace_tex_textcompile_latex
License
MIT
This server cannot be deployed
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.
Your org's AI agents, tasks, runs, search, and brain files as MCP tools and resources.
Browse and manage files in your Moxt AI workspace from any MCP client.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that exposes LaTeX compilation, log parsing, dependency inspection, and citation checking as tools for AI agents, using latexmk under the hood.116 npm1MIT
- AlicenseNot gradedqualityAmaintenanceEnables ChatGPT to inspect and edit local projects through a secure MCP interface, offering workspace management, file operations, git integration, and safe command execution.5MIT
- FlicenseNot gradedqualityCmaintenanceEnables 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.-
- AlicenseBqualityCmaintenanceCompiles LaTeX resumes into PDFs via MCP tools, including validation, preview, template compilation, and LaTeX export, with security defaults like path isolation and no shell escapes.7MIT