MCP tools
PDF4.dev exposes 14 MCP tools covering the full PDF lifecycle: generate, preview, manage templates and components, and monitor usage.
Every tool includes MCP tool annotations (readOnlyHint, destructiveHint, idempotentHint) so AI agents can make informed decisions about which tools are safe to call without user confirmation.
| Annotation | Meaning |
|---|---|
readOnlyHint: true | Tool only reads data, never modifies anything |
destructiveHint: true | Tool may permanently delete or overwrite data |
idempotentHint: true | Calling the tool multiple times with the same input has no additional effect |
openWorldHint: true | Tool may interact with external resources or accept arbitrary input |
Generate
render_pdf
Generate a PDF from a saved template or raw HTML. Returns the PDF as a base64-encoded string with metadata (file size, render duration).
Annotations: readOnlyHint: false · destructiveHint: false · idempotentHint: true
| Parameter | Required | Description |
|---|---|---|
api_key | Yes | Your PDF4.dev API key |
template_id | One of these | Template ID or slug |
html | One of these | Raw HTML string |
data | No | Key-value pairs for {{variables}} |
format_preset | No | a4, letter, square, custom... |
Example prompt: "Generate an invoice PDF for client Acme Corp, total $4,500"
preview_template
Render a template as a PNG screenshot for fast visual feedback. Same parameters as render_pdf. Ideal for iterating on template design without generating a full PDF.
Annotations: readOnlyHint: true · destructiveHint: false
| Parameter | Required | Description |
|---|---|---|
api_key | Yes | Your PDF4.dev API key |
template_id | One of these | Template ID or slug |
html | One of these | Raw HTML string |
data | No | Key-value pairs for {{variables}} |
format_preset | No | a4, letter, square, custom... |
Returns: PNG image displayed directly in the agent's response.
Example prompt: "Preview my invoice template before generating the final PDF"
Templates
list_templates
List all saved templates. Returns IDs, names, slugs, detected variables, and format settings.
Annotations: readOnlyHint: true · destructiveHint: false
| Parameter | Required | Description |
|---|---|---|
api_key | Yes | Your PDF4.dev API key |
Example prompt: "Show me all my PDF templates"
get_template
Get full template details including the HTML source, sample data, and PDF format configuration.
Annotations: readOnlyHint: true · destructiveHint: false
| Parameter | Required | Description |
|---|---|---|
api_key | Yes | Your PDF4.dev API key |
id | Yes | Template ID or slug |
Example prompt: "Show me the HTML of my invoice template"
create_template
Create a new HTML template with Handlebars variables. Optionally include sample data and a default PDF format.
Annotations: readOnlyHint: false · destructiveHint: false
| Parameter | Required | Description |
|---|---|---|
api_key | Yes | Your PDF4.dev API key |
name | Yes | Template name |
html | Yes | HTML with {{variables}} |
sample_data | No | Default values for each variable |
Example prompt: "Create a certificate template with name, course, and date fields"
update_template
Update an existing template's HTML, name, sample data, or PDF format settings.
Annotations: readOnlyHint: false · destructiveHint: false · idempotentHint: true
| Parameter | Required | Description |
|---|---|---|
api_key | Yes | Your PDF4.dev API key |
id | Yes | Template ID or slug |
name | No | New template name |
html | No | Updated HTML |
sample_data | No | Updated sample data |
Example prompt: "Add a discount row and QR code to my invoice template"
delete_template
Permanently delete a template. This action cannot be undone.
Annotations: readOnlyHint: false · destructiveHint: true
| Parameter | Required | Description |
|---|---|---|
api_key | Yes | Your PDF4.dev API key |
id | Yes | Template ID or slug |
Example prompt: "Delete the old receipt template"
Info
get_info
Get an overview of your account: template count, detected variables, usage stats. Useful as a first call to understand what's available.
Annotations: readOnlyHint: true · destructiveHint: false
| Parameter | Required | Description |
|---|---|---|
api_key | Yes | Your PDF4.dev API key |
Example prompt: "What templates do I have and how many PDFs have I generated?"
Components
list_components
List all reusable components (headers, footers, blocks). Filter by type optionally.
Annotations: readOnlyHint: true · destructiveHint: false
| Parameter | Required | Description |
|---|---|---|
api_key | Yes | Your PDF4.dev API key |
type | No | Filter: header, footer, or block |
Example prompt: "Show me all my header components"
get_component
Get a component's full details including HTML source.
Annotations: readOnlyHint: true · destructiveHint: false
| Parameter | Required | Description |
|---|---|---|
api_key | Yes | Your PDF4.dev API key |
component_id | Yes | Component ID (comp_xxx) |
Example prompt: "Show me the HTML of my company header component"
create_component
Create a reusable header, footer, or block component. Components are div fragments that inherit parent template styles. In footers, use <span class="pageNumber"></span> and <span class="totalPages"></span> for page numbers.
Annotations: readOnlyHint: false · destructiveHint: false
| Parameter | Required | Description |
|---|---|---|
api_key | Yes | Your PDF4.dev API key |
name | Yes | Component name |
type | Yes | header, footer, or block |
html | No | HTML with {{variables}} |
Example prompt: "Create a footer component with page numbers and my company name"
update_component
Update a component's name or HTML.
Annotations: readOnlyHint: false · destructiveHint: false · idempotentHint: true
| Parameter | Required | Description |
|---|---|---|
api_key | Yes | Your PDF4.dev API key |
component_id | Yes | Component ID (comp_xxx) |
name | No | New name |
html | No | Updated HTML |
Example prompt: "Update my header to include a logo on the right side"
delete_component
Permanently delete a component. Templates using it will no longer display it.
Annotations: readOnlyHint: false · destructiveHint: true
| Parameter | Required | Description |
|---|---|---|
api_key | Yes | Your PDF4.dev API key |
component_id | Yes | Component ID (comp_xxx) |
Example prompt: "Delete the old footer component"
Analytics
list_logs
View PDF generation history. Filter by status and limit results. Useful for debugging and monitoring usage.
Annotations: readOnlyHint: true · destructiveHint: false
| Parameter | Required | Description |
|---|---|---|
api_key | Yes | Your PDF4.dev API key |
limit | No | Number of entries (default: 20) |
status | No | success or error |
Example prompt: "Show me my last 10 PDF generations and any failures"