Skip to main content

typeset-mcp

A Model Context Protocol server that typesets Markdown documents into production-quality PDFs. Powered by the Typst engine, with first-class CJK (Chinese, Japanese, Korean) support.

Markdown → validate → measure → typeset → audit → render → publish → PDF

Why

LLM agents can write Markdown, but "make it look professional" is where they fail: fonts don't embed, tables split awkwardly, math breaks, page numbers vanish. typeset-mcp gives agents (and you) a structured pipeline instead of a one-shot converter:

  • Validate before compiling — catch broken links, unbalanced code fences, oversized images, and setext heading traps before wasting a compile
  • Measure before writing — table widths, code line lengths, and image sizes compared against the text area, with a rough page count
  • Audit after building — read the actual PDF content stream: embedded fonts (error), text layer (error), WCAG AA contrast, orphan headings, split tables, page-edge text
  • Render for visual review — page PNGs returned inline so the agent (or a vision model) can inspect the output
  • Publish with fingerprint verification — sha256-checked copy that fails loudly if the draft changed

Quick Start

pip install typeset-mcp

Add to your MCP client config (Claude Code, Cursor, Codex, etc.):

{
  "mcpServers": {
    "typeset": {
      "command": "typeset-mcp",
      "args": ["--root", "/path/to/your/workspace"]
    }
  }
}

Or with uv:

{
  "mcpServers": {
    "typeset": {
      "command": "uv",
      "args": ["run", "--with", "typeset-mcp", "typeset-mcp", "--root", "."]
    }
  }
}

Tools

Tool What it does
validate_document Lint Markdown: frontmatter, headings, code fences, tables, images, links
measure_document Pre-compile estimates: table/code/image widths vs text area
typeset_document Compile one .md to a draft PDF (.build.pdf)
typeset_project Build multi-chapter projects from a YAML manifest
audit_document Read the built PDF's content stream for typography defects
render_pages Render page PNGs for visual review
publish_document Copy draft to final destination with fingerprint check
inspect_document Report pages, fonts, metadata
convert_figures Batch-convert PDF vector figures to PNG
create_project Scaffold a project from a template (report / homework / slides)
list_guides / read_guide Methodology guides for agents

Themes

Four themes × six accent colors:

Theme Use case Layout
minimal Simple documents A4, no cover
report Reports, papers Cover + outline + body
homework Problem sets Compact info header, no cover
beamer Presentations 16:9 slides, one ## per slide
---
title: My Document
author: Your Name
theme: report
lang: zh
accent: blue
footer: Internal Draft
---

Features

  • CJK-first: Chinese/Japanese/Korean text renders correctly out of the box (Microsoft YaHei + Times fallback)
  • Math: LaTeX math via mitex — $\sum_{i=1}^n x_i$, $$E = mc^2$$, \boxed, align, matrices
  • Images: PNG/JPG/GIF/WebP, absolute or relative paths, remote URLs (with SSRF sandbox), auto-constrained to page, auto-optimized (downsampled + JPEG when oversized)
  • Footnotes: [^label] renders as page-bottom notes
  • Author notes: authorNotes frontmatter key renders \thanks-style footnotes on the cover
  • Mermaid diagrams: rendered via the mmdr package
  • Multi-chapter books: typeset_project joins chapters with one cover and outline
  • Stylesheets: custom .typ files injected after the theme
  • Project config: typeset.yaml for workspace-wide defaults
  • SSRF protection: remote image fetching runs through a network sandbox (scheme allowlist, private IP blocking, connection pinning, redirect validation)

Guides

The server ships two methodology guides that MCP agents read before typesetting:

  • workflow — the calibration philosophy: validate → measure → typeset → audit → render → publish, when to fix vs accept advisories
  • authoring — writing habits: frontmatter keys, footnote syntax, image path rules, heading numbering, common pitfalls

Requirements

  • Python ≥ 3.12
  • Windows / macOS / Linux
  • Fonts: Microsoft YaHei or any CJK font (for Chinese), Times New Roman (Latin)
  • First compile downloads Typst packages (mitex for math, mmdr for mermaid) — subsequent compiles are offline

Development

git clone https://github.com/lhh010/typeset-mcp
cd typeset-mcp
uv sync
uv run python -X utf8 -m unittest discover -s tests

93 tests, no network required (except first-time package downloads).

License

MIT — see LICENSE.

Metadata

Release files for typeset-mcp 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for typeset-mcp 0.2.0
File Size Uploaded Provenance Actions
typeset_mcp-0.2.0.tar.gz 61.2 kB With provenance Details for typeset_mcp-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for typeset-mcp 0.2.0
File Interpreter ABI Platform Actions
typeset_mcp-0.2.0-py3-none-any.whl Python 3 none any Details for typeset_mcp-0.2.0-py3-none-any.whl

Total release size: 119.5 kB

Release files / typeset_mcp-0.2.0.tar.gz

Download URL typeset_mcp-0.2.0.tar.gz
Size 61.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9766b0b53bfbbb0a33a3d565a6678ecdc34454f3fb3fff4c65d0e2935f02114a
BLAKE2b-256 checksum
How to use checksums
70a1d6fcdfb4a58903f8a45fa4485a83f21362f7397c728eddc245718f3c844e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Release files / typeset_mcp-0.2.0-py3-none-any.whl

Download URL typeset_mcp-0.2.0-py3-none-any.whl
Size 58.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4fa28aa7abcc14ffe628259550776e6c716799c099c88b5bbc2ffd534e7894df
BLAKE2b-256 checksum
How to use checksums
9de66d8eee947b8de5c41752836ab427c679ec558affac4a83393995fc49d0c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Security for typeset-mcp 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for typeset_mcp-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page