MCP E-Invoicing Core

io.github.cmendezs由 GitHub 账号 cmendezs 发布v1.34.1更新于 Oct 24, 2026

Base package for e-invoicing MCP servers. Compliance logic and signing keys stay with you.

发布方自己的服务:core.blue

概览

AI 生成的概览

一个 Python 基础库,为电子发票 MCP 服务器提供共享的发票模型、EN 16931 校验、UBL/CII 转换、Peppol 查询与签名原语。

可以做什么
它是电子发票 MCP 服务器的共享基础,而不是独立的开票工具。它提供 Pydantic 发票与参与方模型、EN 16931 发票树、UBL 与 CII 序列化器和解析器、线格式转换,以及合规审计框架。可挂载的 FastMCP 插件补充了 Peppol 参与方查询、服务端点解析、DNS 诊断、AS4 发送、Peppol Directory 搜索、eDEC 与 EN 16931 代码表查询,以及 PDF 混合文档识别与提取。此外还包含 OAuth2/mTLS/bearer/API key/JWS 的 HTTP 客户端支持、数字签名原语(XAdES-EPES、XMLDSig、CAdES)、路由 ID 校验和沙箱/生产端点路由。
适用场景
当你正在构建或运行某个国家/地区的电子发票 MCP 服务器,并希望复用共享的模型、校验、转换与 Peppol 基础设施时使用它。它也适合在合规逻辑与密钥保留在自有基础设施内的前提下,进行本地发票生成、校验、签名和线格式转换。
运行要求
本地 Python 进程,从 PyPI 安装 mcp-einvoicing-core。可选附加项:[audit] 用于合规审计框架,[xslt2] 用于 XSLT 2.0/3.0 Schematron 校验。可选环境变量:EINVOICING_PEPPOL_CODELIST_DIR、EINVOICING_EN16931_CODELIST_DIR、EINVOICING_PEPPOL_PKI_DIR、EINVOICING_SMP_ALLOWLIST、EINVOICING_CERT_PINS。代码表与 PKI 数据未随包提供,需另行下载。
安装前请注意
它涉及签名密钥与证书,私钥材料保留在你的环境中,应加以保护。AS4 发送等提交路径可能将文档传输到外部端点或主管机关,HTTP 客户端支持 OAuth2、mTLS、bearer 令牌、API key 与 JWS 凭据。除非设置 EINVOICING_CERT_PINS,否则不会强制执行证书固定。代码表与 PKI 目录需由你提供;未提供时相关工具会报告为未配置。

安装

在 SourceWeft 中

  1. 打开 控制台中的 MCP E-Invoicing Core,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

mcp-einvoicing-core

English | Francais | Deutsch | Italiano | Espanol | Portugues (Brasil) | العربية

[License] [PyPI version] [Python][mcp-einvoicing-core MCP server]

Topics: mcp mcp-server e-invoicing electronic-invoicing python fastmcp peppol en16931 ubl fatturapa xp-z12-013 nfe xml base-library

Base package for electronic invoicing MCP servers.

Provides shared Pydantic models, EN 16931 invoice tree, UBL/CII wire format serializers, an OAuth2 HTTP client, Peppol SMP lookup, digital signature primitives, and a compliance audit framework so country-specific packages share a common foundation without duplicating code.


What this package provides

