\begin{article}
FormaTeX MCP Server: LaTeX Compilation for AI Agents
FormaTeX v1.4 introduces an MCP server that lets AI agents compile LaTeX, check engine availability, and monitor usage — directly from Claude Desktop, Cursor, and other MCP clients.

AI agents are increasingly capable of generating documents, writing reports, and producing structured output. But generating a PDF requires compilation infrastructure that most AI agents do not have access to. FormaTeX v1.4 introduces an MCP (Model Context Protocol) server that gives AI agents direct access to LaTeX compilation — no custom integration required.
What Is MCP?
The Model Context Protocol (MCP) is an open standard for connecting AI models to external tools and data sources. Instead of building custom API integrations for every tool, MCP provides a standardized interface that any compatible AI client can use.
MCP clients include:
- Claude Desktop — Anthropic's desktop application for Claude
- Cursor — AI-powered code editor
- Any MCP-compatible client — the protocol is open and growing
When you connect FormaTeX as an MCP server, your AI agent can compile LaTeX, check available engines, and monitor usage — all through natural language.
FormaTeX MCP Tools
The FormaTeX MCP server exposes three tools:
compile_latex
Compiles LaTeX source code into a PDF.
Parameters:
content(string) — the LaTeX source codeengine(string, optional) —pdflatex,xelatex,lualatex, orlatexmk
Returns: The compiled PDF binary, or an error with the TeX compilation log.
list_engines
Lists all LaTeX engines available on your current plan.
Returns: An array of engine names with their descriptions and availability status.
get_usage
Returns your current compilation usage and plan limits.
Returns: Current month's compilation count, AI request count, plan limits, and remaining quota.
Setup for Claude Desktop
Add the FormaTeX MCP server to your Claude Desktop configuration:
{
"mcpServers": {
"formatex": {
"command": "npx",
"args": ["-y", "@formatex/mcp-server"],
"env": {
"FORMATEX_API_KEY": "fxk_your_api_key_here"
}
}
}
}After restarting Claude Desktop, you can ask Claude to compile LaTeX directly:
"Compile this LaTeX document into a PDF:
\documentclass{article}\begin{document}Hello from MCP!\end{document}"
Claude will use the compile_latex tool to compile the document and return the PDF.
Setup for Cursor
Add the FormaTeX MCP server to your Cursor settings:
{
"mcpServers": {
"formatex": {
"command": "npx",
"args": ["-y", "@formatex/mcp-server"],
"env": {
"FORMATEX_API_KEY": "fxk_your_api_key_here"
}
}
}
}Now Cursor can compile LaTeX as part of code generation workflows — generate a report template, compile it, and verify the output all in one conversation.
Example AI Workflows
AI-Generated Reports
Ask your AI agent to produce a complete PDF report from data:
"Here is this month's sales data: [data]. Generate a LaTeX report with a summary table and compile it to PDF."
The agent:
- Writes the LaTeX source with proper tables and formatting
- Calls
compile_latexto produce the PDF - Returns the compiled document
Research Assistants
AI agents can compile academic papers, check for errors, and iterate:
"Take this draft paper and compile it. If there are errors, fix them and recompile."
The agent:
- Calls
compile_latexwith the draft - If compilation fails, reads the error log
- Fixes the LaTeX source
- Recompiles until successful
Developer Copilots
When generating code that includes PDF output, the AI can verify the LaTeX compiles:
"Generate a TypeScript function that builds a LaTeX invoice and compile a sample to make sure it works."
The agent:
- Writes the TypeScript code with a LaTeX template
- Extracts the LaTeX template
- Calls
compile_latexto verify it compiles - Returns verified, working code
Use Cases
| Scenario | How MCP helps |
|---|---|
| Report generation | Agent writes LaTeX and compiles in one step |
| Document QA | Agent compiles, checks output, iterates |
| Template development | Agent builds and tests LaTeX templates interactively |
| Research automation | Agent compiles papers as part of a research pipeline |
| Education | Agent creates worksheets, exams, handouts on demand |
Why MCP Instead of Direct API Calls?
MCP provides several advantages over having the AI agent make raw HTTP calls:
- No prompt engineering — the agent discovers tools automatically via MCP
- Type safety — MCP schemas define parameters and return types
- Credential management — API keys are configured once in the MCP server, not passed in prompts
- Tool discovery — the agent can call
list_enginesandget_usageto understand its capabilities before compiling
The FormaTeX MCP server uses your existing API key and plan. Compilations through MCP count against the same monthly quota as direct API calls. Use get_usage to check your remaining quota before batch operations.
Get Started
- Try the Playground — test LaTeX compilation without an account
- Sign up for free — 15 compilations/month, includes MCP access
- API documentation — complete endpoint reference
- Pricing — Pro, Max, and Enterprise plans
\end{article}
\related{posts}




