Skip to main content
Glama
Dokmatiq DocGen
by dokmatiq

Dokmatiq DocGen MCP Server

MCP (Model Context Protocol) server that exposes the Dokmatiq DocGen document generation API as tools for AI assistants like Codex, Claude Code, Claude Desktop, Cursor, Continue, Cline, and Hermes.

Use it to generate PDFs, DOCX/ODT documents, Excel workbooks, invoices, e-invoices (ZUGFeRD/XRechnung/Factur-X), receipt exports, signed PDFs, PDF forms, and documents on company letterhead (Briefpapier/Firmenpapier).

Setup

Prerequisites

  • Python 3.11+

  • DocGen API key

Installation

python3.11 -m pip install --user dokmatiq-docgen-mcp

The package requires Python 3.11 or newer. On macOS, the system or Xcode-provided python3 can be too old; use Homebrew Python, pyenv, uv, or another Python 3.11+ runtime if pip cannot find a compatible package.

pip install --user commonly installs the docgen-mcp command into ~/.local/bin. If your MCP client cannot find docgen-mcp, add ~/.local/bin to PATH or use the absolute command path in your MCP config.

Or install from source:

cd mcp
pip install -e .

Running tests

From the repository root, use the checked-in lockfile to install the MCP server and run its stdio/client smoke tests:

uv run --project mcp python -m unittest discover -s mcp/tests -v

Configuration

Set your API key as an environment variable:

export DOCGEN_API_KEY=dk_live_xxx

Optionally override the base URL:

export DOCGEN_BASE_URL=https://custom.api.endpoint.com

Related MCP server: rechnungsapi-mcp

Usage with Claude Desktop

Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "docgen": {
      "command": "/Users/you/.local/bin/docgen-mcp",
      "env": {
        "DOCGEN_API_KEY": "dk_live_xxx"
      }
    }
  }
}

Or using uvx:

{
  "mcpServers": {
    "docgen": {
      "command": "uvx",
      "args": ["dokmatiq-docgen-mcp"],
      "env": {
        "DOCGEN_API_KEY": "dk_live_xxx"
      }
    }
  }
}

Usage with Claude Code

claude mcp add docgen -- docgen-mcp

Set the API key in your environment or .env file.

Usage with Codex

Install the companion skill:

python3 ~/.codex/skills/.system/skill-installer/scripts/install-skill-from-github.py \
  --repo dokmatiq/docgen-sdks \
  --path plugin/skills/dokmatiq-docgen

Then configure an MCP server named docgen using either docgen-mcp, an absolute path such as /Users/you/.local/bin/docgen-mcp, or uvx dokmatiq-docgen-mcp. Make sure DOCGEN_API_KEY is available to the server process.

Usage with Hermes

Add the MCP server to your Hermes config (~/.hermes/config.yaml):

mcp_servers:
  docgen:
    command: "uvx"
    args: ["dokmatiq-docgen-mcp"]
    env:
      DOCGEN_API_KEY: "dk_live_xxx"

Replace dk_live_xxx with your Dokmatiq API key.

Environment Variables in MCP Configs

Do not use shell placeholders such as ${DOCGEN_API_KEY} inside JSON MCP config files unless your specific client documents that it expands them. Many MCP clients pass that value literally to the server, which causes authentication to fail.

Available Tools

Document Generation

Tool

Description

generate_pdf_from_html

Convert HTML to PDF

generate_pdf_from_markdown

Convert Markdown to PDF

generate_document

Generate with template, fields, watermark, output format

compose_document

Compose multi-part document from sections

create_invoice

Create ZUGFeRD-compliant invoice PDF

PDF Tools

Tool

Description

merge_pdfs

Merge multiple PDFs into one

extract_text_from_pdf

Extract all text content

get_pdf_metadata

Get title, author, page count

convert_to_pdfa

Convert to PDF/A archival format

rotate_pdf

Rotate pages

PDF Forms

Tool

Description

inspect_pdf_form

List form fields with types and values

fill_pdf_form

Fill form fields

Digital Signatures

Tool

Description

sign_pdf

Digitally sign with PKCS#12 certificate

verify_pdf_signatures

Verify existing signatures

list_certificates

List uploaded certificates

Templates & Fonts

Tool

Description

list_templates

List uploaded templates

upload_template

Upload ODT/DOCX template

