AI agents can reason, plan, and write — but they can't produce a downloadable PDF. PdfBroker.io's MCP server closes that gap. By connecting an AI agent to PdfBroker.io through the Model Context Protocol, any LLM-powered application gains the ability to generate professional, compliance-ready PDF documents from HTML and CSS.
This guide is for SaaS builders and architects who want to embed AI-driven document generation into their products. It covers the architecture, integration patterns, and practical considerations for using PdfBroker.io as PDF infrastructure in the AI agent stack.
Why MCP Instead of a Direct API Integration?
You could integrate PdfBroker.io's REST API directly — and for deterministic, template-driven workflows, that's still the right approach. MCP adds value when the document content is generated or decided by an AI agent at runtime:
Direct API: Your code decides what HTML to send, calls the API, gets a PDF back. The document structure is fixed in your codebase.
MCP: The AI agent decides what to generate based on user input, creates the HTML, and calls the PDF tool. The document adapts to each request without code changes.
Examples where MCP makes more sense than direct API integration:
- A customer support agent that generates personalized resolution letters
- A reporting tool where users describe what they want in natural language
- A contract drafting assistant that creates tailored agreements
- A compliance tool that generates accessibility-ready documents on demand
Architecture
┌─────────────────────────┐
│ Your SaaS Application │
│ │
│ ┌───────────────────┐ │
│ │ AI Agent / LLM │ │
│ │ (Claude, GPT, etc)│ │
│ └────────┬──────────┘ │
│ │ MCP │
│ ▼ │
│ ┌───────────────────┐ │
│ │ PdfBroker.io │ │
│ │ MCP Server │ │
│ │ mcp.pdfbroker.io │ │
│ └────────┬──────────┘ │
│ │ │
│ ▼ │
│ ┌───────────────────┐ │
│ │ Download URL │──┼──► User downloads PDF
│ │ (30-min TTL) │ │
│ └───────────────────┘ │
└─────────────────────────┘
The MCP server is a remote Streamable HTTP service. Your application's AI agent connects to it the same way it connects to any MCP server. Credentials are passed as HTTP headers (X-PdfBroker-ClientId and X-PdfBroker-ClientSecret) on each request.
PdfBroker.io handles the rendering server-side — no local PDF libraries, no container dependencies, no font management. The AI agent sends HTML, the MCP server returns a time-limited download URL.
Integration Pattern: AI Agent with MCP Tools
If you're building an AI agent using the Anthropic API, OpenAI API, or any framework that supports MCP (Semantic Kernel, LangChain, etc.), the integration is straightforward.
Using C# with the MCP C# SDK
using ModelContextProtocol.Client;
// Connect to PdfBroker's MCP server
var transport = new HttpClientTransport(new HttpClientTransportOptions
{
Endpoint = new Uri("https://mcp.pdfbroker.io/"),
Headers = new Dictionary<string, string>
{
["X-PdfBroker-ClientId"] = configuration["PdfBroker:ClientId"]!,
["X-PdfBroker-ClientSecret"] = configuration["PdfBroker:ClientSecret"]!
}
});
var mcpClient = await McpClient.CreateAsync(transport);
// List available PDF tools
var tools = await mcpClient.ListToolsAsync();
// tools: html_to_pdf, html_to_pdf_wk, merge_pdfs, pdf_to_image, write_text_on_pdf
// Call a tool directly
var result = await mcpClient.CallToolAsync("html_to_pdf", new Dictionary<string, object?>
{
["html"] = "<html><body><h1>Generated Report</h1><p>Content here...</p></body></html>",
["conformanceLevel"] = "PdfA1b",
["paperSize"] = "A4"
});
// result.Content contains the download URL
var downloadUrl = result.Content.OfType<TextContentBlock>().First().Text;
// "PDF generated successfully (18 KB). Download: https://mcp.pdfbroker.io/download/a1b2c3d4e5f6"
Passing Tools to an LLM via IChatClient
The MCP C# SDK integrates with Microsoft.Extensions.AI, so MCP tools can be handed directly to any IChatClient:
// Get PdfBroker tools as AIFunctions
var tools = await mcpClient.ListToolsAsync();
// Pass them to your LLM alongside a user prompt
IChatClient chatClient = /* your Claude/OpenAI/etc client */;
var response = await chatClient.GetResponseAsync(
"Create a professional invoice PDF for Acme Corp. " +
"Include 3 line items: consulting (10h at €150/h), development (20h at €120/h), " +
"and hosting (1 month at €49/mo). Use PDF/A compliance.",
new() { Tools = [.. tools] });
// The LLM generates HTML, calls html_to_pdf, and returns the download URL
Using cURL (for testing)
# Call the MCP server directly via JSON-RPC
curl -X POST https://mcp.pdfbroker.io/ \
-H "Content-Type: application/json" \
-H "X-PdfBroker-ClientId: YOUR_CLIENT_ID" \
-H "X-PdfBroker-ClientSecret: YOUR_CLIENT_SECRET" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "html_to_pdf",
"arguments": {
"html": "<html><body><h1>Test</h1></body></html>",
"paperSize": "A4"
}
}
}'
Document Patterns
Pattern 1: Compliance Documents (PDF/A, PDF/UA)
The European Accessibility Act requires publicly available documents to meet accessibility standards. PdfBroker.io's WeasyPrint engine supports PDF/UA-1 compliance out of the box.
User prompt: "Generate an accessible annual report summary for Q1 2026"
AI agent:
1. Generates semantic HTML with proper heading hierarchy, alt text, and lang attributes
2. Calls html_to_pdf with conformanceLevel: "PdfUA1"
3. Returns a PDF/UA-compliant document that passes accessibility validators
For archival use cases (legal, financial, government), use PdfA1b or PdfA3b conformance levels.
Pattern 2: Generate-Then-Merge
For multi-section documents where each section has different content or formatting:
User prompt: "Create a proposal with a cover page, executive summary, and three technical sections"
AI agent:
1. Generates cover page HTML → calls html_to_pdf → gets PDF 1
2. Generates executive summary HTML → calls html_to_pdf → gets PDF 2
3. Generates each technical section → calls html_to_pdf → gets PDFs 3-5
4. Calls merge_pdfs with all five PDFs → gets combined document
Pattern 3: Template + Dynamic Data
The AI agent doesn't need to design documents from scratch every time. Provide a template via MCP resources or in the system prompt, and let the AI fill in the dynamic parts:
System prompt: "When generating invoices, use this HTML template: [template].
Replace the placeholder values with the data from the user's request."
User prompt: "Invoice for 3 hours of consulting at €200/h for Client XYZ"
AI agent:
1. Fills in the template with the specific data
2. Calls html_to_pdf → gets the PDF
Choosing the Right Engine
PdfBroker.io offers two rendering engines via MCP:
| Consideration | html_to_pdf (WeasyPrint) | html_to_pdf_wk (wkhtmltopdf) |
|---|---|---|
| CSS Paged Media (headers, footers, page numbers) | Full support | No |
| JavaScript execution | No | Yes |
| PDF/A, PDF/UA compliance | Yes | No |
| Rendering quality | Professional print-ready | Screen-capture style |
| Free tier | No (Starter plan+) | Yes |
| Best for | Invoices, contracts, reports, compliance docs | Quick snapshots, JS-heavy layouts |
For most AI-generated documents, html_to_pdf (WeasyPrint) is the right choice. The AI agent naturally generates semantic HTML and CSS, which is exactly what WeasyPrint excels at.
Security Considerations
Credentials per user. Each user or tenant should have their own PdfBroker.io credentials. Pass them as X-PdfBroker-ClientId / X-PdfBroker-ClientSecret headers. The MCP server does not store credentials — it creates a fresh authenticated client per request.
Data in transit. HTML content is sent to PdfBroker.io's servers for rendering and is deleted after the PDF is generated. No document content is stored beyond the 30-minute download window. All communication uses HTTPS.
Rate limiting. PdfBroker.io enforces rate limits per credential pair based on the subscription tier. AI agents can generate many requests quickly — monitor usage and consider the Professional or Enterprise tier for production workloads.
What's Next
- Set up PdfBroker.io MCP in your AI client — Step-by-step connection guide for Claude, Cursor, and VS Code
- Automate invoice generation with AI — End-to-end tutorial
- WeasyPrint CSS tips — Headers, footers, and page numbers
- PdfBroker.io pricing — Choose the right plan for your workload
- MCP C# SDK documentation — Build MCP clients in .NET