DocuGenerate MCP Server

DocuGenerate MCP Server

A local MCP server that wraps the DocuGenerate API to generate documents (invoices, contracts, letters) from templates via natural language commands.

Category
访问服务器

README

DocuGenerate MCP Server

A local Model Context Protocol server that wraps the DocuGenerate document-generation API, so Claude Desktop can generate documents (invoices, contracts, letters) from your templates — just by asking.

This is a local demo build: TypeScript, the official MCP SDK, and STDIO transport. You register it in Claude Desktop and it runs on your machine.

The productionised “official” version would instead be a remote HTTP MCP server with OAuth — this local stdio build is deliberately the demo shape.

Tools

Tool Args Returns
list_templates (optional) name_contains Each template's id, name, and merge_fields (the tags to supply).
get_template_fields template_id Merge fields for one template (fallback / double-check).
generate_document template_id, data (object of field→value), format? = pdf | docx (default pdf) A hosted URL to the generated document (a link, not binary).

How it maps to the DocuGenerate API

Confirmed against the API Quick Start and live probes of api.docugenerate.com:

  • Base URL: https://api.docugenerate.com/v1
  • Auth header: Authorization: <API Key> — the raw key, no Bearer prefix.
  • GET /template → list templates (each has id, name, tags.valid = merge fields)
  • GET /template/{id} → one template
  • POST /document with { template_id, data: [ {...} ], output_format: ".pdf" } → responds with document_uri (the hosted document link).

Setup

Requires Node 20+.

npm install
npm run build      # compiles to dist/ via tsc

Get your API key from the DocuGenerate Settings page (https://app.docugenerate.com).

Before the demo: create at least one template in the DocuGenerate dashboard — for the prompts below, make an “Invoice” template with merge tags such as Company Name, Invoice Number, Date, Due Date, Line Items, and Total. list_templates will report each template's exact merge fields.

Register in Claude Desktop

Edit claude_desktop_config.json:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Add this server (use the absolute path to the built dist/index.js):

{
  "mcpServers": {
    "docugenerate": {
      "command": "node",
      "args": ["/absolute/path/to/DocuGenerate-mcp/dist/index.js"],
      "env": {
        "DOCUGENERATE_API_KEY": "your_api_key_here"
      }
    }
  }
}

Then fully quit and reopen Claude Desktop. The docugenerate tools appear under the 🔌 / tools menu.

Demo prompts

Once registered, try these in Claude Desktop:

  1. “List my DocuGenerate templates.”
  2. “Generate an invoice from the Invoice template for Acme Corp — 3 line items: Design $1200, Development $3400, Hosting $200 — due in 30 days.”
  3. “Now generate the same as a DOCX.”

Claude will call list_templates to discover the Invoice template and its fields, then generate_document (PDF, then DOCX) and hand you back the document URLs.

Local testing (without Claude Desktop)

You can drive the server over stdio directly. Set the key and run the smoke test:

export DOCUGENERATE_API_KEY=your_api_key_here
npm run build
node dist/index.js   # server waits for MCP JSON-RPC on stdin; Ctrl-C to exit

A quick end-to-end generate_document smoke test (replace TEMPLATE_ID with a real id from list_templates):

export DOCUGENERATE_API_KEY=your_api_key_here
TEMPLATE_ID=your_template_id node --input-type=module -e '
import { spawn } from "node:child_process";
const srv = spawn("node", ["dist/index.js"], { env: process.env });
let buf = "";
srv.stdout.on("data", d => { buf += d.toString();
  for (const line of buf.split("\n")) { if (!line.trim()) continue;
    try { const m = JSON.parse(line);
      if (m.id === 2) { console.log(m.result.content[0].text); srv.kill(); process.exit(0); }
    } catch {} }
});
srv.stderr.on("data", d => process.stderr.write("[srv] " + d));
const send = o => srv.stdin.write(JSON.stringify(o) + "\n");
send({ jsonrpc:"2.0", id:1, method:"initialize", params:{ protocolVersion:"2024-11-05", capabilities:{}, clientInfo:{ name:"cli", version:"0" } } });
send({ jsonrpc:"2.0", method:"notifications/initialized" });
send({ jsonrpc:"2.0", id:2, method:"tools/call", params:{ name:"generate_document",
  arguments:{ template_id: process.env.TEMPLATE_ID,
    data: { "Company Name": "Acme Corp", "Total": "$4,800" }, format: "pdf" } } });
setTimeout(() => { srv.kill(); process.exit(1); }, 15000);
'

Error handling

Every tool returns a readable error instead of crashing. Failures surface the HTTP status and the DocuGenerate error body, with a hint for the common cases:

  • 401 / 403 → “check that DOCUGENERATE_API_KEY is set to a valid key…”
  • 404 → “the template_id may be wrong or deleted. Use list_templates…”
  • 429 → “rate limit hit; wait a moment and try again.”
  • Network/DNS/TLS failures and non-JSON responses are also caught and reported.

Troubleshooting

  • generate_document returns a 500 “Cannot read properties of undefined (reading 'length')”. This is a DocuGenerate-side error that means the template file is malformed — a hand-assembled .docx missing the standard Office parts (styles.xml, settings.xml, etc.) will upload fine but fail at render time. Fix: author the template in Microsoft Word / Google Docs (or upload it through the DocuGenerate dashboard) so it's a complete .docx, then re-upload. A normal Word-authored invoice template works.

Configuration

Env var Required Default
DOCUGENERATE_API_KEY
DOCUGENERATE_BASE_URL https://api.docugenerate.com/v1

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选