delete_template

Delete a template

list_fonts

List uploaded fonts

Preview

Tool

Description

preview_pdf_page

Render page as PNG image

get_pdf_page_count

Get total page count

Excel Workbooks

Tool

Description

generate_excel

Generate styled XLSX from structured JSON (sheets, columns, formulas, styling, freeze panes)

csv_to_excel

Convert CSV to formatted Excel with auto-filter and styled headers

excel_to_csv

Extract Excel sheet data as CSV

excel_to_json

Extract Excel sheet data as structured JSON with typed values

fill_excel_template

Fill Excel template with values at named cells and ranges

inspect_excel

Inspect workbook metadata (sheet names, row/column counts, named ranges)

E-Invoicing

Tool

Description

validate_zugferd

Validate ZUGFeRD compliance

extract_zugferd

Extract invoice data from ZUGFeRD PDF

validate_xrechnung

Validate XRechnung XML

parse_xrechnung

Parse XRechnung into structured data

detect_xrechnung

Detect XRechnung format

Receipt Recognition (AI-Powered)

Tool

Description

extract_receipt

Extract structured data from receipt image (vendor, totals, VAT, line items, SKR03/04 account)

extract_receipt_async

Submit receipt for async extraction with optional webhook

get_receipt_job

Check async extraction job status

get_receipt_job_result

Get extraction result of completed job

list_receipt_jobs

List all async receipt jobs

receipt_to_document

Extract receipt and generate expense report (PDF/DOCX/ODT)

export_receipts_csv

Export receipts as DATEV-compatible CSV

export_receipts_xlsx

Export receipts as Excel workbook

Example Prompts

Once connected, you can ask Claude:

  • "Generate a PDF from this HTML: <h1>Hello World</h1>"

  • "Create an invoice for ACME GmbH to Kunde AG for 8 hours of consulting at 120€/hour"

  • "Merge these two PDFs together"

  • "Extract the text from this PDF"

  • "Fill the form fields name=Max and date=12.04.2026 in this PDF"

  • "Extract the data from this receipt image -- I need vendor, total, and VAT breakdown"

  • "Analyze these receipts and export them as a DATEV CSV"

  • "Turn this receipt photo into an expense report PDF"

License

MIT

Available Tools

40 tools
compose_documentA

Compose a multi-part document from several sections.

Each part is a dict with: htmlContent, markdownContent, templateName, fields.

Args: parts: List of document parts. Each part can have htmlContent, markdownContent, templateName, fields. watermark: Optional diagonal watermark text overlay. output_format: Output format – PDF, DOCX, or ODT (default: PDF).

Returns: Base64-encoded document bytes.

Inputs: parts (required), watermark, output_format. Returns: result

convert_to_pdfaB

Convert a PDF to PDF/A archival format.

Args: pdf_base64: Base64-encoded PDF file.

Returns: Base64-encoded PDF/A file.

Inputs: pdf_base64 (required). Returns: result

create_invoiceA

Create a ZUGFeRD-compliant invoice PDF with structured e-invoicing data.

Each item in the items list should have: description, unitPrice, and optionally quantity, unit (C62=piece, HUR=hour, DAY=day, KGM=kg), vatRate.

Args: invoice_number: Unique invoice number (e.g. "RE-2026-001"). invoice_date: Invoice date in ISO format (e.g. "2026-04-12"). seller_name: Seller company name. seller_street: Seller street address. seller_zip: Seller postal code. seller_city: Seller city. buyer_name: Buyer company name. buyer_street: Buyer street address. buyer_zip: Buyer postal code. buyer_city: Buyer city. items: Line items – each with description, unitPrice, and optionally quantity, unit, vatRate. iban: Payment IBAN. bic: Payment BIC/SWIFT code. payment_terms: Payment terms text. due_date: Payment due date (ISO format). seller_vat_id: Seller VAT ID. seller_country: Seller country code (default: DE). buyer_country: Buyer country code (default: DE). buyer_vat_id: Buyer VAT ID. currency: Currency code (default: EUR). template_name: Template name for the invoice layout. html_content: HTML content for the invoice body.

Returns: Base64-encoded PDF with embedded ZUGFeRD XML.

Inputs: invoice_number (required), invoice_date (required), seller_name (required), seller_street (required), +18 more. Returns: result

csv_to_excelA

