The Template Treadmill
You need a PDF. Maybe it’s an invoice for a client. Maybe it’s a project report for the team. Maybe it’s a product spec with tables and images.
So you open your template engine — LaTeX, Jinja2, wkhtmltopdf, Puppeteer, Carbone — and start wrestling with layout. Margins are wrong. The table overflows. The font doesn’t embed. Two hours later you have a PDF that looks almost right and a build script you’ll never want to touch again.
Developers have been generating documents this way for decades. Template files, rendering engines, format-specific quirks. What if your AI assistant could just build the document for you — right inside the tool you’re already using?
That’s what MCP makes possible. The Model Context Protocol is an open standard that lets AI tools like Claude Code and Cursor discover and call external APIs directly. Instead of writing template code, you describe what you want in plain language. The assistant figures out the document structure, calls the API, and hands you the file.
Iteration Layer’s Document Generation API ships as an MCP server. Connect it once, and every conversation becomes a document authoring session.
What MCP Actually Is
MCP stands for Model Context Protocol. It’s a standard that lets AI clients — Claude Code, Cursor, Windsurf, and any MCP-compatible tool — connect to external services as “tools” the model can invoke.
Think of it like USB for AI tools. You plug in a service, the assistant discovers what it can do, and it starts using it when relevant. No SDK integration, no template files, no deployment scripts.
When you connect Iteration Layer as an MCP server, your assistant gains the ability to generate documents from structured content — PDFs, Word documents, EPUB ebooks, and PowerPoint presentations. All from a chat prompt.
Setting Up in Claude Code
Claude Code supports MCP servers natively. Add the Iteration Layer server with a single command:
claude mcp add iterationlayer --transport streamablehttp https://api.iterationlayer.com/mcp
The first time you use an Iteration Layer tool, a browser window opens for OAuth authentication. Log in, authorize access, and you’re connected. No API keys to manage.
To verify the server is available, start a conversation and ask Claude Code what MCP tools it has access to. You should see generate_document listed among the available tools.
Setting Up in Cursor
Add to your .cursor/mcp.json:
{
"mcpServers": {
"iterationlayer": {
"type": "streamablehttp",
"url": "https://api.iterationlayer.com/mcp"
}
}
}
Save and restart. The Document Generation tool is now available in your Cursor AI conversations. Authentication works the same way — OAuth in the browser on first use.
How Tool Discovery Works
When your AI assistant starts a conversation, it queries all connected MCP servers to learn what tools are available. The Iteration Layer MCP server advertises a generate_document tool with a description of its capabilities — supported formats, block types, styling options, and page configuration.
The assistant reads this tool description and knows when to use it. If you mention generating a document, creating a PDF, or building a report, the assistant recognizes that generate_document is the right tool. You never need to say “use the Document Generation API” — it figures that out from context.
This is the key difference from a traditional template approach. You don’t write markup. You don’t configure a rendering engine. The assistant handles the translation between your natural language request and the structured API call.
Generating Documents Conversationally
Once connected, you describe the document you want in natural language. Here’s what that looks like.
You type:
“Generate a PDF invoice for Acme Corp. Invoice number INV-2026-0312, dated March 1, 2026. Three line items: ‘Consulting hours (40h)’ at $6,000, ‘Infrastructure setup’ at $2,400, and ‘Documentation’ at $800. Subtotal $9,200, tax 19% ($1,748), total $10,948. Use A4 with comfortable margins.”
The assistant translates that into a structured document definition — headlines, paragraphs, a table with header and body rows, styled text for the totals — calls the API, and returns the PDF. The whole exchange takes seconds.
You can iterate from there:
“Add the company logo from https://example.com/acme-logo.png at the top right. Make the invoice number bold. Add a footer with ‘Payment due within 30 days’ on every page.”
The assistant adjusts the content blocks, adds an image block and a footer definition, and regenerates. Same workflow you’d follow in a word processor — but through conversation.
More Conversations, More Use Cases
The conversational interface handles far more than invoices. Here are a few more prompts and what the assistant does with them.
Creating a project report:
“Generate a PDF report titled ‘Q1 Performance Review’. Add a table of contents. Three sections: ‘Revenue’ with a summary paragraph and a table of monthly figures, ‘Customer Growth’ with a paragraph and a bar chart placeholder image, and ‘Outlook’ with two paragraphs. Use Letter size, professional styling.”
The assistant builds the document with headlines at the right levels, a table-of-contents block that auto-generates from those headlines, tables with proper headers, and paragraph blocks with the text you described. Page breaks between sections keep the layout clean.
Generating a Word document:
“Create a DOCX employee handbook. Title page with ‘Employee Handbook — 2026’ centered. Sections for ‘Code of Conduct’, ‘Benefits’, ‘Time Off Policy’, and ‘Remote Work’. Use a numbered list for the conduct rules and a table for the PTO breakdown by tenure. Include page numbers in the footer.”
The assistant sets the format to docx and builds the content with headlines, lists, tables, page breaks, and a footer containing a page-number block. The output is an editable Word document — not a locked PDF. Your HR team can refine it further.
Building an EPUB ebook:
“Generate an EPUB with the title ‘Getting Started with Elixir’. Three chapters: ‘Installation’, ‘Basic Types’, and ‘Pattern Matching’. Each chapter gets a headline and two paragraphs of content. Add a table of contents at the beginning.”
The assistant produces a valid EPUB file with proper navigation, a generated table of contents, and chapter structure. Drop it on a Kindle or open it in any ebook reader.
Creating a presentation:
“Generate a PPTX with 5 slides. Title slide: ‘Product Roadmap Q2’. Then one slide each for ‘Auth Improvements’, ‘API v2’, ‘Dashboard Redesign’, and ‘Timeline’. Each content slide gets a headline and 3-4 bullet points.”
The assistant generates a PowerPoint file with structured slides. Open it in PowerPoint or Google Slides to add your own styling and visuals.
Iterating on Documents Conversationally
The real power of MCP is the feedback loop. After the first generation, you refine the document based on what you see.
Say the invoice table looks right but the footer text is too small. You reply:
“Make the footer text 8pt and light gray. Also add a horizontal separator line above it.”
The assistant updates the footer styles and adds a separator block. No template to edit, no build to re-run. You iterate on the document in plain language until it matches what you need.
This is especially valuable when you’re figuring out the right structure for a new document type. Instead of guessing the layout upfront, tweaking template markup, rebuilding, and checking — you have a conversation. Once the document looks right, you can take that exact structure and use it in your production code via the API.
What You Can Build
The Document Generation API supports content block types that cover most document authoring needs:
- Paragraphs — text with full markdown support (bold, italic, links), custom fonts, and per-block style overrides
- Headlines — h1 through h6, automatically collected for table of contents generation
- Tables — header rows, body rows, per-cell content, configurable column widths and border styles
- Grids — 12-column layout system for multi-column content within a document
- Lists — ordered and unordered, with nested sub-items
- Images — embedded from URLs or base64, with width and height control
- Table of contents — auto-generated from your headline hierarchy
- QR codes — generated from any value, with custom size and colors
- Barcodes — six formats (Code 128, EAN-13, Codabar, Code 39, EAN-8, ITF)
- Separators — horizontal rules with configurable style, thickness, and spacing
- Page breaks — explicit control over pagination
Four output formats from one content model: PDF, DOCX, EPUB, and PPTX. Define the document once, generate it in whichever format you need.
Custom Fonts and Styling
The API accepts custom fonts in TTF, OTF, WOFF, and WOFF2 formats. Reference them by URL or base64 in the request, then use them across your document.
Every element is stylable. Document-level styles set the defaults — font family, size, color, line height for text; spacing and weight for headlines; border styles for tables. Individual blocks can override any style property, so a single paragraph can use a different font without changing the rest of the document.
When you tell the assistant “use Inter for body text and Playfair Display for headlines, dark navy color scheme,” it knows to include both font definitions and set the appropriate styles at the document level.
Headers, Footers, and Page Numbers
Documents support headers and footers that repeat on every page. Both accept the same block types as the main content — paragraphs, images, separators, and more. A common pattern is a company logo in the header and page numbers in the footer.
The page-number block type renders the current page number dynamically. Place it in your footer with a text alignment and the API handles the numbering across all pages.
MCP vs Direct API Calls
MCP is for ad-hoc work. You need one document, right now, and you don’t want to write code. The assistant handles the document structure, the styling, the block composition. You describe, it generates.
For production pipelines — generating invoices from order data, creating reports on a schedule, building documents from CMS content — use the API directly. The request body is JSON. Any language that can make an HTTP POST can generate documents.
The two approaches complement each other. Prototype in conversation with MCP, then extract the document structure into your codebase for automation. The JSON definition you refined conversationally is the same JSON you pass to the API endpoint — no translation needed.
Get Started
Sign up for a free account at iterationlayer.com — no credit card required. Run the claude mcp add command above, authenticate in the browser, and generate your first document from your next Claude Code or Cursor conversation.
The docs cover every block type, every style property, and every output format. Start with a simple invoice or report — it’s the fastest way to see how structured document generation feels different from templates.