ModuleContents
modelsInvoiceDocument, InvoiceParty, InvoiceLineItem, PartyAddress, VATSummary, PaymentTerms, DocumentValidationResult, TaxIdentifier (per-country tax ID validators: IT, FR, DE, BE, ES, PL, BR, AE, SG, MX, IN), TaxIdValidationResult
en16931EN16931Invoice, EN16931Party, EN16931LineItem, EN16931Address, EN16931Tax, EN16931AllowanceCharge, EN16931PaymentMeans
credit_noteEN16931CreditNote (type codes 381/383/384/385), BillingReference
ubl_documentsBaseUBLDocument — shared envelope for non-invoice UBL/Peppol document families (Peppol Ordering, jurisdiction extensions); explicitly outside the InvoiceDocument/EN16931Invoice tree
wire_formatsEN16931UBLSerializer, EN16931UBLParser, EN16931CIISerializer, EN16931CIIParser, UBL_NSMAP, CII_NSMAP
convertSyntax (UBL, CII), convert_wire_format (auto-detect source, serialize to target)
base_serverEInvoicingMCPServer, BaseDocumentGenerator, BaseDocumentValidator, BaseDocumentParser, BaseLifecycleManager, BasePartyValidator, BaseScopeInfo, SubmissionMetadata, SearchCriteria, SubmitResult, assert_not_read_only, scrub
http_clientBaseEInvoicingClient (OAuth2, mTLS, bearer, API key, JWS, none), OAuthConfig, OAuthValues, JWSConfig, APIKeyConfig, TokenCache, AuthMode
peppolPeppolSMPClient, PeppolParticipantId, PeppolServiceInfo, PeppolLookupResult, PeppolEnvironment, PEPPOL_BIS_BILLING_30, resolve_naptr (standalone U-NAPTR/SML DNS diagnostic)
peppol.toolsregister_peppol_tools (mountable FastMCP plugin: participant lookup, service endpoint, DNS diagnostic, AS4 send, Directory search, plus 8 eDEC code list tools), default_id_adapter, IdentifierAdapter (national identifier adapter contract)
peppol.codelistsCodeList, CodelistNotConfiguredError, load_codelist and the eDEC lookup functions (document types, processes, participant ID schemes, transport profiles, SPIS use cases). Requires EINVOICING_PEPPOL_CODELIST_DIR, see Configuration below
genericodeparse_genericode, CodeList, CodelistNotConfiguredError — shared OASIS Genericode 1.0 parser (used by peppol.codelists and en16931_codelists)
en16931_codelistsen16931_codelist_tools.register_en16931_codelist_tools (mountable FastMCP plugin: country, currency, ICD, UNCL1001/1153/4461/5305, allowance/item/charge reason, MIME, EAS, VATEX lookup). Requires EINVOICING_EN16931_CODELIST_DIR, see Configuration below
peppol.directoryPeppolDirectoryClient (public Peppol Directory REST search, no auth), PeppolDirectorySearchResult, PeppolBusinessCard, PeppolBusinessEntity
peppol.transportAS4MessageEnvelope, AS4TransportClient, AS4ReceiptHandler, PeppolTransmitter, AS4Receipt, AS4Credentials (Peppol AS4 outbound transmission, now with real WS-Security message signing); AS4InboundHandler, AS4InboundMessage, AS4InboundError, StandardBusinessDocumentHeader (AS4 inbound receiver, C3 role); sign_as4_message, verify_as4_signature (WS-Security primitives)
peppol.trustPeppolTrustStore, validate_certificate_chain, check_revocation, verify_smp_signature — OpenPeppol PKI chain/revocation/signature validation. Requires EINVOICING_PEPPOL_PKI_DIR (root certs not yet published by OpenPeppol as of this release — logic-only until supplied)
peppol.reportingparse_eusr, parse_tsr, validate_eusr, validate_tsr — Peppol EUSR/TSR service-provider statistics report models and validation (bundled XSD + Schematron, optional [xslt2] extra)
peppol.mlsparse_mls, validate_mls, build_mls — Peppol Message Level Status (MLS) model and validation (bundled Schematron, optional [xslt2] extra)
schematronSchematronValidator (XSLT 1.0), SaxonSchematronValidator (XSLT 2.0/3.0, optional [xslt2] extra), load_schematron_validator (auto-dispatch factory), get_xslt_version, BaseStructuredValidator, BaseXSDValidator, XSDValidator (generic concrete XSD validator), BaseJSONValidator, ValidationMessage, ValidationResult
schematron_artifactsen16931_base_schematron_validator (bundled, compiled CEN EN16931 base Schematron — BR-* rules only, no Peppol overlay; optional [xslt2] extra)
digital_signatureBaseDocumentSigner, XAdESEPESSigner, XAdESSignerConfig, XMLDSigSigner, XMLDSigSignerConfig, CAdESSigner, CAdESSignerConfig, SelloDigitalSigner, SelloDigitalSignerConfig, load_certificate_der
endpointsBaseEnvironmentEndpoints, EndpointSet, EndpointEnvironment (sandbox/production URL routing)
routingRoutingIdentifier (static validators: validate_de_leitweg), RoutingIdValidationResult
profile_registryProfileEntry, ProfileRegistry, profile_registry, set_profile_registry
pdfPDFEmbedder (PDF/A-3 XML embedding); extract(filename=None) tries canonical Factur-X/XRechnung/ZUGFeRD filenames in turn, identify() reads XMP to detect a hybrid PDF and its conformance level
pdf_toolsregister_pdf_tools (mountable FastMCP plugin: identify_and_extract_pdf), identify_and_extract_pdf
qrgenerate_qr_png_base64
xml_utilsformat_amount, format_quantity, xml_element, xml_optional, validate_date_iso, validate_iban, resolve_xml_input, mark_untrusted, mark_untrusted_fields, filter_empty_values, format_error
download_rulesDownloadSpec, download_artefacts
testingInvoiceFixtureFactory (shared pytest fixtures)
audit_logAuditLog, AuditAction, get_audit_log
confirmationConfirmationGate, ConfirmationStore (human-in-the-loop gate)
exceptionsEInvoicingError, ValidationError, PartyValidationError, XSDValidationError, SchematronValidationError, DocumentGenerationError, AuthenticationError, PlatformError
logging_utilssetup_logging, get_logger
auditCompliance audit framework: AuditReport, CheckResult, CheckFinding, severity constants, make_report, render_summary_table, parse_audit_args, run_check_core_coverage, run_check_version_compatibility, run_check_known_shared_helpers, run_check_resource_paths, TaxRate, load_rates (optional [audit] extra)

