AI agents can now generate PDFs directly, no code, no API calls, no manual work. You describe what you want in plain English, and the agent handles everything: writing the HTML template, filling in data, and rendering a pixel-perfect PDF.
This is possible thanks to MCP (Model Context Protocol), the open standard that lets AI tools connect to external services. PDF4.dev ships with a built-in MCP server, making it the first PDF API that AI agents can use natively.
What is MCP?
MCP is an open protocol created by Anthropic that lets AI assistants call external tools. Think of it as "plugins for AI", but standardized across all clients.
When you connect an MCP server to your AI tool, the agent gains new capabilities. In the case of PDF4.dev, your agent can:
- Generate PDFs from templates or raw HTML
- Create and manage templates with Handlebars variables
- Check generation logs for debugging and monitoring
The agent decides which tools to call based on your natural language request. You never need to write API calls yourself.
Setup: 3 minutes
Update, September 2026. Claude and ChatGPT now connect by signing in to PDF4.dev with OAuth, with no API key to create or paste. The server exposes 14 tools, and an API key, for the clients that use one, is sent in the Authorization header, never as a tool parameter. The steps below reflect that.
Step 1: Create an account
Create a free account at pdf4.dev. Claude and ChatGPT sign you in from there. For clients that take an API key, such as Cursor or VS Code, generate one on the API keys page.
Step 2: Connect the MCP server
Add PDF4.dev to your AI client's MCP configuration. The setup is slightly different for each client:
Claude Code
Run this in your terminal, then run /mcp in Claude Code and choose Authenticate to sign in:
claude mcp add --transport http pdf4dev https://pdf4.dev/api/mcpFor scripts and CI, add --header "Authorization: Bearer p4_live_xxx" to use an API key instead.
Claude (web, Desktop, mobile)
Open Customize → Connectors → Add custom connector, enter https://pdf4.dev/api/mcp, then Add and Connect. Sign in to PDF4.dev, pick an organization, and allow access. No API key or config file is needed.
Cursor
Add to .cursor/mcp.json in your project root:
{
"mcpServers": {
"pdf4dev": {
"url": "https://pdf4.dev/api/mcp",
"headers": {
"Authorization": "Bearer p4_live_xxx"
}
}
}
}VS Code (Copilot)
Add to .vscode/mcp.json in your project root:
{
"servers": {
"pdf4dev": {
"type": "http",
"url": "https://pdf4.dev/api/mcp",
"headers": {
"Authorization": "Bearer p4_live_xxx"
}
}
}
}The top-level key is servers (not mcpServers). MCP tools only work in Copilot Agent mode.
Windsurf
Add to ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"pdf4dev": {
"serverUrl": "https://pdf4.dev/api/mcp",
"headers": {
"Authorization": "Bearer p4_live_xxx"
}
}
}
}Windsurf uses serverUrl, not url.
ChatGPT
Turn on Developer mode under Settings → Security and login, then open chatgpt.com/plugins, select +, and enter https://pdf4.dev/api/mcp as the connection. ChatGPT then signs you in to PDF4.dev with OAuth; it does not send API keys or custom headers. Developer mode availability depends on your account and workspace policy.
Step 3: Start generating
That's it. Your AI agent now has access to 14 PDF tools. Clients that signed in hold an OAuth token and refresh it on their own; clients configured with a key send it in the Authorization header. Either way, the credential never appears in the conversation.
The 14 MCP tools
| Tool | What it does |
|---|---|
get_info | Account overview: templates, variables, stats |
render_pdf | Generate a PDF from template or raw HTML, as base64 or a 24-hour URL |
preview_template | Render a template as PNG screenshot for visual feedback |
list_templates | List all templates |
get_template | Get template details including HTML |
create_template | Create a new template |
update_template | Update an existing template |
delete_template | Delete a template permanently |
list_components | List header/footer/block components |
get_component | Get component details |
create_component | Create a header/footer/block component |
update_component | Update a component |
delete_component | Delete a component permanently |
list_logs | View generation history |
Real-world examples
Generate an invoice
"Generate an invoice PDF for Acme Corp. Invoice #INV-042, date March 8 2026, item: Annual subscription, amount: $4,500."
The agent calls render_pdf with your invoice template and the data you provided. In seconds, you get a downloadable PDF.
Create a template from scratch
"Create a certificate template with fields for recipient name, course title, completion date, and instructor name. Use a clean, modern design with a blue accent color."
The agent writes the full HTML/CSS, then calls create_template to save it. You can then use this template for all future certificates.
Batch generation
"Generate certificates for these 5 people: Alice Johnson (React Fundamentals), Bob Smith (Advanced TypeScript), Carol Lee (System Design), David Kim (Cloud Architecture), Eve Chen (Data Engineering). All completed on March 1, 2026."
The agent calls render_pdf five times with different data, producing five distinct PDFs.
Debug a failed generation
"Show me my last 10 PDF generations. Were there any failures?"
The agent calls list_logs and presents a formatted summary with status, timing, and error details for any failures.
Iterate on design
"The invoice template looks good, but add a QR code placeholder and move the total to the bottom right. Also increase the font size of the company name."
The agent calls get_template to read the current HTML, modifies it, and calls update_template. No manual coding needed.
Why MCP beats traditional API integration
| Aspect | Traditional API | MCP |
|---|---|---|
| Setup time | Hours (read docs, write code, handle errors) | 3 minutes (paste config, start talking) |
| Learning curve | Learn API endpoints, auth, request format | Zero, use natural language |
| Error handling | You write retry logic, validation | Agent handles retries and edge cases |
| Iteration speed | Edit code → test → debug → repeat | "Make the header bigger" → done |
| Template design | HTML/CSS knowledge required | Describe what you want |
MCP doesn't replace the REST API, it adds a natural language layer on top. For production pipelines, you'll still want direct API calls. But for template design, one-off generations, and prototyping, MCP is dramatically faster.
Technical details
PDF4.dev's MCP server uses Streamable HTTP transport (the latest MCP standard). Key details:
- Endpoint:
https://pdf4.dev/api/mcp - Auth: OAuth sign-in (Claude, ChatGPT, Claude Code) or an API key in the
Authorizationheader, verified before any tool runs - PDF format: Returned as base64-encoded string with metadata (size, duration)
- Templates: Full Handlebars support with
{{variables}} - Page formats: A4, Letter, A4 Landscape, Letter Landscape, Square, or custom dimensions
Getting started
- Create a free account
- Add
https://pdf4.dev/api/mcpto your AI client: Claude, Claude Code and ChatGPT sign you in with OAuth, other clients take an API key - Try: "Generate a simple invoice PDF for $100"
The full integration guide with all client configs and tool documentation is at pdf4.dev/ai-integration.
If you prefer direct API calls, check out the interactive API docs or the OpenAPI spec.
Free tools mentioned:
Start generating PDFs
Build PDF templates with a visual editor. Render them via API from any language in ~300ms.



