SuperAPI AI Directory

latex-mcp-server

Compile LaTeX, download, organize and read cited papers, run visualization scripts and add figures and tables to LaTeX documents.

Open website

About this tool

latex-mcp-server is an MCP (Model Context Protocol) server designed to enhance the VSCode + LaTeX Workshop writing workflow. It currently contains a set of MCP tools and supports easily adding new tools via Python and TypeScript. The Python process acts as the MCP server, and some selected tools are delegated through a bridge to a small Node/TypeScript module.

Main capabilities

  • list_tex_files: Lists all .tex files (relative paths) under the LaTeX workspace, allowing the LLM or agent to discover available chapters and sections.
  • read_file: Reads text or binary-safe slices based on a relative path within the workspace, supporting a specified maximum number of bytes to return.
  • extract_bibliography: Parses a BibTeX file and returns structured entry metadata, including download URLs (DOI, arXiv), making it easy to process citation data programmatically.
  • download_bibliography: Downloads the reference PDFs listed in resources/cited_papers/index.json, can force re-downloading and limit the number of new downloads.
  • compile_latex: Runs LaTeX compilation via latexmk (pdflatex / xelatex), returns success or failure and log snippets, and supports specifying the entry .tex file and the number of compilation runs.
  • read_pdf: Uses pypdf to extract text and metadata from a PDF file path, supports page and character limits, and stores a JSON artifact for downstream use.
  • read_pdf_from_citation: Resolves the PDF corresponding to a citation key via resources/cited_papers/index.json and extracts text (automatically downloading if necessary), returning the extracted text, metadata, and citation key.
  • TypeScript bridge tools: summarize_text (generates a concise natural-language summary of the provided LaTeX or text content, with an optional maximum number of sentences), suggest_bib_key (suggests a stable BibTeX key based on author, year, and title metadata).

Usage Installation (using uv): After running the installation command in the repository root, the console script latex-mcp-server will appear in PATH. If you want to run it once without installing it as a tool, you can also invoke it directly.

MCP configuration snippet: Add to mcp.json (VS Code / Claude Desktop user settings). If --workspace is omitted, the server will infer the current working directory. Windows example: If the paper_1 root directory is located at C:\Users\User\projects\paper_1, you can use forward slashes to avoid escaping backslashes. Be sure to replace the placeholder ABSOLUTE_PATH_TO_YOUR_PAPER_1_ROOT.

Alternative: Install once and then invoke directly, which simplifies configuration.

Troubleshooting: If you modify the TypeScript source code, you need to rebuild and repackage before restarting the server (npm run build).

TypeScript bridge: The TypeScript source code is located at ts_functions/src, and the compiled JavaScript output is bundled into the Python package latex_mcp_server/ts_dist, so users do not need to install npm or tsc to run the server. To modify or add a TS function, you need to create a new file, add it to the export map, rebuild and sync the dist output, and then register the Python wrapper in server.py using bridge.register_ts_tool.

Adding a new Python tool: Add a function in latex_mcp_server/functions/latex_ops.py (or a new module), and register it in register_python_tools in server.py.

Citation-aware PDF reading: When the user asks about a paper (for example, "explain how \cite{smith2023model} differs from ..."), the agent should resolve the citation key, call read_pdf_from_citation for each key (fetch/download the PDF and extract text snippets and metadata), answer based on the extracted text (optionally calling summarize_text to generate a concise summary), and note whether the extraction was truncated (check the truncated flag), avoiding overclaiming beyond the available page/character range. read_pdf_from_citation returns the same schema as read_pdf, with an added citation_key, making it easy for multi-citation responses to correctly attribute snippets.

Automatically update index.json (chosen method: VS Code task): The project is configured to refresh resources/cited_papers/index.json using a VS Code task before every LaTeX build. A .vscode/tasks.json has been added, containing three tasks: update-index (runs a short Python one-liner that calls extract_bibliography to process src/references.bib), latex-build (calls latexmk -pdf on main.tex), and build+index (runs update-index and then latex-build in sequence). In VS Code, open the Command Palette and run "Tasks: Run Task", then select build+index (it is recommended to set it as the default build task when prompted). The BibTeX index will be regenerated first, followed by the LaTeX compilation. If LaTeX Workshop cannot import the package (ModuleNotFoundError), a helper script latex-mcp-server/update_index.py is provided. The workspace settings have been updated to call this script, so a local editable install is not strictly required.

Set as default build: When VS Code prompts you after the first run, accept setting build+index as the default. It can also be added to the workspace settings.

Why this method: no background watcher process; deterministic: index refresh is explicitly tied to the build command; minimal overhead (BibTeX parsing is fast compared to PDF compilation). If an alternative is needed later (such as a Makefile or on-demand freshness checks), it can still be layered on; the task method is non-intrusive.

Use cases

  • Work with tools such as Copilot, Claude, or Cursor to read cited papers to verify or supplement arguments.
  • Access Python scripts to generate new figures or LaTeX tables from experimental data and autonomously place them into LaTeX.
  • Verify each step and ensure the PDF compiles successfully.
  • Functionally, it can autonomously turn an outline and experimental results into a paper (though it may look formulaiccontent).

Limitations

  • The server follows the MCP JSON-RPC message schema; if the mcp Python package updates its API, the imports will need to be adjusted accordingly.
  • The quality of automatically converted papers may be unsatisfactory; the original text states "may looks like slop though".
  • No specific information is provided on other platform support, charging models, pricing, etc.