Skip to main content

MCP server for German electronic invoicing (ZUGFeRD 2.x, XRechnung 3.x, EN 16931)

Project description

mcp-einvoicing-de 🇩🇪

English | Deutsch

License PyPI version Python mcp-einvoicing-de MCP server

MCP server (Model Context Protocol) in Python for German electronic invoicing in ZUGFeRD 2.x and XRechnung 3.x formats (EN 16931, FeRD, KoSIT). Enables AI agents (Claude, IDEs) to create, validate, parse, and convert e-invoices that are fully compliant with the German B2B e-invoicing mandate (effective from 2025, phased enforcement through 2027 to 2028) and the European standard EN 16931.


🏗️ Built on

This package is built on mcp-einvoicing-core, a shared base library for European e-invoicing MCP servers. It provides shared models, validation abstractions, XML utilities, and the exception hierarchy.

mcp-einvoicing-core is automatically installed as a transitive dependency, no additional step required.

For developers: pip install -e ".[dev]" installs the base package automatically from PyPI.


🏗️ Architecture

mcp-einvoicing-de (this package, standalone MCP server)
├── ZUGFeRDInvoice / XRechnungInvoice  ← Pydantic models (all profiles)
├── SchematronValidator                ← EN 16931 + KoSIT BR-DE-* rules
├── KoSITValidator                     ← Remote validation tool (optional)
└── Tools: create / validate / parse / convert / peppol_check / peppol_send / datev_export / tax_rules

        ↑ extends
mcp-einvoicing-core (shared base, installed as dependency)
├── BaseDocumentGenerator / Validator / Parser
├── BaseInvoice, BaseParty … (Pydantic)
├── xml_utils, exceptions
└── EInvoicingMCPServer

🚀 Installation

Via PyPI (recommended)

pip install mcp-einvoicing-de

Without prior installation, using uvx:

uvx mcp-einvoicing-de

From source

git clone https://github.com/cmendezs/mcp-einvoicing-de.git
cd mcp-einvoicing-de

python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate

pip install -e ".[dev]"

Optional extras

Extra Purpose Install
[xslt2] Saxon-HE backend for XSLT 2.0 Schematron stylesheets (FeRD Factur-X 1.08 and KoSIT XRechnung 3.0.2). Required for local Schematron validation; lxml supports XSLT 1.0 only. pip install mcp-einvoicing-de[xslt2]
[pdf] Additional PDF utilities for embedded XML extraction (pikepdf is also a base dependency for PDF/A-3 generation). pip install mcp-einvoicing-de[pdf]
[pymupdf] Alternative PDF engine (uses PyMuPDF). pip install mcp-einvoicing-de[pymupdf]
[dev] Development tools (pytest, ruff, pre-commit). pip install mcp-einvoicing-de[dev]

⚙️ Configuration

The server does not require external credentials. Available environment variables:

Variable Description Default
EINVOICING_DE_LOG_LEVEL Log level (DEBUG, INFO, WARNING, ERROR) INFO
EINVOICING_DE_KOSIT_VALIDATOR_URL URL of a self-hosted KoSIT validation tool REST endpoint (overrides the default https://validator.kosit.de)
EINVOICING_DE_KOSIT_DISABLE Set to 1 to disable KoSIT cloud validation entirely (local Schematron only)
EINVOICING_DE_PEPPOL_CERT_PATH Path to the X.509 certificate for Peppol AS4 signing (PEM or DER)
EINVOICING_DE_PEPPOL_KEY_PATH Path to the private key for Peppol AS4 signing (PEM or DER)
EINVOICING_DE_PEPPOL_KEY_PASSWORD Password for the private key (if encrypted)

🤖 Claude Desktop integration

Add the following entry to claude_desktop_config.json:

{
  "mcpServers": {
    "einvoicing-de": {
      "command": "uvx",
      "args": ["mcp-einvoicing-de"]
    }
  }
}

⌨️ Cursor integration

Configuration file (~/.cursor/mcp.json or .cursor/mcp.json in the project directory):

{
  "mcpServers": {
    "einvoicing-de": {
      "command": "uvx",
      "args": ["mcp-einvoicing-de"]
    }
  }
}

🪐 Kiro integration

{
  "mcpServers": {
    "einvoicing-de": {
      "command": "uvx",
      "args": ["mcp-einvoicing-de"],
      "disabled": false,
      "autoApprove": []
    }
  }
}

🧰 Available MCP tools

Tool Description
invoice_create Generate ZUGFeRD or XRechnung XML (CII or UBL). Enforces the §14 Abs. 2 UStG B2B mandate: non-XML output is rejected for DE-prefixed VAT buyers unless transitional_period_opt_in=True is set. output_format='pdf' produces a PDF/A-3 level B hybrid invoice with sRGB ICC profile, OutputIntent, embedded fonts, and deterministic /ID.
invoice_validate Validate an invoice against EN 16931 and KoSIT rules (BR-DE-*). KoSIT cloud validation (validator.kosit.de) is enabled by default with exponential backoff retry (1s/2s/4s) and automatic Schematron fallback. Disable with EINVOICING_DE_KOSIT_DISABLE=1. XSLT 2.0 local validation requires the [xslt2] extra.
invoice_parse Extract structured data from ZUGFeRD or XRechnung XML, or from a PDF/A-3 hybrid invoice with embedded factur-x.xml / zugferd-invoice.xml.
invoice_convert Convert between ZUGFeRD profiles, swap ZUGFeRD/XRechnung CII headers, or perform cross-syntax CII/UBL conversion via core convert_wire_format.
peppol_check Check Peppol participant registration of a German company via SMP/SML lookup.
peppol_send Send an invoice to a Peppol recipient via AS4 outbound transmission. Converts ZUGFeRD to XRechnung UBL (Peppol BIS 3.0 profile), signs with X.509 credentials, and returns the AS4 receipt. Requires EINVOICING_DE_PEPPOL_CERT_PATH and EINVOICING_DE_PEPPOL_KEY_PATH.
datev_export Export a ZUGFeRD invoice as a DATEV EXTF 700 Buchungsstapel CSV file for import into DATEV accounting software. Defaults to SKR 03 accounts (8400 revenue / 10000 receivable).
tax_rules Query German VAT rules (rates, §13b UStG reverse charge codes, §19 UStG Kleinunternehmer thresholds at JStG 2024 values of €25,000 preceding year / €100,000 current year, exemptions).

Usage examples

Example 1: Validate an invoice

1. invoice_validate(
     xml_base64="...",   # Base64-encoded ZUGFeRD XML
     strict=True
   )
   → {
       "is_valid": true,
       "profile": "EN_16931",
       "syntax": "CII",
       "error_count": 0,
       "warning_count": 2,
       "errors": [],
       "warnings": [...],
       "validator_used": "local_schematron"
     }

Example 2: Query German tax rules

2. tax_rules(query="reverse_charge", context="Bauleistungen")
   → {
       "results": [
         {
           "paragraph": "§13b Abs. 2 Nr. 5 UStG",
           "description_en": "Construction services (building contractor rule)",
           "vatex_code": "VATEX-EU-AE",
           "invoice_note": "Steuerschuldnerschaft des Leistungsempfängers (§13b UStG)"
         }
       ],
       "legal_disclaimer": "..."
     }

Example 3: Check Peppol registration

3. peppol_check(
     participant_id="0204:991-1234512345-06",
     environment="production"
   )
   → {
       "is_registered": true,
       "participant_id": "0204:991-1234512345-06",
       "document_type_supported": true,
       "access_point_url": "https://ap.example.de/as4",
       "transport_profile": "peppol-transport-as4-v2.0"
     }

Example 4: Parse invoice data

4. invoice_parse(xml_base64="...", include_raw_xml=False)
   → {
       "profile": "XRECHNUNG",
       "syntax": "CII",
       "invoice_number": "RE-2025-001",
       "invoice_date": "2025-01-15",
       "seller_name": "Muster GmbH",
       "buyer_name": "Käufer AG",
       "tax_inclusive_amount": "119.00",
       "currency_code": "EUR"
     }

📚 Supported standards

Standard Version Profiles / Syntax
ZUGFeRD 2.3.2 MINIMUM, BASIC WL, BASIC, EN 16931, EXTENDED
XRechnung 3.0.2 CII (Cross Industry Invoice), UBL (Universal Business Language)
EN 16931 2017 European core data model for electronic invoicing
Peppol BIS 3.0 Billing 3.0 (EN 16931-compliant)

Note: ZUGFeRD 2.x and XRechnung 3.x share the same CII XML syntax at the EN 16931 profile level. Conversion between both formats is therefore possible without data loss. The EXTENDED profile is specific to ZUGFeRD and has no XRechnung equivalent.

Resource Link
FeRD ZUGFeRD specification ferd-net.de
KoSIT XRechnung xeinkauf.de
KoSIT validation tool github.com/itplr-kosit/validationtool
EN 16931-1:2017 CEN
Peppol BIS Billing 3.0 docs.peppol.eu

🧪 Tests

# Install development dependencies
pip install -e ".[dev]"

# Run the full test suite
pytest tests/ -v

# With coverage report
pytest --cov=mcp_einvoicing_de --cov-report=term-missing

# Model tests only
pytest tests/test_models.py -v

Roadmap

Current version: v0.6.0.

For the history of past releases, see RELEASE.md.


Contributing

Contributions are welcome. Please open an issue before submitting a pull request for significant changes.

git clone https://github.com/cmendezs/mcp-einvoicing-de.git
cd mcp-einvoicing-de
pip install -e ".[dev]"
pytest
make audit

Other e-invoicing MCP servers

Country Server
🌍 Global mcp-einvoicing-core
🇧🇪 Belgium mcp-einvoicing-be
🇧🇷 Brazil mcp-nfe-br
🇫🇷 France mcp-facture-electronique-fr
🇩🇪 Germany mcp-einvoicing-de
🇮🇹 Italy mcp-fattura-elettronica-it
🇵🇱 Poland mcp-ksef-pl
🇪🇸 Spain mcp-facturacion-electronica-es

📄 License

This project is licensed under the Apache 2.0 License.
See the LICENSE file for details.

Copyright 2026 cmendezs


Project maintained by cmendezs. For questions about the ZUGFeRD or XRechnung specification implementation, please open an issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_einvoicing_de-0.8.0.tar.gz (24.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_einvoicing_de-0.8.0-py3-none-any.whl (330.7 kB view details)

Uploaded Python 3

File details

Details for the file mcp_einvoicing_de-0.8.0.tar.gz.

File metadata

  • Download URL: mcp_einvoicing_de-0.8.0.tar.gz
  • Upload date:
  • Size: 24.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for mcp_einvoicing_de-0.8.0.tar.gz
Algorithm Hash digest
SHA256 3a1cc0c052ab396d93156465459b40b68c1e33895fcbf56e0c65d1bbd5693f7e
MD5 410bd433e2ed11807fe27ce9daad729b
BLAKE2b-256 1369ffe68d751544a0cd90b12605069657226245e9e7956a9b31d69bf6a3b263

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_einvoicing_de-0.8.0.tar.gz:

Publisher: publish.yml on cmendezs/mcp-einvoicing-de

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcp_einvoicing_de-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_einvoicing_de-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d702c552f78d6bec3e65c6d50e72d6c146d4ce53fdf7e3338974e52cb45a2ca7
MD5 31cb8450a0feeb8a3062f22645ecc8dd
BLAKE2b-256 e4ec1a0f009159510d197f48a88af0b9fb382a2cc3ac940cf58eba15f60a833d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_einvoicing_de-0.8.0-py3-none-any.whl:

Publisher: publish.yml on cmendezs/mcp-einvoicing-de

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page