beautiful-pdf-mcp
Integrates with Typst to compile typographically correct, print-ready PDFs from AI-generated content using Typst's typesetting engine.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@beautiful-pdf-mcpCreate a magazine spread from these photos and text"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
π beautiful-pdf-mcp
MCP server that lets AI agents produce print-ready, typographically correct PDFs β magazine spreads, GOST lab reports, books, resumes β compiled by Typst, not an HTML export dressed up as a document.
π§ The idea: the page is the unit of design
Most generated documents are built the lazy way: stack blocks on a canvas and let them fall where they may. The result is familiar β a heading stranded at the bottom of a page, an image floating in a half-empty sheet, a paragraph that trails off into nothing.
This engine thinks the way a magazine make-up editor does, one page at a time:
Budget first. Before any text is written,
estimate_page_budgetmeasures how many words fit one page of the chosen template β so content is written to size, not trimmed after the fact.Fill the page like a block. Every page inside a continuous flow is composed to the bottom of the type area. The leftover text carries to the next page as plain prose β mid-sentence, even mid-hyphen, exactly like a printed book. Tails are normal; holes are not.
Verify, then ship. Every compile returns a per-page
layout_report(fill %, holes, defects). The agent inspects rendered pages as PNGs and fixes problems before the user ever sees them.strict_layout: truerefuses to produce a defective PDF at all.Two-pass image placement. The compiler tracks the position of every paragraph, computes where each image actually lands, and recompiles with explicit placements β so a photo never tears the layout or strands itself on an empty page.
Related MCP server: agent-reader
πΈ Showcase
Two of eight templates shown β run the test suite to render them all.
β¨ Features
π Page-as-canvas engine β budget β compose β per-page QC β two-pass image placement. Every sheet is a finished block, not an accident.
πΌοΈ Magazine spreads β two photos placed diagonally with one continuous text threading around both, powered by meander; single photos get true side-wrap via wrap-it.
π Auto-fit single-page documents β a short resume or letter measures itself and scales typography up until the sheet is gracefully full.
π GOST 7.32 compliance β sections on fresh pages, figures after first mention, full-width tables with captions above: Russian academic standards enforced structurally. Works in English and Russian (
language: "en"switches Figure/Table/Contents labels).βοΈ No rivers, ever β justified text uses aggressive hyphenation costs so lines pack tight instead of stretching into word gaps.
π Deterministic re-rendering β the document state lives in JSON; every edit re-lays-out the whole document by the rules, so nothing ever "drifts apart".
π Quick Start
Prerequisites
Python 3.10+
Typst β
brew install typst(or download a release)
Installation
git clone https://github.com/Kreminskaya/beautiful-pdf-mcp.git
cd beautiful-pdf-mcp
pip install -r requirements.txtConnect to your agent
Add to your MCP client config (Claude Desktop: ~/Library/Application Support/Claude/claude_desktop_config.json, Cursor: ~/.cursor/mcp.json β same JSON for any stdio MCP client):
{
"mcpServers": {
"beautiful-pdf": {
"command": "python3",
"args": ["/absolute/path/to/beautiful-pdf-mcp/src/server.py"]
}
}
}Restart the client β tools appear as beautiful-pdf__*. Then just ask your agent:
"Make me a magazine-style PDF article from these three photos and this text."
π Templates
Template | Use case | Format | Body font |
| Business report, analytics | A4 | Source Serif 4 |
| Thesis, lab report (GOST 7.32, en/ru) | A4 | PT Serif 14pt |
| Long-form, fiction & non-fiction | A5 | PT Serif |
| API docs, developer guides | A4 | IBM Plex Sans |
| Portfolio, showcase | A4 | Noto Sans |
| Official correspondence | A4 | Source Sans 3 |
| Magazine / editorial layout | A4 | Lora + Cormorant |
| Modern two-column CV | A4 | IBM Plex Sans |
All 21 fonts ship with the repo β output is identical on every machine.
π οΈ How agents use it
budget = estimate_page_budget(template="journal", language="en")
# β words_per_page, lines_per_page: write the article TO BUDGET
doc = create_document(title="Between Rock and Sky", template="journal",
language="en", preset_overrides={"accent_color": "#c4a35a"})
sid = add_section(doc_id, "On Restraint", ARTICLE_WRITTEN_TO_BUDGET, level=1)["section_id"]
add_image(doc_id, sid, "photo1.png") # photos embed into the running text
add_image(doc_id, sid, "photo2.png") # second photo β diagonal spread
result = compile_preview(doc_id, pages="1-3")
# β PNG per page + layout_report: fill % and defects for every page
compile_pdf(doc_id, "article.pdf", strict_layout=True)
# refuses to ship a PDF with underfilled pages or layout holesThe loop is the point: budget β compose β look β fix β ship. The agent reads
the layout_report numbers (words to add, lines short), inspects the rendered
pages, and iterates until every page is a clean block.
Tool | Description |
| Words/lines that fit one page of a template β call before writing |
| Create a document, returns |
| Add a section (Markdown content) |
| Update a section's title or text |
| Remove a section |
| Image with optional caption, width, position ( |
| Grid of images |
| Table with headers and rows |
| Syntax-highlighted code |
| Callout box (info / warning / tip / danger / quote) |
| Render pages to PNG + per-page |
| Final PDF; |
| Persist / restore document state as JSON |
| Inspect session state |
Any preset key can be overridden per document via preset_overrides:
create_document(..., preset_overrides={
"accent_color": "#2a9d8f", # brand colour
"page_num_position": "bottom-center", # or top-left β¦ bottom-right, none
"header_rule": False, # drop the thin running-header line
"show_header_footer": False, # no furniture at all
"body_font": "PT Serif",
"margin_left": "3.5cm",
})Each template declares a page contract (data/styles.json): what a finished
page looks like for that genre β fill thresholds, tolerated underfill, whether a
final chapter page may end early (a book chapter can; a hole mid-article cannot).
Compilation is two-pass: pass 1 renders the document with invisible
per-paragraph position marks, the server queries where every paragraph and image
actually landed, computes optimal after:N anchors for position: "auto"
images, and pass 2 recompiles with explicit placements. The QC
(src/layout_qc.py) then grades every page against the contract and reports
exact numbers β "page 3: 6 lines short, add ~40 words" β so the agent can fix
layout arithmetically instead of guessing.
The full specification lives in docs/SPEC_PAGE_FILL.md (in Russian β the project's design constitution is CONCEPT.md).
π§ͺ Testing
python3 tests/render_all.py # render every template to PNG + page QC
python3 tests/render_all.py journal # one template
python3 tests/render_all.py showcase # hand-finished showcase documentsEvery page of every template is rendered to tests/output/ and graded by the
page-fill QC β the test fails if any page violates its template's contract.
πΊοΈ Roadmap
8 templates with shipped fonts
Page-as-canvas layout engine (meander spreads, auto-fit, GOST structure)
Page budget + per-page fill QC +
strict_layoutTwo-pass compilation with automatic image placement
Bibliography tool with GOST citation style (
gost-r-705-2008-numeric)Typst 0.15 upgrade (multiple bibliographies, variable fonts)
Decorative drop caps for the book template
More CV layouts (single-column, photo-left)
π§± Tech Stack
Layer | Technology |
Typesetting | |
Server | Python, FastMCP |
Layout QC |
|
Imaging | Pillow (aspect detection, preview pipeline) |
Fonts | PT, IBM Plex, Source, Noto, Lora, Cormorant β bundled |
π License
MIT β see LICENSE.
βοΈ If this saves you from one more ugly AI-generated PDF β star the repo!
This server cannot be deployed
Maintenance
Related MCP Connectors
- pdfs.buildOAuthbuild.pdfs
Design, publish and render PDF templates with Typst. Full template lifecycle over MCP.
Hosted MCP server: convert PDFs to clean, LLM-ready Markdown with tables, formulas and OCR.
MCP server for building and testing AI agents with multi-model experimentation and insights.
HTML and CSS to PDF MCP server with page headers, footers and page numbers. No headless browser.
Related MCP Servers
- AlicenseBqualityCmaintenanceMCP server that converts Markdown to high-quality PDF documents using LaTeX, enabling AI agents like Claude to generate professional PDFs without requiring sign-ups or credit cards.1279 npm11MIT
- AlicenseAqualityNot gradedmaintenanceAn MCP server that enables AI agents to instantly convert Markdown into beautiful, ready-to-deliver Word, PDF, HTML with sidebars, and Slideshow documents, bridging the "last mile" of AI content generation.728 npm1-
- AlicenseAqualityCmaintenanceMCP server for generating professional PDFs from structured JSON in AI agents like Claude or Cursor, using pure Node.js with embedded fonts and precision text layout.624 npmMIT
- AlicenseAqualityDmaintenanceThis MCP server enables AI agents to view PDFs as accessible HTML with bounding-box citations, and provides tools for layout-aware parsing, schema extraction, cross-document Q&A, and PDF rendering.27MIT