latexmk-mcp
An MCP server that exposes LaTeX compilation, log parsing, dependency inspection, and citation checking as tools for AI agents, using latexmk under the hood.
README
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 texlive
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-mcp
Global 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 path
Then 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.js
Tools
latexmk_compile
Full compile of a LaTeX document with configurable engine, output format, bibliography processor, and latexmk flags.
| Parameter | Type | Default | Description |
|---|---|---|---|
tex_content |
string | — | Raw LaTeX source (mutually exclusive with file_path) |
file_path |
string | — | Path to existing .tex file |
output_format |
pdf|dvi|ps|xdv |
pdf |
Target format |
engine |
pdflatex|xelatex|lualatex|latex|pdftex |
pdflatex |
TeX engine |
bibtex |
bibtex|biber|none |
none |
Bibliography processor |
shell_escape |
boolean | false |
Enable --shell-escape |
synctex |
boolean | false |
Generate SyncTeX data |
extra_args |
string[] | [] |
Extra latexmk CLI flags |
working_dir |
string | temp dir | Build directory |
return_pdf |
boolean | false |
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 |
|---|---|---|---|
tex_content |
string | — | Raw LaTeX source |
file_path |
string | — | Path to .tex file |
engine |
string | pdflatex |
TeX engine |
working_dir |
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 |
|---|---|---|---|
working_dir |
string | required | Directory to clean |
job_name |
string | — | Clean a specific job only |
clean_all |
boolean | false |
-C instead of -c |
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 |
|---|---|---|
tex_content |
string | Raw LaTeX source |
file_path |
string | Path to .tex file |
working_dir |
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
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。