Country packages

CountryPackageStandardScopeCoverage status
🇧🇪 Belgiummcp-einvoicing-bePeppol BIS 3.0 / PINT-BEB2B, 1 January 2026Live; Peppol-specific overlay rules not checked (EN 16931 base only)
🇧🇷 Brazilmcp-nfe-brNF-e / NFC-e (modelo 55/65, schema 4.00) / NFS-e NacionalB2B (NF-e) + B2C (NFC-e), both mandatory since 2008Live; IBS/CBS tax reform rollout ongoing through 2033
🇫🇷 Francemcp-facture-electronique-frNF XP Z12-012 / NF XP Z12-013 / Factur-X / UBL 2.1 / CIIB2B, phased rollout from 1 September 2026Live
🇩🇪 Germanymcp-einvoicing-deZUGFeRD 2.x / XRechnung 3.xB2B, phased 2025 to 2028Live
🇮🇳 Indiamcp-einvoicing-inGST e-invoicing / FORM GST INV-01 schema v1.1 / IRP-IRN (INV + CRN + DBN)B2B + B2G, mandatory under CGST Rule 48(4) for taxpayers with AATO above ₹5 crore, since 1 August 2023Pre-release (v0.1.0, unpublished); Phase A only (build + offline validation + QR rendering) — live IRP submission pending the NIC API spec
🇮🇹 Italymcp-fattura-elettronica-itFatturaPA / SDIB2G + B2B + B2C, mandatory since 2019 (B2G since 2014)Live
🇲🇽 Mexicomcp-cfdi-mxCFDI 4.0 / Complemento de Pagos 2.0B2B + B2G, mandatory nationwideLive; PAC submission transport pending
🇵🇱 Polandmcp-ksef-plKSeF FA(3) / FA(2) / Peppol BIS 3.0B2B, phased February 2026 to January 2027Live; batch session flow not implemented
🇸🇬 Singaporemcp-invoicenow-sgPINT-SG v1.4.1 / SG Peppol BIS Billing 3.0B2B, mandatory for GST-registered businesses from April 2026Live; validation scope limited to IRAS C5 acceptance checks, PINT-SG jurisdiction Schematron and EN 16931 base validation not yet wired
🇪🇸 Spainmcp-facturacion-electronica-esFactura-e / VeriFactu / SII / FACePending Orden Ministerial, targeted 2026-10-01Live for VeriFactu/SII; B2B format wiring blocked on pending Orden Ministerial
🇦🇪 United Arab Emiratesmcp-einvoicing-aePINT AE (billing + self-billing) / Peppol AE TDDB2B + B2G, voluntary pilot from July 2026, mandatory for large taxpayers from January 2027Live; validates CEN EN16931 base Schematron only, PINT AE jurisdiction overlay and TDD validation not yet available

