
Docgen Mcp Server
io.github.cyanheads由 GitHub 账号 cyanheads 发布v0.3.0更新于 Oct 27, 2026
Render HTML/markdown to PDF, export rows to xlsx, and fill AcroForm PDFs.
概览
本地 MCP 服务器,让助手把 HTML、Markdown 或模板渲染成 PDF、把数据行导出为 xlsx,并填写 AcroForm PDF 表单。
- 可以做什么
- 把 HTML、Markdown 或 {{key}} 模板连同页面选项渲染为可下载的 PDF
- 把一个或多个命名工作表的行对象导出为 xlsx 工作簿
- 在不修改 PDF 的前提下查看 AcroForm 字段名、类型、必填标记和选项
- 用 base64 或 https 链接提供的 PDF 填写 AcroForm 字段,可选择扁平化
- 按 id 重新获取此前渲染的文档,可通过工具或文档资源读取
- 适用场景
- 适合助手需要根据已有数据生成可交付文件(报告、发票、填写好的业务或政务表单、表格导出)而不调用外部渲染 API 的场景。
- 运行要求
- 通过 npx、bunx 或 Docker 在本地以 stdio(或 Streamable HTTP)运行;需要 Bun v1.4.0 以上或 Node.js v24 以上。无需 API 密钥,所有配置变量均为可选。默认使用内存存储,重启后文档丢失。
安装
在 SourceWeft 中
- 打开 控制台中的 Docgen Mcp Server,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
@cyanheads/docgen-mcp-server
Render HTML/markdown to PDF, export rows to xlsx, and fill AcroForm PDFs via MCP. STDIO or Streamable HTTP.
Overview
Generate documents from an agent: render HTML, markdown, or template data to PDF, export rows to Excel, and fill PDF forms. Everything renders locally on a bundled stack (pdf-lib, exceljs, marked).
Tools
Resources
All document data is also reachable via the tool surface — docgen_get_document is the tool-only twin of this resource.
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: truemeans CSS, images or scripts were dropped, or characters were replaced with?. 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 columns accept
true/1/yes/onandfalse/0/no/off, case-insensitive; other strings stay 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 fail - One shared
DocumentEnvelopeacross the four document delivery tools; field inspection returns its inventory directly - Bounded renders — a byte ceiling (
DOCGEN_MAX_DOCUMENT_BYTES) and a timeout (DOCGEN_RENDER_TIMEOUT_MS) turn a runaway render into a typed error instead of a hang - Tenant-scoped, expiring storage — a document id resolves only for the tenant that created it, and documents expire rather than accumulate
- SSRF-guarded form fetch — both form tools check every address, including each redirect hop, and block private, loopback and link-local destinations
Agent-friendly output:
- Dual-surface delivery — every envelope field appears in both
structuredContentand the markdown output, including thedocumentId, resource URI, size, and TTL - Inline by size —
inlineBase64is populated only at or underDOCGEN_INLINE_MAX_BYTES; larger documents are delivered through the resource URI - Partial-fill reporting —
docgen_fill_formreturnsunmatchedFields[]so the agent sees which field names didn't match - Typed errors with recovery hints (
invalid_source,template_render_failed,document_too_large,render_timeout,not_a_form,source_unfetchable,document_expired, …); semantic validation usesValidationError(-32007) and malformed argumentsInvalidParams(-32602)
Getting started
Add the following to your MCP client configuration file. No API keys are required.
Or with npx (no Bun required):
Or with Docker:
For Streamable HTTP, set the transport and start the server:
Documents 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:
- Navigate into the directory:
- Install dependencies:
- Configure environment:
Configuration
All configuration is optional — docgen runs with no required environment variables.
See .env.example for the full list of optional overrides.
The default in-memory storage drops every document on restart, and earlier ids then return
document_expired. To keep documents across restarts, pointSTORAGE_PROVIDER_TYPEat a persistent backend.
Running the server
Local development
-
Build and run:
-
Run checks and tests:
Docker
The 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
Development guide
See CLAUDE.md/AGENTS.md for development guidelines and architectural rules. The short version:
- Handlers throw, framework catches — no
try/catchin tool logic - Use
ctx.logfor request-scoped logging,ctx.statefor tenant-scoped storage - Register new tools and resources in
src/index.ts'screateApp()arrays - One shared
DocumentEnvelopeacross all delivery tools — keep the writers and reader interchangeable
Contributing
Issues are welcome. Run checks and tests before submitting:
License
Apache-2.0 — see LICENSE for details.
来源:README.md,提交 702ad4a
工具
0版本历史
4- v0.3.0最新Oct 13, 2026
- v0.2.4Oct 7, 2026
- v0.2.3Sep 22, 2026
- v0.2.2Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分