latexmk-mcp
Provides tools for compiling LaTeX documents, parsing logs, inspecting dependencies, checking citations, and managing build artifacts via latexmk.
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., "@latexmk-mcp compile report.tex to pdf"
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.
latexmk-mcp
A Model Context Protocol server for latexmk that exposes LaTeX compilation, log parsing, dependency inspection, citation checking, and other utilities as MCP tools for any compatible AI agent or client.
Prerequisites
Node.js 18+
latexmk on
$PATH— bundled with most TeX distributions (TeX Live, MiKTeX)A TeX distribution with the engines and packages your project requires
# Debian/Ubuntu
sudo apt install latexmk texlive-full
# macOS
brew install --cask mactex
# Arch Linux
sudo pacman -S texliveRelated MCP server: FastMCP LaTeX Server (tex-mcp)
Usage
Add this to your MCP client configuration:
{
"mcpServers": {
"latexmk": {
"command": "npx",
"args": ["-y", "latexmk-mcp"]
}
}
}The example above applies for clients such as Gemini CLI, Claude Code, etc. Additionally, some tools allow you to add MCP servers imperatively:
codex mcp add latexmk -- npx -y latexmk-mcpGlobal install via npm
Alternatively, you can install the package globally and invoke it directly without npx:
npm install -g latexmk-mcp
which latexmk-mcp # note the absolute pathThen point your MCP client at the local binary using node:
{
"mcpServers": {
"latexmk": {
"command": "node",
"args": ["/absolute/path/to/node/vX.Y.Z/bin/latexmk-mcp"]
}
}
}Development
bun install
bun test
bun run build
node dist/index.jsTools
latexmk_compile
Full compile of a LaTeX document with configurable engine, output format, bibliography processor, and latexmk flags.
Parameter | Type | Default | Description |
| string | — | Raw LaTeX source (mutually exclusive with |
| string | — | Path to existing |
|
|
| Target format |
|
|
| TeX engine |
|
|
| Bibliography processor |
| boolean |
| Enable |
| boolean |
| Generate SyncTeX data |
| string[] |
| Extra latexmk CLI flags |
| string | temp dir | Build directory |
| boolean |
| Return compiled PDF as base64 when building PDF output |
Returns: success, exit_code, output_file, page_count, structured errors[], structured warnings[], missing_packages[], install_hints[], working_dir, stdout, stderr, and optional pdf_base64.
latexmk_draft_compile
Fast single-pass compile (no reruns, no bibliography) — ideal for quick syntax/error checks while editing.
Parameter | Type | Default | Description |
| string | — | Raw LaTeX source |
| string | — | Path to |
| string |
| TeX engine |
| string | temp dir | Build directory |
Returns: success, structured errors[], structured warnings[], missing_packages[], install_hints[], stdout, stderr.
latexmk_clean
Remove build artifacts using latexmk -c (auxiliaries only) or latexmk -C (auxiliaries + output files).
Parameter | Type | Default | Description |
| string | required | Directory to clean |
| string | — | Clean a specific job only |
| boolean |
|
|
latexmk_check
Detect whether latexmk is installed and which TeX engines are available on the system.
Returns: latexmk_available, latexmk_version, latexmk_path, engines_available map.
latexmk_list_dependencies
List all file dependencies of a document (included .tex files, .bib files, packages, images…) via latexmk -deps.
Parameter | Type | Description |
| string | Raw LaTeX source |
| string | Path to |
| string | Working directory |
Returns: dependencies[] (deduplicated list of file paths).
latexmk_watch_start / latexmk_watch_stop / latexmk_watch_list
Manage background latexmk -pvc watch sessions. Start returns a session_id; stop terminates it; list shows active sessions with PID, job name, and start time.
latexmk_write_config / latexmk_read_config
Write or inspect .latexmkrc files. The write tool can set engine, output mode, shell escape, extra pdflatex args, and custom Perl rules.
latexmk_list_citations
Extract citation keys from LaTeX source and optionally compare them to a .bib file.
Returns: cited_keys[], cited_count, and when bib_path is provided, bib_entries[], missing_from_bib[], and unused_in_bib[].
License
MIT
Available Tools
11 toolslatexmk_checkA
Check whether latexmk is installed and which TeX engines are available on this system.
Inputs: working_dir.
latexmk_cleanA
Clean LaTeX build artifacts in a directory using latexmk -c (auxiliary files only) or latexmk -C (auxiliary + output files).
Inputs: working_dir (required), job_name, clean_all.
latexmk_compileB
Compile a LaTeX document using latexmk. Accepts raw LaTeX source or a path to an existing .tex file. Returns structured errors, warnings, missing package hints, page count, and the output file path.
Inputs: bibtex, engine, synctex, file_path, +6 more.
latexmk_draft_compileA
Run a fast single-pass draft compile to quickly surface errors without running multiple passes or bibliography. Good for syntax/error checking during editing.
Inputs: engine, file_path, tex_content, working_dir.
latexmk_list_citationsA
Extract all citation keys from a LaTeX document and optionally cross-reference them against a .bib file.
Inputs: bib_path, file_path, tex_content, working_dir.
latexmk_list_dependenciesA
List all file dependencies of a LaTeX document (included .tex files, .bib files, packages, images, etc.) using latexmk -deps.
Inputs: file_path, tex_content, working_dir.
latexmk_read_configA
Read the active .latexmkrc config files from the project and home directory.
Inputs: working_dir.
latexmk_watch_listA
List all currently active latexmk watch sessions.
Inputs: no named parameters.
latexmk_watch_startA
Start a background latexmk watch process (-pvc) that recompiles automatically on file changes. Returns a session_id.
Inputs: file_path (required), engine, working_dir.
latexmk_watch_stopA
Stop a running latexmk watch session by session_id.
Inputs: session_id (required).
latexmk_write_configB
Write a .latexmkrc config file to a project directory or globally to ~/.latexmkrc.
Inputs: working_dir (required), engine, global, custom_rules, +3 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Most tools have clearly distinct purposes: compile, draft_compile, watch operations, clean, check, dependencies, config, and citations. The only potential confusion is between latexmk_compile and latexmk_draft_compile, but their descriptions clarify draft as a quick single-pass syntax check vs. full compilation.
All tools share a latexmk_ prefix, but the verb/noun order is inconsistent: most use verb_noun (compile, clean, list_dependencies), while watch tools use noun_verb (watch_start, watch_stop, watch_list), and draft_compile uses an adjective-noun form. This mix is readable but not a uniform pattern.
With 11 tools, the server covers the full LaTeX latexmk workflow—compiling, watching, cleaning, dependency management, config, and citations—without bloat. Each tool addresses a distinct user need, making the count well-scoped for this domain.
The tool surface covers the essential lifecycle of LaTeX document processing: compile (draft and full), watch, clean, dependency resolution, config management, and citation checking. There are no obvious dead ends or missing operations for the announced purpose of a latexmk wrapper.
Maintenance
Related MCP Connectors
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
MCP server for agentverse documentation, generated by doc2mcp.
An MCP server that gives your AI access to the source code and docs of all public github repos
MCP server for progressive tool usage at any scale (see https://klavis.ai)
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceA real-time MCP server that enables AI coding agents to read, write, and compile LaTeX projects in self-hosted Overleaf instances via native OT protocol.420 npm16AGPL 3.0
- AlicenseNot gradedqualityDmaintenanceMCP server that renders LaTeX to PDF via pdflatex, supporting raw LaTeX and Jinja2 templates with artifact generation.11MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables LLMs to compile LaTeX documents and inspect the resulting PDF, supporting an autonomous write-compile-check-revise loop via a self-hosted Overleaf CLSI instance.1MIT
- AlicenseNot gradedqualityBmaintenanceMCP server for agentic-first PDF review of LaTeX papers, enabling commenting, compiling, and visual inspection via Claude Code.2,041 PyPI10MIT