@cyanheads/docgen-mcp-server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@@cyanheads/docgen-mcp-serverConvert this markdown to PDF: ## Meeting Notes"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Overview
Document rendering built on a bundled stack — pdf-lib for PDF and AcroForm fill, exceljs for spreadsheets, marked for markdown. Render HTML, markdown, or template data to PDF, export tabular rows to xlsx, and fill AcroForm PDF forms from any MCP client. Runs as a stdio process or a local Streamable HTTP server.
Tools
Tool | Description |
| Render HTML, markdown, or a |
| Render one or more named worksheets of row objects to a downloadable |
| Fill the AcroForm fields of a supplied PDF (base64 or https URL) and optionally flatten it |
| Inspect exact AcroForm field names, types, required flags and choice options without changing the PDF |
| Re-fetch a previously rendered document by the id a render/export/fill tool returned |
Resources
Resource | Description |
| A rendered document by id — raw bytes as a blob plus a JSON metadata block |
All document data is also reachable via the tool surface — docgen_get_document is the tool-only twin of this resource.
Related MCP server: md2pdf-mcp
Capability reference
docgen_render_pdf tool
Provide exactly one
source:{ html },{ markdown }, or{ template, data }for{{key}}interpolation.pageOptionscontrols page size/orientation, CSS-length margins, headers/footers ({{page}},{{total}},{{date}}) and page numbers.Returns a
DocumentEnvelopewithpageCount;degraded: truesignals dropped CSS, images or scripts, or character replacement with?on body text, tables, headers or footers. Supported Latin-1 and existing smart-punctuation transliteration remain non-degraded. The lightweight engine renders headings, paragraphs, lists and tables.Typed failures:
invalid_source,template_render_failed,document_too_large,render_timeout.
docgen_export_spreadsheet tool
Supply at least one sheet with a unique
name(1–31 characters) and scalarrows[]; empty rows yield a header-only sheet. Optionalcolumns[]sets headers, type (string/number/date/boolean), width and Excel format.Omitted columns use all row keys in first-seen order. Boolean strings are trimmed and case-insensitive:
true/1/yes/onandfalse/0/no/off/empty; unknown strings stay text. Blank numeric strings stay blank, and numeric date values stay decimal text.Returns a
DocumentEnvelopewithsheetCount. Typed failures:empty_workbook,invalid_sheet_name,document_too_large,render_timeout.
docgen_fill_form tool
Provide exactly one
sourcePdf:{ base64 }or{ url }(public https servingapplication/pdf), plusfieldsmapping exact, case-sensitive AcroForm field names to values. Flat or XFA-only PDFs returnnot_a_form.Obtain exact names and choice options with
docgen_list_form_fieldsbefore filling an unfamiliar PDF.Returns a
DocumentEnvelopewithpageCountandunmatchedFields[]for names with no matching field.flatten: truemakes the filled values non-editable (defaultfalse).
docgen_list_form_fields tool
Accepts the same
sourcePdfbase64-or-URL source asdocgen_fill_form. Returns{ fields: [{ name, type, required, options? }] }without modifying the PDF or storing a document.Types:
text,checkbox,dropdown,optionList,radioGroup,signature,button. Only dropdown, optionList and radioGroup entries includeoptions; signatures and buttons are discovery only.Nested names retain their exact paths. PDFs without AcroForm fields return
not_a_form.
docgen_get_document tool
Supply the
documentIdan earlier render/export/fill returned (doc_plus 24 url-safe characters).Re-fetches its
DocumentEnvelopewithout rendering again; an expired or unknown id returnsdocument_expired.
docgen://document/{documentId} resource
Use the
documentIdfrom a render/export/fill result (doc_plus 24 url-safe characters).Returns a base64
blobwith the document's MIME type and JSON metadata (documentId,byteSize,pageCount/sheetCount,createdAt,ttlSecondsRemaining). Reads the same store asdocgen_get_document; expired or unknown ids returndocument_expired.
Features
Built on @cyanheads/mcp-ts-core: stdio and Streamable HTTP transports, pluggable auth (none / jwt / oauth), swappable storage (in-memory, filesystem, Supabase, Cloudflare KV/R2/D1), structured logging with optional OpenTelemetry tracing.
docgen-specific:
No external API — a bundled rendering stack (
pdf-lib,exceljs,marked), so renders are local and deterministic with no upstream to failOne shared
DocumentEnvelopeacross the four document delivery tools; field inspection returns its inventory directlyBounded renders — a per-document byte ceiling (
DOCGEN_MAX_DOCUMENT_BYTES) and a wall-clock timeout (DOCGEN_RENDER_TIMEOUT_MS) turn a runaway render into a typed, recoverable error instead of a hangTenant-scoped, TTL-bounded storage — a document id minted for one tenant resolves only for that tenant; outputs are downloads, not records, so they expire rather than accumulate
SSRF-guarded form fetch — both form tools vet every resolved address at each HTTPS redirect hop and open a fresh connection only to a vetted destination, preserving TLS identity and HTTP Host; private, loopback and link-local destinations are blocked
Agent-friendly output:
Dual-surface delivery — every envelope field lands in both
structuredContentand theformat()markdown twin, so tool-only and resource-only clients both see thedocumentId, resource URI, inline-availability status, size, and TTLInline-vs-resource by size —
inlineBase64is populated only at or underDOCGEN_INLINE_MAX_BYTES, so a large workbook isn't base64-inlined into a tool result; above the threshold, delivery is via the resource URIPartial-fill reporting —
docgen_fill_formreturnsunmatchedFields[]so the agent learns which field names didn't land and can correct and re-render rather than assuming a clean fillTyped error contract with recovery hints — each tool declares its failure surface (
invalid_source,template_render_failed,document_too_large,render_timeout,not_a_form,source_unfetchable,document_expired, …) with actionable next-step textSemantic validation uses
ValidationError(-32007); malformed arguments useInvalidParams(-32602). Fetch errors remainServiceUnavailable, timeoutsTimeout, and expired documentsNotFound.
Getting started
Add the following to your MCP client configuration file. No API keys are required.
{
"mcpServers": {
"docgen-mcp-server": {
"type": "stdio",
"command": "bunx",
"args": ["@cyanheads/docgen-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info"
}
}
}
}Or with npx (no Bun required):
{
"mcpServers": {
"docgen-mcp-server": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@cyanheads/docgen-mcp-server@latest"],
"env": {
"MCP_TRANSPORT_TYPE": "stdio",
"MCP_LOG_LEVEL": "info"
}
}
}
}Or with Docker:
{
"mcpServers": {
"docgen-mcp-server": {
"type": "stdio",
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "MCP_TRANSPORT_TYPE=stdio",
"ghcr.io/cyanheads/docgen-mcp-server:latest"
]
}
}
}For Streamable HTTP, set the transport and start the server:
MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 bun run start:http
# Server listens at http://localhost:3010/mcpDocuments are delivered by the docgen://document/{id} resource (and inline base64 when small enough) over every transport. The envelope's downloadUrl field is reserved for a future HTTP download route and is not emitted in this version.
Prerequisites
Bun v1.4.0 or higher (or Node.js v24+); development uses Bun v1.4.3.
Installation
Clone the repository:
git clone https://github.com/cyanheads/docgen-mcp-server.gitNavigate into the directory:
cd docgen-mcp-serverInstall dependencies:
bun installConfigure environment:
cp .env.example .env
# edit .env to override any defaultsConfiguration
All configuration is optional — docgen runs with no required environment variables.
Variable | Description | Default |
| How long a rendered document is retrievable before it expires, in seconds. |
|
| Hard ceiling on a single rendered artifact in bytes; exceeding it aborts the render. |
|
| Per-render wall-clock budget in milliseconds; exceeding it aborts the render. |
|
| Artifacts at or under this byte size are returned inline as base64; larger ones omit it. |
|
| PDF rendering engine. Only |
|
| Transport: |
|
| Port for the HTTP server. |
|
| HTTP session posture: |
|
| Auth mode: |
|
| Public origin behind a TLS proxy. (The | — |
| Log level (RFC 5424). |
|
| Log failed arguments/results, redacted by key name and capped by |
|
| Storage backend for document bytes + metadata. |
|
| Enable OpenTelemetry instrumentation (spans, metrics, completion logs). |
|
| Base OTLP URL; traces use | — |
| Opt-in log endpoint, used as-is; the base URL never enables log export. | — |
See .env.example for the full list of optional overrides.
Documents are stored in
ctx.state, which the in-memory provider keeps in process memory — a restart drops every stored document, and an id minted before the restart returnsdocument_expired. This is intended (outputs are downloads, not records); for durable retention across restarts, pointSTORAGE_PROVIDER_TYPEat a persistent backend.
Running the server
Local development
Build and run:
# One-time build bun run rebuild # Run the built server bun run start:stdio # or bun run start:httpRun checks and tests:
bun run devcheck # Lint, format, typecheck, security, changelog sync bun run test # Vitest test suite bun run lint:mcp # Validate MCP definitions against spec
Docker
docker build -t docgen-mcp-server .
docker run --rm -e MCP_TRANSPORT_TYPE=http -p 3010:3010 docgen-mcp-serverThe Dockerfile defaults to HTTP transport, stateless session mode, and logs to /var/log/docgen-mcp-server. OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.
Project structure
Directory | Purpose |
|
|
| Server-specific environment variable parsing and validation with Zod. |
| Tool definitions ( |
| Resource definitions ( |
| The rendering stack ( |
| Unit and integration tests mirroring |
Development guide
See CLAUDE.md/AGENTS.md for development guidelines and architectural rules. The short version:
Handlers throw, framework catches — no
try/catchin tool logicUse
ctx.logfor request-scoped logging,ctx.statefor tenant-scoped storageRegister new tools and resources in
src/index.ts'screateApp()arraysOne shared
DocumentEnvelopeacross all delivery tools — keep the writers and reader interchangeable
Contributing
Issues are welcome. Run checks and tests before submitting:
bun run devcheck
bun run testLicense
Apache-2.0 — see LICENSE for details.
This server cannot be deployed
Maintenance
Related MCP Connectors
HTML and CSS to PDF MCP server with page headers, footers and page numbers. No headless browser.
Generate PDF, Word (.docx) and PowerPoint (.pptx) documents from Markdown over MCP.
MCP server for Api2Pdf — generate PDFs & images from HTML, URLs or office files; merge, barcodes.
Document-to-Markdown MCP server — convert PDF, Office and HTML into LLM-ready Markdown.
Related MCP Servers
- AlicenseBqualityDmaintenanceA universal MCP server for document processing, conversion, and automation. Handle PDF, DOCX, HTML, Markdown, and more through a unified API and toolset.1320 npm140MIT
- MIT
- AlicenseBqualityDmaintenanceConverts Markdown files and content to styled PDFs with S3 integration, Mermaid diagrams, and ApexCharts support, supporting stdio, HTTP, and SSE transport modes.312 npm8MIT

polydoc-mcpofficial
AlicenseNot gradedqualityCmaintenanceMCP server that converts HTML or URLs to PDF, captures screenshots, and generates EU-compliant e-invoices (Factur-X/ZUGFeRD).47 npmMIT