PDF4.dev

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.

AnnotationMeaning
readOnlyHint: trueTool only reads data, never modifies anything
destructiveHint: trueTool may permanently delete or overwrite data
idempotentHint: trueCalling the tool multiple times with the same input has no additional effect
openWorldHint: trueTool 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

ParameterRequiredDescription
api_keyYesYour PDF4.dev API key
template_idOne of theseTemplate ID or slug
htmlOne of theseRaw HTML string
dataNoKey-value pairs for {{variables}}
format_presetNoa4, 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

ParameterRequiredDescription
api_keyYesYour PDF4.dev API key
template_idOne of theseTemplate ID or slug
htmlOne of theseRaw HTML string
dataNoKey-value pairs for {{variables}}
format_presetNoa4, 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

ParameterRequiredDescription
api_keyYesYour 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

ParameterRequiredDescription
api_keyYesYour PDF4.dev API key
idYesTemplate 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

ParameterRequiredDescription
api_keyYesYour PDF4.dev API key
nameYesTemplate name
htmlYesHTML with {{variables}}
sample_dataNoDefault 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

ParameterRequiredDescription
api_keyYesYour PDF4.dev API key
idYesTemplate ID or slug
nameNoNew template name
htmlNoUpdated HTML
sample_dataNoUpdated 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

ParameterRequiredDescription
api_keyYesYour PDF4.dev API key
idYesTemplate 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

ParameterRequiredDescription
api_keyYesYour 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

ParameterRequiredDescription
api_keyYesYour PDF4.dev API key
typeNoFilter: 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

ParameterRequiredDescription
api_keyYesYour PDF4.dev API key
component_idYesComponent 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

ParameterRequiredDescription
api_keyYesYour PDF4.dev API key
nameYesComponent name
typeYesheader, footer, or block
htmlNoHTML 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

ParameterRequiredDescription
api_keyYesYour PDF4.dev API key
component_idYesComponent ID (comp_xxx)
nameNoNew name
htmlNoUpdated 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

ParameterRequiredDescription
api_keyYesYour PDF4.dev API key
component_idYesComponent 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

ParameterRequiredDescription
api_keyYesYour PDF4.dev API key
limitNoNumber of entries (default: 20)
statusNosuccess or error

Example prompt: "Show me my last 10 PDF generations and any failures"