Installation

bash
pip install mcp-einvoicing-core

For the compliance audit framework (used by country package CI):

bash
pip install mcp-einvoicing-core[audit]

For XSLT 2.0/3.0 Schematron validation (SaxonSchematronValidator — needed for Schematron rule sets using XPath 2.0+ constructs, e.g. FNFE-MPE Factur-X 1.08 / ZUGFeRD):

bash
pip install mcp-einvoicing-core[xslt2]

Configuration

VariableUsed byPurpose
EINVOICING_PEPPOL_CODELIST_DIRpeppol.codelists (and the peppol.tools codelist tools)Local directory containing your own copy of the OpenPeppol eDEC Code Lists. Not bundled with this package: the eDEC Code Lists carry no confirmed redistribution grant from OpenPeppol, so core ships only the parser and lookup tools, never the data itself. Download the "as GeneriCode" export for each artifact (Document Types, Participant Identifier Schemes, Processes, Transport Profiles, SPIS Use Case) from docs.peppol.eu/edelivery/codelists and point this variable at the directory containing them. Filenames are matched by prefix, so a version bump (e.g. v9.7 to v9.8) needs no code change. Without this set, the codelist tools return a configured: false result with setup instructions rather than raising.
EINVOICING_EN16931_CODELIST_DIRen16931_codelists (and its FastMCP tools)Local directory containing your own copy of the CEF EN 16931 semantic code lists (country, currency, ICD, UNCL1001/1153/4461/5305, allowance/item/charge reason, MIME, EAS, VATEX). Not bundled, same posture as the eDEC lists above — download the "as GeneriCode" export bundle from the CEF EN 16931 code lists page. Filenames match exactly (Country.gc, not a version-prefixed name). Without this set, tools return configured: false.
EINVOICING_PEPPOL_PKI_DIRpeppol.trustLocal directory with test/ and prod/ subdirectories of PEM-encoded OpenPeppol PKI root/intermediate CA certificates, for AS4 message signature and SMP response signature chain validation. Not yet published by OpenPeppol as bundled data anywhere — trust functions report trust_anchors_configured: false until this is set.
EINVOICING_SMP_ALLOWLISTpeppol (PeppolSMPClient, resolve_naptr)Comma-separated hostname suffixes to extend the built-in Peppol Access Point allowlist used when validating a resolved SMP hostname.
EINVOICING_CERT_PINShttp_client (BaseEInvoicingClient) and peppol.transport.client (AS4TransportClient)Comma-separated host:sha256hex pairs enabling SHA-256 certificate pinning on outbound HTTP requests. Without this set, pinning is not enforced.

Architecture

Country packages subclass the core abstractions and register their tools on a shared or standalone MCP server:

mcp-einvoicing-core  ├── EN16931Invoice / InvoiceDocument  ← canonical invoice models  ├── EN16931CreditNote                 ← credit note (type codes 381/383/384/385)  ├── EN16931UBL/CII Serializer/Parser  ← wire format round-trip  ├── convert_wire_format               ← CII ↔ UBL conversion  ├── BaseDocumentGenerator/Validator/Parser/LifecycleManager  ├── BaseEInvoicingClient              ← async HTTP (OAuth2/mTLS/bearer/API key/JWS)  ├── PeppolSMPClient                   ← participant lookup via SMP/SML  ├── PeppolTransmitter                 ← AS4 outbound transmission  ├── BaseDocumentSigner                ← XAdES-EPES / XMLDSig  ├── BaseEnvironmentEndpoints          ← sandbox/production URL routing  ├── RoutingIdentifier                 ← country-specific routing ID validation  ├── EInvoicingMCPServer               ← plugin registry wrapping FastMCP  └── Audit framework                   ← per-package compliance checks

Vendor neutrality

Every server in this family implements the standard itself. It builds, validates and signs the document locally, and the signing keys stay in your infrastructure. None of these packages is a client for a commercial invoicing platform, and no vendor account is needed to run one.

What differs between countries is the last mile: who, if anyone, must stand between you and the tax authority. mcp-einvoicing-core supports all three arrangements, and each country package implements exactly the one its jurisdiction uses:

  • Direct to the authority. No intermediary is legally required; the package talks to the government endpoint with your own accreditation. (Italy, Poland, Brazil, Spain)
  • Substitutable intermediary. An intermediary is required, but its API is standardized, so changing provider is a configuration change, not a code change. (France's PDP under XP Z12-013; Peppol access points for Belgium, Singapore, the UAE)
  • Adapter-per-vendor intermediary. An intermediary is required and each vendor's API differs. The document and the keys still stay yours; only the transport adapter is vendor-specific. (Mexico's PAC, India's GSP)

In all three, the compliance logic and the private keys stay with you.

Plugin registration pattern

Country packages register their tools on a shared or standalone FastMCP instance:

python
# Standalonefrom fastmcp import FastMCPmcp = FastMCP(name="mcp-fattura-elettronica-it", instructions="...")register_header_tools(mcp)register_body_tools(mcp)register_global_tools(mcp)
# Multi-country (optional EInvoicingMCPServer)from mcp_einvoicing_core import EInvoicingMCPServerserver = EInvoicingMCPServer(name="mcp-einvoicing-eu", instructions="...")server.register_plugin(register_header_tools, "it-header")server.register_plugin(register_flow_tools, "fr-flow")server.run()

Core also ships its own mountable Peppol tool plugin so country packages stop reimplementing SMP lookup and AS4 send. Supply a national identifier adapter (a small function that normalizes a bare national number, e.g. a VAT number, into a Peppol "<scheme>:<value>" participant ID):

python
from mcp_einvoicing_core.peppol.tools import register_peppol_tools
def be_id_adapter(identifier: str) -> str:    if ":" in identifier:        return identifier    return f"0208:{normalize_vat_be(identifier)[2:]}"  # KBO/BCE scheme
server.register_plugin(    lambda m: register_peppol_tools(m, id_adapter=be_id_adapter), "peppol")

This registers peppol_lookup_participant, peppol_get_service_endpoint, resolve_peppol_dns, peppol_send, peppol_directory_search, and 8 OpenPeppol eDEC code list tools (see Configuration above for EINVOICING_PEPPOL_CODELIST_DIR, required for the code list tools). Separate mountable plugins cover the EN 16931 semantic code lists (en16931_codelist_tools.register_en16931_codelist_tools), Peppol reporting (peppol.reporting_tools.register_peppol_reporting_tools), and MLS (peppol.mls_tools.register_peppol_mls_tools).

Claude Desktop / Cursor / Kiro compatibility

Existing configurations for country packages require no changes: tool names, signatures, environment variables, and entry points (server:main) are fully preserved.

License

Apache 2.0 -- see LICENSE.

来源:README.md,提交 e3b5c0a

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.34.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

其他 Core 集成