LaTeX MCP
Compiles and inspects LaTeX projects using the local TeX Live installation, providing tools to check the TeX environment, resolve package files with kpsewhich, run latexmk/pdfLaTeX builds, and clean generated outputs.
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 MCP Compile main.tex in D:\paper and show me any errors."
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 MCP
LaTeX MCP is a local stdio Model Context Protocol server for compiling and inspecting LaTeX projects with TeX Live on Windows or MacTeX on macOS. It is intended for Claude Code and OpenAI Codex in VS Code, but any MCP client that supports local stdio servers can use it.
The server selects the platform's explicit TeX installation: C:\texlive\2025\bin\windows on Windows and /Library/TeX/texbin from MacTeX on macOS. It never enables shell escape and does not expose package installation.
Architecture
VS Code client
-> platform virtualenv Python server.py (MCP over stdio)
-> Windows: build-latex.ps1 -> TeX Live latexmk/pdflatex
-> macOS: MacTeX latexmk/pdflatexThe MCP repository owns the protocol surface, tests, and an MCP-local minimal English format configuration. TeX Live/MacTeX is a machine dependency. The PowerShell wrapper remains the Windows low-level build entry point; macOS invokes MacTeX's latexmk directly.
Manuscript repositories do not need copies of server.py, .venv, or this repository. Tools accept an explicit absolute project_dir, so the MCP server process does not need to start in the manuscript workspace. If project_dir is empty, CLAUDE_PROJECT_DIR is used when available.
Related MCP server: mcp-overleaf-server
Prerequisites and setup
Python 3.11 or newer.
Windows: TeX Live 2025 at
C:\texlive\2025and the build wrapper atC:\tools\latex\build-latex.ps1.macOS: MacTeX installed through Homebrew; its command-line tools must be available at
/Library/TeX/texbin.
macOS
Install Python, MacTeX, and the MCP package with:
brew install python
brew install --cask mactex
python3 -m venv .venv
.venv/bin/python -m pip install -e ".[test]"MacTeX provides pdflatex, latexmk, kpsewhich, bibtex, biber, and tlmgr through /Library/TeX/texbin. Verify the installation before registering the MCP server:
/Library/TeX/texbin/pdflatex --version
/Library/TeX/texbin/latexmk --version
/Library/TeX/texbin/kpsewhich IEEEtran.clsIf /Library/TeX/texbin is not present in a GUI-launched client's environment, restart the client after installing MacTeX. The server prepends this directory itself when it runs TeX tools.
Windows — TeX Live 2025
On Windows 11 if you don't have it yet, you can follow these steps from admin powershell:
Install/update git
winget install --id Git.Git -eInstall/update Python 3.12
winget install --id Python.Python.3.12 -eInstall/update cURL
winget install --id cURL.cURL -eUse
cURLto install TeX Live 2025 installer/follow instructions thereafter:
$repo = "https://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2025/tlnet-final"
$installer = "$env:TEMP\install-tl-2025.exe"
curl.exe -L "$repo/install-tl-windows.exe" -o "$installer"
& $installer -repository $repoIn the TeX Live installer, select Advanced and configure:
Scheme: small Installation root: C:\texlive\2025 Default paper size: Letter
Source and documentation installation can also be disabled if you want to minimize the installation size.
Complete the TeX Live installation.
Install the additional packages required by LaTeX_MCP
After the base installation succeeds:
$tlmgr = "C:\texlive\2025\bin\windows\tlmgr.bat"
& $tlmgr --repository $repo install `
ieeetran `
latexmk `
microtype `
amsmath `
amsfonts `
mathtools `
siunitx `
booktabs `
tools `
makecell `
algorithms `
algorithmicx `
pgf `
xcolor `
dblfloatfix `
hyperref `
placeins `
preprint `
cm-supertlmgr automatically resolves and installs dependencies required by these packages.
Verify the installation
$bin = "C:\texlive\2025\bin\windows"
& "$bin\pdflatex.exe" --version
& "$bin\latexmk.exe" --version
& "$bin\tlmgr.bat" --version
& "$bin\kpsewhich.exe" IEEEtran.cls
& "$bin\kpsewhich.exe" tikz.sty
& "$bin\kpsewhich.exe" siunitx.sty
& "$bin\kpsewhich.exe" algpseudocode.styVerify the default paper configuration with:
& "$bin\tlmgr.bat" paperIf necessary, explicitly set Letter afterward:
& "$bin\tlmgr.bat" paper letterThe resulting installation should reside at:
C:\texlive\2025and the executables used by LaTeX_MCP should come explicitly from:
C:\texlive\2025\bin\windowsrather than from MiKTeX or another TeX distribution on PATH.
Installation from Repo
On Windows, create or refresh the isolated environment from this repository:
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install ".[test]"Dependencies are pinned in pyproject.toml; no global Python install is required. The MCP SDK range is mcp>=1.29.0,<2 for the FastMCP server and icon metadata API, and the test pin is pytest==8.4.2.
On macOS, use the POSIX virtual-environment path:
python3 -m venv .venv
.venv/bin/python -m pip install ".[test]"An editable install also exposes helper console scripts for registration. On Windows:
.\.venv\Scripts\python.exe -m pip install -e .On macOS:
.venv/bin/python -m pip install -e .Script | Scope | Purpose |
| — | Run the stdio MCP server (same as invoking |
| Project | Generate project-local config for one VS Code repository. |
| User | Register the server in the global user Claude and Codex config. |
Both registration scripts resolve this repository's platform-specific .venv interpreter and server.py automatically (override with --python / --server), and every file they touch is reconciled in place: an existing latex entry is replaced rather than duplicated. Pass --dry-run to preview.
On Windows, the protected TeX Live tree may not contain a writable texmf-dist\ls-R filename database. The server handles that state by configuring read-only Kpathsea disk searches and user-scoped formats/maps. The MCP-local texmf directory supplies a minimal US-English format configuration; it does not change manuscript sources. MacTeX normally manages its own filename database.
Tools
Tool | Arguments | Result and behavior |
| None | Reports exact TeX Live roots, binary paths, versions, BibTeX/Biber availability, wrapper availability, and filename-database state. |
|
| Resolves a simple TeX filename using the explicit TeX Live |
|
| Runs the known wrapper with pdfLaTeX/LatexMk, noninteractive file/line errors, halt-on-error, SyncTeX, and no shell escape. Output is bounded; the full |
|
| Runs LatexMk |
main_tex must resolve to a .tex file inside project_dir. Absolute paths, option-like names, missing files, and traversal outside the project are rejected. Subprocesses use argument arrays with shell=False.
Agent skill package and icon
The repository includes the latex-mcp skill in the formats used by OpenAI,
Muse, and Claude workflows:
skills/latex-mcp/is the canonical skill and OpenAI metadata package..agents/skills/latex-mcp/SKILL.mdis the Muse-compatible mirror..claude/skills/latex-mcp/SKILL.mdis the Claude Code mirror.
The skill package includes 512×512 and 96×96 PNG assets. The stdio
initialization handshake advertises the 96×96 asset as a PNG data URI through
the FastMCP mcp instance, so compatible clients can display the LaTeX MCP
icon without resolving a local filesystem path.
Resources
URI | MIME type | Purpose |
|
| Preferred baseline preamble for new 10-point IEEEtran journal manuscripts, including the documented mathematics, units, table, algorithm, TikZ, float, link, and balancing setup. |
Discover the template with MCP resources/list and fetch its text with resources/read. It is a starting point: add manuscript-specific packages after reviewing compatibility, and let repository or venue requirements override it. The resource ends before title metadata and \\begin{document}, so callers can append a project-specific body. Existing documents are not automatically rewritten to use it.
Development and tests
Launch the stdio server directly:
C:\MyRepos\Python\LaTeX_MCP\.venv\Scripts\python.exe C:\MyRepos\Python\LaTeX_MCP\server.pyThe terminal appears idle because it is waiting for MCP JSON-RPC on stdin. Diagnostics go to stderr; stdout is reserved for the protocol.
Run all automated unit, integration, and stdio protocol tests on Windows:
.\.venv\Scripts\python.exe -m pytest -qOn macOS:
.venv/bin/python -m pytest -qThe realistic IEEE smoke source is testdata\ieee_smoke\main.tex. Tests compile it with IEEEtran, algorithms, TikZ, siunitx, microtype, and the rest of the documented package stack, confirm PDF creation, and clean the generated output.
Registration
Project scope (one repository)
Run the generator from inside the repository you want to configure, or pass its path:
latex-mcp-vscode # configures the current directory
latex-mcp-vscode C:\MyRepos\Papers\MyPaperOn macOS, use the same installed command with POSIX paths:
latex-mcp-vscode
latex-mcp-vscode ~/Projects/Papers/MyPaperIt reconciles these local artifacts, upserting a single latex entry into each:
File | Client |
| Claude Code (project scope) |
| Codex (project-local) |
| VS Code native MCP client |
| Ignores the machine-specific local config above |
| Agent usage guidance and preferred IEEE style (managed block) |
| Human note describing what was generated and how to verify |
User scope (every project)
To register the server for all projects at once:
latex-mcp-installOn macOS:
latex-mcp-installIt upserts the latex entry into ~/.claude.json (mcpServers) and ~/.codex/config.toml ([mcp_servers.latex]), preserving unrelated servers and settings. On Windows, ~ is the user's %USERPROFILE% directory.
Claude Code registration (manual reference)
Claude Code's MCP documentation specifies that user-scoped MCP servers are stored at %USERPROFILE%\.claude.json. The latex entry belongs under the top-level mcpServers object:
{
"type": "stdio",
"command": "C:\\MyRepos\\Python\\LaTeX_MCP\\.venv\\Scripts\\python.exe",
"args": [
"C:\\MyRepos\\Python\\LaTeX_MCP\\server.py"
]
}This is user scope, so it is available in every Claude Code project. After configuration changes, reload the Claude Code VS Code session, open /mcp or the MCP management UI, and confirm that latex is connected and exposes four tools. The standalone claude CLI is not required.
Codex registration (manual reference)
OpenAI's MCP documentation specifies that the Codex IDE extension and CLI share %USERPROFILE%\.codex\config.toml. The user-level entry is:
[mcp_servers.latex]
command = "C:\\MyRepos\\Python\\LaTeX_MCP\\.venv\\Scripts\\python.exe"
args = ["C:\\MyRepos\\Python\\LaTeX_MCP\\server.py"]
cwd = "C:\\MyRepos\\Python\\LaTeX_MCP"
startup_timeout_sec = 15
tool_timeout_sec = 300
enabled = trueIn VS Code, open the Codex gear menu, select MCP servers, and restart the extension after configuration changes. Confirm that latex is enabled and connected. Codex's official documentation states that the IDE extension and CLI share config.toml; the standalone CLI is not required for normal extension use.
Example agent requests
For guidance on selectively turning substantive implementation concepts into repository-local technical notes, see the technical manuscript workflow.
From any unrelated manuscript repository, ask:
Use the latex MCP server to compile the manuscript in the current workspace. Find the main TeX file, compile it, inspect any errors, fix the errors, and recompile until the build succeeds.
For a precise call, provide the project path:
Use latex_build with project_dir="C:\MyRepos\Papers\MyPaper" and main_tex="main.tex".Troubleshooting
Call
latex_environmentfirst. On Windows, itspdflatex.pathmust be underC:\texlive\2025\bin\windowsand its version must containTeX Live 2025. On macOS, the path should be/Library/TeX/texbin/pdflatex(or its resolved MacTeX target) and the distribution should report MacTeX/TeX Live.Use
latex_find_file("package.sty")to distinguish a missing TeX package from a manuscript error. Package installation is intentionally not an MCP tool; maintain TeX Live separately with deliberatetlmgradministration.Review the returned error summary, then open the complete
.logat the returnedlog_path. MCP responses intentionally truncate large process output.A normal warning that shell escape is disabled confirms the intended security policy. Documents that require external shell commands must use a separately reviewed workflow.
If a client shows the server as disconnected, verify both absolute registered paths, run the test suite, then reload the relevant VS Code extension. Editing a configuration file alone does not prove extension connectivity.
The TeX Live tree on this machine is read-only and uses per-user formats/maps. After changing TeX Live format sources or font packages, rerun the appropriate user maintenance (
fmtutil-userorupdmap-user) before rebuilding.
Updating
Pull or edit this single repository, activate no global environment, and run:
.\.venv\Scripts\python.exe -m pip install --upgrade ".[test]"
.\.venv\Scripts\python.exe -m pytest -qOn macOS:
.venv/bin/python -m pip install --upgrade ".[test]"
.venv/bin/python -m pytest -qThe Claude and Codex registrations use stable absolute paths into this repository, so routine server updates do not require copying files or duplicating configuration in manuscript repositories.
Handoff MCP — session memory for agents
This repo has the handoff MCP server configured (see .mcp.json /
.codex/config.toml). It is a durable, project-scoped place to leave
breadcrumbs between sessions. Use it instead of re-deriving context.
At the start of a session, call handoff_list to reload where prior work
stopped and what to do next, and todo_list for outstanding next steps. This is
cheaper and more reliable than re-reading the whole transcript.
While working, when you find something that must be done but is not the
current focus, call todo_add rather than holding it in the conversation.
When context gets heavy (stale greps, large logs, finished sub-tasks pile
up), call context_report, then context_compact — it returns a
summarise-then-handoff procedure and can persist the summary as a handoff in one
call.
At the end of a work chunk, call handoff_add with a summary, next steps,
and the few key facts (file paths, decisions, gotchas) the next worker needs. A
fresh session can then resume from handoff_list alone.
Close the loop with todo_update (done/dropped) and handoff_resolve so
the open lists stay a true worklist.
Tool | Use it to |
| Reload breadcrumbs at session start. |
| Record where you stopped and what is next. |
| Mark a handoff done. |
| Track next-step TODOs. |
| Counts of open todos and handoffs. |
| Notice and shrink a bloated context window. |
Every tool is scoped to this project only; there is no way to reach another
project's data. Full reference: docs/TOOL_GUIDE.md.
Available Tools
4 toolslatex_buildA
Build a project with pdfLaTeX/LatexMk, no shell escape, and bounded diagnostics.
Inputs: main_tex, clean_first, project_dir. Returns: object
latex_cleanB
Remove only normal LatexMk-generated products for the selected main file.
Inputs: main_tex, project_dir. Returns: object
latex_environmentA
Report exact TeX Live 2025 binaries, versions, and supporting tools.
Inputs: no named parameters. Returns: object
latex_find_fileA
Resolve a simple TeX package or class filename with TeX Live kpsewhich.
Inputs: filename (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool targets a distinct concern: environment inspection, file resolution, compilation, and cleanup. There is no functional overlap between them.
All tools share the latex_ prefix and mostly use verb-led names like find_file, build, and clean. latex_environment is the only noun-based deviation but remains predictable in context.
Four tools form a tight, well-scoped set for LaTeX project workflows without redundancy or bloat. Each tool serves a clear purpose.
The set covers the main lifecycle of inspecting, resolving, building, and cleaning LaTeX projects. Minor gaps exist such as no explicit output preview or detailed log retrieval, but the core workflow is complete.
Maintenance
Related MCP Connectors
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.
Persistent AI LaTeX workspace: edit and compile multi-file projects, export publication-ready PDFs.
Compile LaTeX to PDF without installing TeX Live. No API key needed to start.
Search arXiv/Semantic Scholar/OpenAlex + medical evidence (PubMed/Europe PMC) + LaTeX/PDF tools.
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.12MIT
- AlicenseAqualityCmaintenanceTailors LaTeX résumés, CVs, and cover letters to job descriptions by injecting truthfully-selected content from a master CV, compiling PDFs, and logging applications.111MIT
- AlicenseNot gradedqualityCmaintenanceProvides restricted MCP tools for scanning, editing, compiling, and verifying LaTeX workspaces, enabling AI assistants to manage local LaTeX projects safely.1MIT
- AlicenseNot gradedqualityCmaintenanceEnables local LaTeX project compilation with latexmk across pdflatex, xelatex, and lualatex, including bibliography processing and diagnostics, plus workspace file inspection and constrained PDF text extraction.MIT