typstgenv0.6.2

CASOON Open Source

Typst in, PDF out.

typstgen compiles .typ files to PDF with the Typst engine built in: no typst binary, no subprocess, and templates found through a config file instead of hardcoded paths. From the shell, from Rust, in the browser or from your AI agent.

cargo install typstgen
cargo add typstgen --no-default-features
claude mcp add typstgen -- typstgen mcp --root .
Terminal: grep template_paths typstgen.toml prints template_paths = ["templates"]. typstgen compile letter.typ prints letter.pdf. typstgen compile missing-import.typ fails with 'error: typst compilation failed: missing-import.typ:2:9: error: file not found (searched at /footer.typ)', and echo $? prints 1.
The top of letter.pdf as compiled: the sender line of the letterhead, the recipient Ada Example, the date 14 September 2026, the subject 'Your quote request' and a price table with a total of € 1,800.
letter.pdf, page 1
MITcrates.io 0.6.2Rust 1.92+Typst 0.15

Who it is for

typst binaries or subprocesses needed
0
ways in: CLI, Rust library, Wasm, MCP server
4
MCP tools, from check and preview to e-invoices
9
bundled font files, also in Wasm
17

How it works

You run typstgen compile, or your AI agent calls the MCP server. Either way the document goes to the Typst engine that is compiled into typstgen.

Imports are looked up next to the document first, then in the template directories listed in typstgen.toml. You get a PDF, or Typst’s error with its exact position and exit code 1.

How typstgen worksYou run typstgen compile, or an AI agent calls the MCP server started with typstgen mcp. Both hand the .typ file to the Typst engine compiled into typstgen, which resolves imports from the template directories in typstgen.toml. The result is a PDF next to the document, a PNG of one page for the MCP preview tool, or the Typst errors with file, line and column and exit code 1.How typstgen workstypstgen compile → Embedded TypstAI agent → typstgen mcptypstgen mcp → Embedded Typsttypstgen.toml → Embedded Typst: importsEmbedded Typst → PDF: compileEmbedded Typst → PNG page: previewEmbedded Typst → Errors: on failureimportscompilepreviewon failuretypstgen compile – CLItypstgen compileCLIAI agent – MCP clientAI agentMCP clienttypstgen mcp – check, preview, compiletypstgen mcpcheck, preview, compiletypstgen.toml – template_pathstypstgen.tomltemplate_pathsEmbedded Typst – typst 0.15, no subprocessEmbedded Typsttypst 0.15, no subprocessPDF – next to the .typ filePDFnext to the .typ filePNG page – preview toolPNG pagepreview toolErrors – file:line:column, exit 1Errorsfile:line:column, exit 1
How typstgen worksYou run typstgen compile, or an AI agent calls the MCP server started with typstgen mcp. Both hand the .typ file to the Typst engine compiled into typstgen, which resolves imports from the template directories in typstgen.toml. The result is a PDF next to the document, a PNG of one page for the MCP preview tool, or the Typst errors with file, line and column and exit code 1.How typstgen workstypstgen compile → Embedded TypstAI agent → typstgen mcptypstgen mcp → Embedded Typsttypstgen.toml → Embedded Typst: importsEmbedded Typst → PDF: compileEmbedded Typst → PNG page: previewEmbedded Typst → Errors: on failureimportscompilepreviewon failuretypstgen compile – CLItypstgen compileCLIAI agent – MCP clientAI agentMCP clienttypstgen mcp – check, preview, compiletypstgen mcpcheck, preview, compiletypstgen.toml – template_pathstypstgen.tomltemplate_pathsEmbedded Typst – typst 0.15, no subprocessEmbedded Typsttypst 0.15, no subprocessPDF – next to the .typ filePDFnext to the .typ filePNG page – preview toolPNG pagepreview toolErrors – file:line:column, exit 1Errorsfile:line:column, exit 1
How typstgen worksYou run typstgen compile, or an AI agent calls the MCP server started with typstgen mcp. Both hand the .typ file to the Typst engine compiled into typstgen, which resolves imports from the template directories in typstgen.toml. The result is a PDF next to the document, a PNG of one page for the MCP preview tool, or the Typst errors with file, line and column and exit code 1.How typstgen workstypstgen compile → Embedded TypstAI agent → typstgen mcptypstgen mcp → Embedded Typsttypstgen.toml → Embedded Typst: importsEmbedded Typst → PDF: compileEmbedded Typst → PNG page: previewEmbedded Typst → Errors: on failureimportscompilepreviewon failuretypstgen compile – CLItypstgencompileCLIAI agent – MCP clientAI agentMCP clienttypstgen mcp – check, preview, compiletypstgen mcpcheck, preview,compiletypstgen.toml – template_pathstypstgen.tomltemplate_pathsEmbedded Typst – typst 0.15, no subprocessEmbeddedTypsttypst 0.15, nosubprocessPDF – next to the .typ filePDFnext to the .typfilePNG page – preview toolPNG pagepreview toolErrors – file:line:column, exit 1Errorsfile:line:column,exit 1
How typstgen worksYou run typstgen compile, or an AI agent calls the MCP server started with typstgen mcp. Both hand the .typ file to the Typst engine compiled into typstgen, which resolves imports from the template directories in typstgen.toml. The result is a PDF next to the document, a PNG of one page for the MCP preview tool, or the Typst errors with file, line and column and exit code 1.How typstgen workstypstgen compile → Embedded TypstAI agent → typstgen mcptypstgen mcp → Embedded Typsttypstgen.toml → Embedded Typst: importsEmbedded Typst → PDF: compileEmbedded Typst → PNG page: previewEmbedded Typst → Errors: on failureimportscompilepreviewon failuretypstgen compile – CLItypstgencompileCLIAI agent – MCP clientAI agentMCP clienttypstgen mcp – check, preview, compiletypstgen mcpcheck, preview,compiletypstgen.toml – template_pathstypstgen.tomltemplate_pathsEmbedded Typst – typst 0.15, no subprocessEmbeddedTypsttypst 0.15, nosubprocessPDF – next to the .typ filePDFnext to the .typfilePNG page – preview toolPNG pagepreview toolErrors – file:line:column, exit 1Errorsfile:line:column,exit 1

What you get

Invoices

One invoice JSON, every format

The invoice template of the Typst package business-templates renders the PDF from an invoice JSON. typstgen reads the same file for the machine-readable versions, so the PDF and the XML cannot disagree.

  • ZUGFeRD / Factur-X: --zugferd invoice.json embeds the EN 16931 data in a PDF/A-3b.
  • XRechnung 3.0 and Peppol BIS Billing 3.0: typstgen e-invoice writes UBL 2.1 XML.
  • Your own tax rules: prepare-invoice calculates line amounts, tax groups and totals from your configuration, VAT or sales tax.
  • Clear errors: every problem names the JSON field to fix. Nothing is sent; validation and transmission stay separate steps.
Terminal: typstgen e-invoice --format xrechnung-3.0 --company company.json invoice.json prints 'wrote invoice.xml (xrechnung-3.0, UBL 2.1)' and the checks: arithmetic and required fields passed, XML schema, EN 16931, XRechnung and transmission not run. The same command on incomplete.json fails and names the missing fields recipient.electronic_address and metadata.buyer_reference (the Leitweg-ID for public buyers).

Quickstart

From a .typ file to a PDF in three steps. Every PDF on this page was compiled by typstgen from the files in examples/.

  1. Install the CLI with cargo install typstgen.
  2. List your template directories in typstgen.toml, for example template_paths = ["templates"].
  3. Run typstgen compile letter.typ. The PDF lands next to it.

Your first PDF in a few minutes.

Read the quickstart