Convert CSV content into a styled Excel workbook.

Auto-formats with header styling, auto-filter, frozen header row, and auto-sized columns.

Args: csv_content: Raw CSV text content. delimiter: CSV delimiter (default: comma). has_header: Whether the first row is a header (default: true). sheet_name: Name for the sheet tab (default: "Data").

Returns: Base64-encoded XLSX file.

Inputs: csv_content (required), delimiter, has_header, sheet_name. Returns: result

delete_templateB

Delete a template by name.

Args: name: Name of the template to delete.

Returns: Confirmation message.

Inputs: name (required). Returns: result

detect_xrechnungA

Detect if an XML document is an XRechnung and identify its format.

Args: xml: XML content to analyze.

Returns: JSON with detection result (detected, format, version).

Inputs: xml (required). Returns: result

excel_to_csvA

Extract data from an Excel sheet and return it as CSV text.

Args: excel_base64: Base64-encoded Excel file. sheet_index: Sheet index to extract (0-based, default: 0). delimiter: CSV delimiter (default: comma).

Returns: CSV text content.

Inputs: excel_base64 (required), sheet_index, delimiter. Returns: result

excel_to_jsonA

Extract data from an Excel sheet and return structured JSON.

Returns headers (if present) and typed data rows.

Args: excel_base64: Base64-encoded Excel file. sheet_index: Sheet index to extract (0-based, default: 0). has_header: Whether the first row is a header (default: true).

Returns: JSON with sheetName, totalRows, headers, and data array.

Inputs: excel_base64 (required), sheet_index, has_header. Returns: result

export_receipts_csvA

Export extracted receipt data as DATEV-compatible CSV.

Args: receipts: List of receipt extraction results (from extract_receipt).

Returns: Base64-encoded CSV file.

Inputs: receipts (required). Returns: result

export_receipts_xlsxA

Export extracted receipt data as Excel workbook (XLSX).

Args: receipts: List of receipt extraction results (from extract_receipt).

Returns: Base64-encoded XLSX file.

Inputs: receipts (required). Returns: result

extract_receiptA

Extract structured data from a receipt or invoice image using AI.

Returns vendor, date, totals (gross/net/VAT per rate), line items, currency, payment method, SKR03/04 account, category, and confidence score.

Args: image_base64: Base64-encoded receipt image (JPEG, PNG) or PDF. filename: Original filename (helps with format detection). content_type: MIME type (default: image/jpeg). Use application/pdf for PDF receipts.

Returns: JSON with extracted receipt data.

Inputs: image_base64 (required), filename, content_type. Returns: result

extract_receipt_asyncA

Submit a receipt for async AI extraction. Returns a job ID for polling.

Use get_receipt_job to check status and get_receipt_job_result for the result.

Args: image_base64: Base64-encoded receipt image or PDF. filename: Original filename. content_type: MIME type (default: image/jpeg). callback_url: Optional webhook URL to receive the result.

Returns: JSON with jobId and status.

Inputs: image_base64 (required), filename, content_type, callback_url. Returns: result

extract_text_from_pdfA

Extract all text content from a PDF.

Args: pdf_base64: Base64-encoded PDF file.

Returns: Extracted text content.

Inputs: pdf_base64 (required). Returns: result

extract_zugferdB

Extract structured invoice data from a ZUGFeRD/Factur-X PDF.

Args: pdf_base64: Base64-encoded ZUGFeRD PDF.

Returns: JSON with extracted invoice data.

Inputs: pdf_base64 (required). Returns: result

fill_excel_templateA

Fill an Excel template with data at named cells and ranges.

Args: template_base64: Base64-encoded Excel template file. values: Cell values to set (key = cell ref like 'Sheet1!A1' or named range, value = content). tables: Table data to insert at named ranges (key = range name, value = row arrays). recalculate: Recalculate formulas after filling (default: true).

Returns: Base64-encoded filled XLSX file.

Inputs: template_base64 (required), values, tables, recalculate. Returns: result

fill_pdf_formA

Fill form fields in a PDF.

Args: pdf_base64: Base64-encoded PDF file with form fields. fields: Field name-value pairs to fill. flatten: Whether to flatten the form (make fields non-editable).

Returns: Base64-encoded filled PDF.

Inputs: pdf_base64 (required), fields (required), flatten. Returns: result

