texstudio-mcp
MCP (Model Context Protocol) server over stdio for TeXstudio and LaTeX projects. It helps AI clients read and edit sources inside a project folder, run latexmk and bibliography tools, inspect logs, preview PDFs, use SyncTeX, run ChkTeX, and optionally read TeXstudio profile files on the host.
Version: see pyproject.toml or texstudio_mcp.__version__.
What it does
- Project sandbox: Paths are resolved under a
workspace_rootyou provide. Relative paths cannot escape the root (..and absolute paths are rejected). - Read & search: Read
.tex/.bib/etc., grep the tree, list LaTeX-related files, statically scan\input,\includegraphics, bibliographies, and more in a single.texfile. - Edit: Replace line ranges or write new files (UTF-8, LF).
- Build:
latexmk -pdf, plusbibtex/biberon a job basename, or a combined pipeline (latexmk → bib → optional extra latexmk passes). Heuristic.log/.blgparsing. - PDF & SyncTeX:
pdfinfometadata,pdftotextpreviews,synctex view/synctex editwhen those tools are onPATH. - Lint:
chktexon one file, a list of files, or all.texfiles discovered in the workspace. - TeXstudio hints (optional): Read
texstudio.iniorlastSession.txssfrom OS config locations — not part of the project sandbox. Useful forsuggested_job_basenamewhen orchestrating builds.
External commands (latexmk, pdflatex, bibtex, biber, pdfinfo, pdftotext, synctex, chktex) must be installed separately (e.g. TeX Live, MiKTeX, Poppler). The server only checks PATH and invokes them with timeouts and truncated output.
Install
- Python 3.10+
git clone https://github.com/ChenAI-TGF/texstudio-mcp.git
cd texstudio-mcp
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -e .
Optional BibTeX parsing via bibtexparser:
pip install -e ".[bibtex]"
Then use validate_bib_file(..., use_bibtexparser=true).
Run
python -m texstudio_mcp
Or, after install:
texstudio-mcp
Cursor configuration (example)
{
"mcpServers": {
"texstudio-mcp": {
"command": "c:\\Users\\YOU\\path\\to\\texstudio-mcp\\.venv\\Scripts\\python.exe",
"args": ["-m", "texstudio_mcp"],
"cwd": "c:\\Users\\YOU\\path\\to\\texstudio-mcp"
}
}
}
Use your actual clone path and venv python.exe.
Tool reference
Server & toolchain
Workspace paths
Read & analyze sources
Edit sources
Compile & bibliography
Concurrency: For a given workspace_root, only one of compile_latex_document, run_bibtex_on_job, run_biber_on_job, or compile_latex_then_run_bibliography_on_job runs at a time inside the same MCP process. A second call gets concurrent_workspace_exclusive_blocked. Separate MCP instances do not coordinate.
Bibliography files & PDF
ChkTeX
TeXstudio profile (host only)
Usage notes
workspace_root and main_tex
- If
workspace_rootis the folder that contains the main.tex, pass only the basename (e.g.paper.tex) — the server avoids redundantlatexmk -cd. - If
workspace_rootis the repository root, pass a relative path (e.g.chapters/paper.tex);latexmkruns in that subfolder via-cd.
Build time and logs
- Builds spawn real
latexmk/engine processes; wall time is often longer than a single IDE compile. Usewall_clock_msin the response. - Tool output is truncated for MCP JSON size; read full
.logfiles withread_project_file.
Limits
- Bibliography pipeline runs a bounded number of latexmk/bib cycles — not an open-ended “compile until done” loop.
- Profile and config reads access files outside your LaTeX project by design.
License
MIT — see LICENSE.