@cyanheads/docgen-mcp-server
Click on "Install 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.
Why docgen
An agent can write a perfect invoice's HTML, a clean data table, or a filled-form field map as tokens — but it cannot emit bytes. docgen is the renderer that closes the gap: structured content in, a downloadable binary document out. It wraps no external API; the "service" is a bundled rendering stack (pdf-lib for PDF and form fill, exceljs for spreadsheets, marked for the markdown path). Every output is stored tenant-scoped with a short TTL and handed back as a stable resource URI plus inline base64 when small enough.
Related MCP server: pymupdf4llm-mcp
Tools
Four tools sharing one delivery shape — three renderers that write a stored document and one read that re-fetches by id. Every render/export/fill call returns a DocumentEnvelope (a documentId, a docgen://document/{id} resource URI, byte size, TTL, and inline base64 when the artifact is small enough); docgen_get_document returns the same envelope for an id you already hold.
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. |
| Re-fetch a previously rendered document by the id a render/export/fill tool returned. |
docgen_render_pdf
Render content to a downloadable PDF.
Provide exactly one
source:{ html }(raw HTML you compose — the recommended path),{ markdown }(converted to HTML, then rendered), or{ template, data }(a{{key}}template filled from a data object, with server-owned layout)pageOptionscontrol size (A4/Letter/Legal/A3/A5, defaultLetter), orientation, per-side margins (CSS lengths like"10mm","0.5in","72pt"), header/footer text (supporting the{{page}},{{total}},{{date}}tokens), and automatic page numbersThe lightweight engine renders structured layout (headings, paragraphs, lists, tables) but not arbitrary CSS — a
degradedenrichment flag is set when unsupported styling is dropped, so the agent isn't misled about fidelityReturns a
DocumentEnvelopewithpageCount
docgen_export_spreadsheet
Render tabular data to an .xlsx workbook — the natural export stage for rows pulled from another server.
Each entry in
sheets[]is a worksheetnameplus an array of row objects (property → scalar string / number / boolean / null)An optional per-column spec sets the header label, value
type(string/number/date/boolean), column width, and an Excel number/date format string (e.g."#,##0.00","yyyy-mm-dd"); when omitted, columns derive from the first row's keysAn empty
rowsarray yields a header-only sheet; an emptysheets[]is rejected (empty_workbook)Returns a
DocumentEnvelopewithsheetCount
docgen_fill_form
Fill the AcroForm fields of a supplied PDF and optionally flatten it.
Provide the source as exactly one of
{ base64 }or{ url }— an https URL fetched behind an SSRF guard (private/loopback/link-local ranges blocked,application/pdfrequired, response size capped); base64 avoids the fetch entirelyfieldsis an AcroForm field name → value map; names must match the PDF's internal field names exactly (case-sensitive), obtained from whoever supplied the form (docgen does not expose them)Names with no AcroForm counterpart come back in
unmatchedFields[]rather than failing the call — correct them and re-renderSet
flatten: trueto bake the values in so the result is no longer editableAcroForm only — XFA-based PDFs (some government forms) report
not_a_formReturns a
DocumentEnvelopewithpageCount, plusunmatchedFields[]
docgen_get_document
Re-fetch a stored document by id.
The
documentIdis obtainable only from an earlierdocgen_render_pdf,docgen_export_spreadsheet, ordocgen_fill_formresult — it is not guessable or constructibleUse it to recover a document whose inline copy was dropped (over the inline size limit) while it is still within its TTL
An expired or unknown id returns
document_expired; ids are single-render and not reusable
Resources
Type | Name | Description |
Resource |
| A rendered document by id — the raw bytes as a |
The resource is the stable-URI delivery surface for hosts that support resources. All document data is also reachable via the tool surface — docgen_get_document is the tool-only twin of this resource, reading the same store and returning the same envelope. Neither re-renders.
Features
Built on @cyanheads/mcp-ts-core:
Declarative tool and resource definitions — single file per primitive, framework handles registration and validation
Unified error handling — handlers throw, framework catches, classifies, and formats
Pluggable auth:
none,jwt,oauthSwappable storage backends:
in-memory,filesystem,Supabase,Cloudflare KV/R2/D1Structured logging with optional OpenTelemetry tracing
STDIO and Streamable HTTP transports
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 all four tools — the three writers and the reader are interchangeable to the agent, and the resource-URI vs. inline-base64 delivery is decided in one placeBounded 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 —
docgen_fill_formwith a URL source resolves DNS and checks the destination IP before fetching, blocking private/loopback/link-local ranges
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 text
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.3.2 or higher (or Node.js v24+).
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. |
|
| Auth mode: |
|
| Public origin behind a TLS proxy. (The | — |
| Log level (RFC 5424). |
|
| Storage backend for document bytes + metadata. |
|
| Enable OpenTelemetry instrumentation (spans, metrics, completion logs). |
|
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 and pull requests 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 installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
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.Last updated1346139MIT

pymupdf4llm-mcpofficial
Alicense-qualityBmaintenanceMCP server for exporting PDF to markdown, optimized for LLM consumption.Last updated69AGPL 3.0- Alicense-qualityDmaintenanceMCP Server for Markdown to PDF conversion.Last updatedMIT
- Alicense-qualityDmaintenanceConverts Markdown files and content to styled PDFs with S3 integration, Mermaid diagrams, and ApexCharts support, supporting stdio, HTTP, and SSE transport modes.Last updated348MIT
Related MCP Connectors
Generate PDF/DOCX/XLSX/PPTX from templates+JSON. Convert Office/HTML/MD to PDF. Universal templating
Query SEC EDGAR filings, XBRL financials, and company data through MCP. STDIO & Streamable HTTP.
Render HTML, Markdown, or URLs to images, PDF, or branded artifacts; extract and watch pages.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/cyanheads/docgen-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server