generate_documentB

Generate a document with optional template, fields, and watermark.

Args: html_content: HTML content for the document body. markdown_content: Markdown content (alternative to HTML). template_name: Name of a pre-uploaded template (ODT/DOCX). fields: Template field replacements (key-value pairs). watermark: Diagonal watermark text overlay. output_format: Output format – PDF, DOCX, or ODT (default: PDF).

Returns: Base64-encoded document bytes.

Inputs: html_content, markdown_content, template_name, fields, +2 more. Returns: result

generate_excelA

Generate an Excel workbook (.xlsx) from a structured JSON definition.

The request dict should contain: sheets: List of sheet definitions, each with: name: Sheet tab name columns: Column definitions (header, width, format, align) rows: Data rows (list of dicts with 'values' or 'cells') formulas: List of formula definitions (cell, formula, label) headerFooter: Print header/footer configuration printArea: Print area in A1 notation freezePane: {row, col} for frozen panes headerStyle/dataStyle: Cell styling definitions autoSizeColumns, autoFilter, pageOrientation, fitToPage properties: Document properties (title, author, subject) password: Workbook protection password

Args: request: Structured JSON definition of the Excel workbook.

Returns: Base64-encoded XLSX file.

Inputs: request (required). Returns: result

generate_pdf_from_htmlC

Generate a PDF from HTML content.

Args: html: HTML content to convert to PDF.

Returns: Base64-encoded PDF bytes.

Inputs: html (required). Returns: result

generate_pdf_from_markdownA

Generate a PDF from Markdown content.

Args: markdown: Markdown content to convert to PDF.

Returns: Base64-encoded PDF bytes.

Inputs: markdown (required). Returns: result

get_pdf_metadataA

Get metadata (title, author, page count, etc.) from a PDF.

Args: pdf_base64: Base64-encoded PDF file.

Returns: JSON string with metadata fields.

Inputs: pdf_base64 (required). Returns: result

get_pdf_page_countB

Get the total number of pages in a PDF.

Args: pdf_base64: Base64-encoded PDF file.

Returns: Page count.

Inputs: pdf_base64 (required). Returns: result

get_receipt_jobA

Check the status of an async receipt extraction job.

Args: job_id: The job ID returned by extract_receipt_async.

Returns: JSON with job status (PENDING, PROCESSING, COMPLETED, FAILED).

Inputs: job_id (required). Returns: result

get_receipt_job_resultA

Get the extraction result of a completed async receipt job.

Args: job_id: The job ID returned by extract_receipt_async.

Returns: JSON with extracted receipt data.

Inputs: job_id (required). Returns: result

inspect_excelB

Inspect an Excel workbook and return metadata.

Returns sheet names, row/column counts, and named ranges.

Args: excel_base64: Base64-encoded Excel file.

Returns: JSON with sheetCount, sheets array, and namedRanges.

Inputs: excel_base64 (required). Returns: result

inspect_pdf_formA

Inspect form fields in a PDF and return their names, types, and current values.

Args: pdf_base64: Base64-encoded PDF file with form fields.

Returns: JSON array of form field definitions.

Inputs: pdf_base64 (required). Returns: result

list_certificatesB

List all uploaded signing certificates.

Returns: JSON array of certificate info objects.

Inputs: no named parameters. Returns: result

list_fontsA

List all uploaded custom fonts.

Returns: JSON array of font info objects.

Inputs: no named parameters. Returns: result

list_receipt_jobsB

List all async receipt extraction jobs.

Returns: JSON array of job info objects.

Inputs: no named parameters. Returns: result

list_templatesB

List all uploaded document templates.

Returns: JSON array of template info objects.

Inputs: no named parameters. Returns: result

merge_pdfsA

Merge multiple PDFs into a single PDF.

Args: pdfs_base64: List of base64-encoded PDF files to merge.

Returns: Base64-encoded merged PDF.

Inputs: pdfs_base64 (required). Returns: result

parse_xrechnungA

Parse XRechnung XML into structured invoice data.

Args: xml: XRechnung XML content.

Returns: JSON with parsed invoice data.

Inputs: xml (required). Returns: result

preview_pdf_pageA

Render a PDF page as a PNG image preview.

Args: pdf_base64: Base64-encoded PDF file. page: Page number (1-based, default: 1). dpi: Resolution in DPI (default: 150).

