MCP server
Give the PDF tools to your AI agents (Claude and others).
@pdfforge/mcp is a Model Context Protocol server that exposes the pdfforge
toolbox to AI agents — Claude Code, Claude Desktop, Cursor, or any MCP
client. The agent works with file paths; the server handles upload,
base64 and saving results.
Setup
Add the server to your MCP client config (example for Claude Code / Claude Desktop):
{
"mcpServers": {
"pdfforge": {
"command": "npx",
"args": ["-y", "@pdfforge/mcp"],
"env": {
"PDFFORGE_API_KEY": "pf_live_..."
}
}
}
}| Env variable | Description |
|---|---|
PDFFORGE_API_KEY | Required. Your API key. |
PDFFORGE_BASE_URL | Optional API override (staging, self-hosted). |
PDFFORGE_OUTPUT_DIR | Where generated PDFs/images are written (default: the OS temp dir). |
The tools
Generation
| Tool | What it does |
|---|---|
generate_pdf_from_html | HTML string → PDF file (Tailwind supported). |
generate_pdf_from_template | Stored template + JSON data → PDF. |
list_templates / get_template | Discover templates and their data schema. |
Operations
| Tool | What it does |
|---|---|
merge_pdfs | Merge files by path, in order. |
split_pdf | One file per page. |
pdf_to_image | Rasterize pages to PNG — how the agent looks at a document. |
strip_pdf_watermark | Structurally remove overlay watermarks. |
The perceive → act loop
| Tool | What it does |
|---|---|
pdf_perceive | Call this first. Structured map: elements with stable ids, text, bboxes, semantic labels (email, phone, iban, amount...), logical regions (header, line_items_table, signature_area...). |
edit_pdf_text | Rewrite elements by perceived id — design stays intact; works on vector text and OCR/scanned spans. |
redact_pdf | True redaction by element ids, regex pattern, semantics labels, or raw regions. flatten: true rasterizes for scans. |
place_signature | Burn a signature image, anchored to text (anchor_text) or the perceived signature_area. |
PDF templates (the import flow)
| Tool | What it does |
|---|---|
create_pdf_template | Mark perceived elements as variables → a reusable template from ANY designed PDF. |
fill_pdf_template | Render a stored PDF template with values. |
list_pdf_templates | Discover templates and their variables. |
Perceive first
The action tools (edit_pdf_text, redact_pdf, place_signature,
create_pdf_template) act on the ids and bboxes returned by
pdf_perceive. Ids change after every edit — re-perceive between
operations on the same file. The server caches perceptions per file and
guards against silently corrupted output (an edit that would destroy
unrelated text is aborted).
Example session
A prompt like this is enough — the agent chains the tools itself:
Take ~/Documents/contract.pdf: redact every email address and phone number,
place my signature (~/Documents/signature.png) under "Le Directeur",
then show me page 1.→ pdf_perceive → redact_pdf (semantics: ["email", "phone"]) →
place_signature (anchor "Le Directeur") → pdf_to_image.
Next steps
- Inspect — the perception layer these tools are built on.
- Import a PDF — the template flow
behind
create_pdf_template. - n8n — no-code automation instead.