\usepackage{mcp}
Connect Claude and other MCP-compatible AI agents to FormaTeX. Let your AI assistant write LaTeX and compile it to PDF — all within a single conversation, without leaving the chat interface.
\section{What is MCP}
AI-native tool use
MCP is an open protocol from Anthropic that lets LLMs discover and call external tools at inference time — no custom glue code required.
Standardised server API
An MCP server exposes a list of named tools with JSON Schema definitions. Any compatible client — Claude Desktop, Claude.ai, custom agents — can use them.
FormaTeX as a tool
The FormaTeX MCP server exposes a single compile_latex tool. Claude calls it with LaTeX source and receives a compiled PDF download URL.
End-to-end in one turn
Ask Claude to draft a report. Claude writes the LaTeX, calls compile_latex, and returns a link to the finished PDF — all in one conversation turn.
\section{Setup}
Add the FormaTeX MCP server to your Claude Desktop configuration file. On macOS the file is at ~/Library/Application Support/Claude/claude_desktop_config.json. On Windows: %APPDATA%\Claude\claude_desktop_config.json.
{
"mcpServers": {
"formatex": {
"command": "npx",
"args": ["-y", "@formatex/mcp-server"],
"env": {
"FORMATEX_API_KEY": "your-api-key"
}
}
}
}After saving the config
Restart Claude Desktop. You will see a hammer icon in the chat input confirming the FormaTeX server is connected. Replace your-api-key with a key from your FormaTeX dashboard.
\section{Tool Definition}
The FormaTeX MCP server exposes a single compile_latex tool. Below is the JSON Schema that Claude receives when it connects to the server.
# Tool definition exposed by the FormaTeX MCP server
COMPILE_LATEX_TOOL = {
"name": "compile_latex",
"description": (
"Compile a LaTeX document to PDF using the FormaTeX API. "
"Returns a temporary download URL valid for 10 minutes."
),
"input_schema": {
"type": "object",
"properties": {
"source": {
"type": "string",
"description": "Complete LaTeX source code including \\documentclass preamble.",
},
"engine": {
"type": "string",
"enum": ["pdflatex", "xelatex", "lualatex", "latexmk"],
"description": "LaTeX engine to use. Default: pdflatex.",
},
},
"required": ["source"],
},
}\section{Python Example}
You can also connect to the FormaTeX MCP server programmatically via the Anthropic Python SDK using the remote MCP client beta. The example below asks Claude to write and compile a technical report in a single API call.
import anthropic
client = anthropic.Anthropic()
# The MCP server exposes a compile_latex tool.
# Claude will call it automatically when asked to generate PDFs.
response = client.beta.messages.create(
model="claude-opus-4-5",
max_tokens=4096,
tools=[
{
"type": "computer_20241022",
"name": "computer",
}
],
mcp_servers=[
{
"type": "url",
"url": "https://mcp.formatex.io/sse",
"name": "formatex",
"authorization_token": "your-api-key",
}
],
messages=[
{
"role": "user",
"content": (
"Write a two-page technical report on gradient descent "
"with LaTeX math equations, then compile it to PDF."
),
}
],
betas=["mcp-client-2025-04-04"],
)
# Claude generates LaTeX, calls compile_latex, returns the PDF download URL
print(response.content)\section{Use Cases}
Research reports
Ask Claude to summarise a paper and compile a formatted PDF with equations, figures, and bibliography — all from one prompt.
Automated documentation
Integrate into CI/CD pipelines. Trigger Claude to generate release notes or API reference docs and compile them as PDFs automatically.
On-demand certificates
Generate personalised LaTeX certificates or invoices at scale. Claude fills the template, FormaTeX renders the PDF.
\end{mcp}
Get a FormaTeX API key, add the MCP server config, and start generating PDFs directly from Claude Desktop in minutes.
One quick thing
We track anonymous usage — page views, feature usage, compilation events — to understand what works and what doesn't. No ads, no personal data, no third-party sharing.