Returns: Base64-encoded PNG image.

Inputs: pdf_base64 (required), page, dpi. Returns: result

receipt_to_documentA

Extract receipt data and generate an expense report document.

Combines AI extraction with document generation in a single step.

Args: image_base64: Base64-encoded receipt image or PDF. filename: Original filename. content_type: MIME type (default: image/jpeg). output_format: Output format – PDF, DOCX, or ODT (default: PDF). title: Document title (default: "Spesenbeleg"). template_name: Optional template for the expense report layout.

Returns: JSON with extracted data and base64-encoded document.

Inputs: image_base64 (required), filename, content_type, output_format, +2 more. Returns: result

rotate_pdfA

Rotate pages in a PDF.

Args: pdf_base64: Base64-encoded PDF file. angle: Rotation angle in degrees (90, 180, 270). pages: Page range to rotate (e.g. "1-3", "all"). Default: all pages.

Returns: Base64-encoded rotated PDF.

Inputs: pdf_base64 (required), angle (required), pages. Returns: result

sign_pdfB

Digitally sign a PDF with a PKCS#12 certificate.

Args: pdf_base64: Base64-encoded PDF to sign. certificate_name: Name of a pre-uploaded certificate. certificate_password: Password for the certificate. reason: Reason for signing. location: Location of signing.

Returns: Base64-encoded signed PDF.

Inputs: pdf_base64 (required), certificate_name (required), certificate_password (required), reason, +1 more. Returns: result

upload_templateA

Upload a document template (ODT or DOCX).

Args: template_base64: Base64-encoded template file. filename: Filename for the template (e.g. "invoice.odt").

Returns: JSON with upload result.

Inputs: template_base64 (required), filename (required). Returns: result

validate_xrechnungA

Validate XRechnung XML for compliance.

Args: xml: XRechnung XML content.

Returns: JSON validation result (valid, format, errors, warnings).

Inputs: xml (required). Returns: result

validate_zugferdA

Validate a ZUGFeRD/Factur-X PDF for compliance.

Args: pdf_base64: Base64-encoded PDF with embedded ZUGFeRD data.

Returns: JSON validation result (valid, profile, errors, warnings).

Inputs: pdf_base64 (required). Returns: result

verify_pdf_signaturesB

Verify digital signatures in a PDF.

Args: pdf_base64: Base64-encoded signed PDF.

Returns: JSON with verification results (signed, signatureCount, allValid, signatures).

Inputs: pdf_base64 (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 40 tools

    Disambiguation5/5

    Every tool has a clearly distinct purpose, covering document generation, PDF manipulation, Excel, receipts, e-invoicing, and template management. Overlaps like generate_document vs compose_document are resolved by different input types (single vs multi-part).

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern with underscores, e.g., create_invoice, extract_receipt, merge_pdfs. No mixing of conventions like camelCase.

    Tool Count2/5

    At 40 tools, the server is significantly over-scoped for a typical document generation service. The breadth of features (PDF, Excel, receipts, e-invoicing) is excessive, making it harder to navigate.

    Completeness5/5

    The tool set covers the full lifecycle for document generation, PDF operations, Excel handling, receipt extraction, and e-invoicing (ZUGFeRD/XRechnung). Includes CRUD for templates, async jobs, and validation.

    Maintenance

    ActivitySlowing
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables creating professional documents (invoices, contracts, certificates, proposals, reports) via the DocuQueue API, with tools for template management, filling, previewing, and PDF generation.
      28 npm
      1
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI assistants and agents to create, validate, read and convert German and EU e-invoices in ZUGFeRD, XRechnung and Factur-X formats, including extracting structured data from scanned or PDF invoices and embedding XML into PDF/A-3 files. It can run as a hosted remote server or locally, with each request authenticated by the caller's own API token.
      10
      24 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI assistants to read, validate against the official KoSIT rules (no Java), create, and display XRechnung and ZUGFeRD e-invoices, and export incoming invoices as DATEV posting batches. Running it with a cloud language model sends invoice contents to that provider's service.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI assistants to convert German PDF invoices into XRechnung 3.0 and ZUGFeRD e-invoices with KoSIT validation and missing-field prompts, and Brazilian bank statement PDFs into OFX, CSV, and Excel after balance validation.
      3
      740 npm
      MIT