agentic-doc
v0.1.2
Published
Render HTML templates to local HTML or Cloudflare Browser Rendering PDFs with a CLI, MCP server, and agent library.
Maintainers
Readme
agentic-doc
agentic-doc is an open-source HTML template renderer for Node.js developers and agents that writes local HTML or Cloudflare Browser Rendering PDFs.
Install
npm install agentic-docRequires Node.js 18 or later. Includes TypeScript declarations and two runtime dependencies.
Render your first document
cat > template.html <<'HTML'
<h1>Hello {{name}}</h1>
HTML
printf '{"name":"Ada"}' > slots.json
npx agentic-doc render --template template.html --slots slots.json --output result.html
npx agentic-doc render --template template.html --slots slots.json --output result.html --live
cat result.htmlThe first command previews JSON with dryRun: true and writes nothing.
The second writes local HTML. The final command prints <h1>Hello Ada</h1>.
Features and coverage
- Template slots: Replace
{{name}}placeholders with string values; missing slots raise errors. - Preview: Inspect filled HTML before file writes or vendor calls.
- HTML output: Write a local file without credentials.
- PDF output: Send filled HTML to Cloudflare Browser Rendering.
| Output | Provider | Status | | --- | --- | --- | | HTML | Local filesystem | Implemented; local tests | | PDF | Cloudflare Browser Rendering | Implemented; mocked HTTP test; live credentials unverified |
For PDFs, export CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID.
The package does not load .env files; load them before running the command.
npx agentic-doc render --template template.html --slots slots.json --output result.pdf --format pdf --liveSuccess returns JSON with vendor: "cloudflare" and writes result.pdf.
Library and agent tools
import { renderDocument } from "agentic-doc";
const result = await renderDocument({
template: "template.html",
slots: { name: "Ada" },
output: "result.html",
});
console.log(result.html); // <h1>Hello Ada</h1>Set dryRun: false to write files. PDF requests also require live: true.
The CLI supports render, --help, and --version.
Run npx --package agentic-doc agentic-doc-mcp for the Model Context Protocol (MCP) stdio server.
Its single tool is render_document, with the same request fields and dry-run default.
Limits and status
Slot values are inserted verbatim; escape untrusted HTML yourself. The PDF request has no built-in retry or explicit timeout. The Worker source contains text-summary scaffolding, not a document-rendering service. Version 0.1.1 has an API that may change. No managed rendering service is included.
