PolyDoc for AI agents (MCP)
Model Context Protocol (MCP) is an open standard that lets AI
assistants and agents call external tools directly. polydoc-mcp is an MCP server that exposes
PolyDoc's PDF, screenshot, and e-invoice generation as tools an agent can call, so it can produce a
real, downloadable file instead of describing one.
Installation
Requires Node.js 20.15 or later. The server is published to npm and runs with
npx, no install step required:npx -y polydoc-mcp
Configuration
The server is configured entirely through environment variables.
| Variable | Required | Default | Description |
|---|---|---|---|
POLYDOC_API_KEY | yes | - | Your API key from dashboard.polydoc.tech. |
POLYDOC_SANDBOX | no | false | Default sandbox mode (watermarked output, does not use production quota). A tool call can override this per request. |
POLYDOC_BASE_URL | no | https://api.polydoc.tech | Override for self-hosted or staging use. |
POLYDOC_OUTPUT_DIR | no | OS temp dir + /polydoc | Where downloaded files are written. Output never escapes this folder. |
Claude Desktop
Add to
claude_desktop_config.json (Settings > Developer > Edit Config):{
"mcpServers": {
"polydoc": {
"command": "npx",
"args": ["-y", "polydoc-mcp"],
"env": {
"POLYDOC_API_KEY": "your-key"
}
}
}
}
Claude Code
claude mcp add polydoc -e POLYDOC_API_KEY=your-key -- npx -y polydoc-mcp
Cursor
Add the same
mcpServers block shown above to ~/.cursor/mcp.json, or to a project-level .cursor/mcp.json.Available tools
| Tool | What it does |
|---|---|
polydoc_html_to_pdf | Renders a URL, raw HTML, or a saved template to PDF. Supports layout, margins, page format, page ranges, bookmarks, and accessible/tagged PDF output. |
polydoc_screenshot | Renders a URL, raw HTML, or a saved template to PNG, JPEG, or WebP, with viewport and device-pixel-ratio control. Returns an inline image preview when small enough for the client to display. |
polydoc_generate_einvoice | Generates a Factur-X or ZUGFeRD hybrid PDF/A-3 from structured invoice data, with profiles from minimum to extended. |
polydoc_test_credentials | Verifies the configured API key with a minimal sandbox render. Never uses production quota. |
Content for the PDF and screenshot tools can come from a URL, an inline HTML string, or a saved template (with Liquid
templateData), exactly as in the REST API. Every tool also accepts an advanced object that is merged into the request body, so any API capability not exposed as a typed field (for example pdf.watermark, pdf.encryption, or render options) is still reachable. See the full field reference for everything the underlying API accepts.Output and delivery
- Download (default): the file is written under
POLYDOC_OUTPUT_DIRand the tool returns the absolute path plus metadata (size, conversion id, credits used). Screenshots also return an inline image block. PassreturnBase64: trueto receive the raw bytes as base64 instead, for clients without filesystem access. - Cloud storage: set
delivery: "cloudStorage"with apresignedUrlto have PolyDoc upload directly to your own S3, GCS, Azure Blob, Backblaze B2, or Wasabi bucket. See the cloud storage guide for the presigned-URL setup on each provider. - Webhook: set
delivery: "webhook"with awebhookobject ({ url, async?, method?, headers? }) for HMAC-signed asynchronous delivery.
What an agent can do with this
Once configured, you can ask an agent things like:
- "Render this HTML as a PDF and save it to my Downloads folder."
- "Take a full-page screenshot of https://example.com at 2x device pixel ratio."
- "Generate a PDF from my
invoicetemplate with this data, tagged as accessible PDF/UA." - "Check that my PolyDoc API key works before I run the rest of this workflow."
Source
polydoc-mcp is MIT-licensed and open source, with
worked examples for each tool in the repository's examples/ folder.