mcp-einvoicing-core 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,69 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ env:
9
+ FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
10
+
11
+ jobs:
12
+ build:
13
+ name: Build distribution
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.12"
22
+
23
+ - name: Install Hatch
24
+ run: pip install hatch
25
+
26
+ - name: Build package
27
+ run: hatch build
28
+
29
+ - name: Upload distribution artifacts
30
+ uses: actions/upload-artifact@v4
31
+ with:
32
+ name: dist
33
+ path: dist/
34
+
35
+ publish-pypi:
36
+ name: Publish to PyPI
37
+ needs: build
38
+ runs-on: ubuntu-latest
39
+ environment: pypi
40
+ permissions:
41
+ id-token: write # required for trusted publishing (no API key needed)
42
+ steps:
43
+ - name: Download distribution artifacts
44
+ uses: actions/download-artifact@v4
45
+ with:
46
+ name: dist
47
+ path: dist/
48
+
49
+ - name: Publish to PyPI
50
+ uses: pypa/gh-action-pypi-publish@release/v1
51
+
52
+ create-release:
53
+ name: Create GitHub Release
54
+ needs: build
55
+ runs-on: ubuntu-latest
56
+ permissions:
57
+ contents: write
58
+ steps:
59
+ - name: Download distribution artifacts
60
+ uses: actions/download-artifact@v4
61
+ with:
62
+ name: dist
63
+ path: dist/
64
+
65
+ - name: Create GitHub Release
66
+ uses: softprops/action-gh-release@v2
67
+ with:
68
+ files: dist/*
69
+ generate_release_notes: true
@@ -0,0 +1,58 @@
1
+ # macOS
2
+ .DS_Store
3
+ .AppleDouble
4
+ .LSOverride
5
+ *.DS_Store
6
+ Icon?
7
+ ._*
8
+ .Spotlight-V100
9
+ .Trashes
10
+
11
+ # Credentials & sensitive files
12
+ *.env
13
+ *.key
14
+ *.pem
15
+ cookie.file
16
+ secrets/
17
+ .secret
18
+ *.secret
19
+ *.credentials
20
+ *.token
21
+
22
+ # Logs
23
+ *.log
24
+ logs/
25
+
26
+ # Python
27
+ __pycache__/
28
+ *.py[cod]
29
+ *$py.class
30
+ .venv/
31
+ venv/
32
+ env/
33
+ dist/
34
+ build/
35
+ *.egg-info/
36
+ .hatch/
37
+ *.whl
38
+
39
+ # Environment locals (secrets)
40
+ .env
41
+ .env.local
42
+ .env.*.local
43
+
44
+ # Tests & coverage
45
+ .pytest_cache/
46
+ .coverage
47
+ htmlcov/
48
+ .tox/
49
+ coverage.xml
50
+
51
+ # IDE
52
+ .vscode/
53
+ .idea/
54
+ *.swp
55
+ *.swo
56
+
57
+ # Claude Code (local settings, memory, session data)
58
+ .claude/
@@ -0,0 +1,191 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other transformations
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "contribution" means any work of authorship,
51
+ including the original version of the Work and any modifications or
52
+ additions to that Work or Derivative Works of the Work.
53
+
54
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
55
+ whom a Contribution has been received by the Licensor and included
56
+ within the Work.
57
+
58
+ 2. Grant of Copyright License. Subject to the terms and conditions of
59
+ this License, each Contributor hereby grants to You a perpetual,
60
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
61
+ copyright license to reproduce, prepare Derivative Works of,
62
+ publicly display, publicly perform, sublicense, and distribute the
63
+ Work and such Derivative Works in Source or Object form.
64
+
65
+ 3. Grant of Patent License. Subject to the terms and conditions of
66
+ this License, each Contributor hereby grants to You a perpetual,
67
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
68
+ (except as stated in this section) patent license to make, have made,
69
+ use, offer to sell, sell, import, and otherwise transfer the Work,
70
+ where such license applies only to those patent contributions
71
+ Licensable by such Contributor that are necessarily infringed by
72
+ their Contribution(s) alone or by the combination of their
73
+ Contribution(s) with the Work to which such Contribution(s) was
74
+ submitted. If You institute patent litigation against any entity
75
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
76
+ the Work or any Work embodied within the Work constitutes direct
77
+ or contributory patent infringement, then any patent licenses
78
+ granted to You under this License for that Work shall terminate
79
+ as of the date such litigation is filed.
80
+
81
+ 4. Redistribution. You may reproduce and distribute copies of the
82
+ Work or Derivative Works thereof in any medium, with or without
83
+ modifications, and in Source or Object form, provided that You
84
+ meet the following conditions:
85
+
86
+ (a) You must give any other recipients of the Work or Derivative
87
+ Works a copy of this License; and
88
+
89
+ (b) You must cause any modified files to carry prominent notices
90
+ stating that You changed the files; and
91
+
92
+ (c) You must retain, in the Source form of any Derivative Works
93
+ that You distribute, all copyright, patent, trademark, and
94
+ attribution notices from the Source form of the Work,
95
+ excluding those notices that do not pertain to any part of
96
+ the Derivative Works; and
97
+
98
+ (d) If the Work includes a "NOTICE" text file as part of its
99
+ distribution, You must include a readable copy of the
100
+ attribution notices contained within such NOTICE file, in
101
+ at least one of the following places: within a NOTICE text
102
+ file distributed as part of the Derivative Works; within
103
+ the Source form or documentation, if provided along with the
104
+ Derivative Works; or, within a display generated by the
105
+ Derivative Works, if and wherever such third-party notices
106
+ normally appear. The contents of the NOTICE file are for
107
+ informational purposes only and do not modify the License.
108
+ You may add Your own attribution notices within Derivative
109
+ Works that You distribute, alongside or in addition to the
110
+ NOTICE text from the Work, provided that such additional
111
+ attribution notices cannot be construed as modifying the License.
112
+
113
+ You may add Your own license statement for Your modifications and
114
+ may provide additional grant of rights to use, copy, modify, merge,
115
+ publish, distribute, sublicense, and/or sell copies of the
116
+ Contributions, either on an original or modified basis, or to
117
+ grant a third-party the rights to do so, provided you meet the
118
+ terms of this License.
119
+
120
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
121
+ any Contribution intentionally submitted for inclusion in the Work
122
+ by You to the Licensor shall be under the terms and conditions of
123
+ this License, without any additional terms or conditions.
124
+ Notwithstanding the above, nothing herein shall supersede or modify
125
+ the terms of any separate license agreement you may have executed
126
+ with Licensor regarding such Contributions.
127
+
128
+ 6. Trademarks. This License does not grant permission to use the trade
129
+ names, trademarks, service marks, or product names of the Licensor,
130
+ except as required for reasonable and customary use in describing the
131
+ origin of the Work and reproducing the content of the NOTICE file.
132
+
133
+ 7. Disclaimer of Warranty. Unless required by applicable law or
134
+ agreed to in writing, Licensor provides the Work (and each
135
+ Contributor provides its Contributions) on an "AS IS" BASIS,
136
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
137
+ implied, including, without limitation, any warranties or conditions
138
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
139
+ PARTICULAR PURPOSE. You are solely responsible for determining the
140
+ appropriateness of using or reproducing the Work and assume any
141
+ risks associated with Your exercise of permissions under this License.
142
+
143
+ 8. Limitation of Liability. In no event and under no legal theory,
144
+ whether in tort (including negligence), contract, or otherwise,
145
+ unless required by applicable law (such as deliberate and grossly
146
+ negligent acts) or agreed to in writing, shall any Contributor be
147
+ liable to You for damages, including any direct, indirect, special,
148
+ incidental, or exemplary damages of any character arising as a
149
+ result of this License or out of the use or inability to use the
150
+ Work (including but not limited to damages for loss of goodwill,
151
+ work stoppage, computer failure or malfunction, or all other
152
+ commercial damages or losses), even if such Contributor has been
153
+ advised of the possibility of such damages.
154
+
155
+ 9. Accepting Warranty or Additional Liability. While redistributing
156
+ the Work or Derivative Works thereof, You may include an offer,
157
+ accepting, as described in Sections 1 and 2 above, for additional
158
+ warranty or additional liability obligations consistent with the
159
+ License. However, in accepting such obligations, You may offer only
160
+ on Your own behalf and on Your behalf of all other Contributors, and
161
+ only if You agree to indemnify, defend, and hold each Contributor
162
+ harmless for any liability incurred by, or claims asserted against,
163
+ such Contributor by reason of your accepting any such warranty or
164
+ additional liability.
165
+
166
+ END OF TERMS AND CONDITIONS
167
+
168
+ APPENDIX: How to apply the Apache License to your work.
169
+
170
+ To apply the Apache License to your work, attach the following
171
+ boilerplate notice, with the fields enclosed by brackets "[]"
172
+ replaced with your own identifying information. (Don't include
173
+ the brackets!) The text should be enclosed in the appropriate
174
+ comment syntax for the format in question; however, since the
175
+ file itself may be readable as a machine, you may not include
176
+ the brackets! This is just an example notice; replace the text
177
+ according to your actual work.
178
+
179
+ Copyright 2026 Christophe Mendez
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
@@ -0,0 +1,126 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-einvoicing-core
3
+ Version: 0.1.0
4
+ Summary: Base package for European electronic invoicing MCP servers
5
+ Author: Christophe Mendez
6
+ License: Apache-2.0
7
+ License-File: LICENSE
8
+ Keywords: b2b,e-invoicing,einvoicing,europe,mcp,peppol,ubl
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Topic :: Office/Business :: Financial :: Accounting
15
+ Requires-Python: >=3.10
16
+ Requires-Dist: fastmcp>=2.0.0
17
+ Requires-Dist: httpx>=0.27.0
18
+ Requires-Dist: pydantic-settings>=2.3.0
19
+ Requires-Dist: pydantic>=2.7.0
20
+ Requires-Dist: python-dotenv>=1.0.0
21
+ Provides-Extra: dev
22
+ Requires-Dist: mypy>=1.10.0; extra == 'dev'
23
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
24
+ Requires-Dist: pytest-httpx>=0.30.0; extra == 'dev'
25
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
26
+ Requires-Dist: ruff>=0.4.0; extra == 'dev'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # mcp-einvoicing-core
30
+
31
+ **Topics:** `mcp` `mcp-server` `e-invoicing` `electronic-invoicing` `european-invoicing` `python` `fastmcp` `peppol` `en16931` `ubl` `fatturapa` `xp-z12-013` `xml` `base-library`
32
+
33
+ Base package for European electronic invoicing MCP servers.
34
+
35
+ Provides abstract base classes, shared Pydantic models, XML utilities, and an HTTP client
36
+ so country-specific packages (`mcp-facture-electronique-fr`, `mcp-fattura-elettronica-it`, …)
37
+ share a common foundation without duplicating code.
38
+
39
+ ---
40
+
41
+ ## What this package provides
42
+
43
+ | Module | Contents | Used by |
44
+ |--------|----------|---------|
45
+ | `models.py` | `InvoiceParty`, `InvoiceLineItem`, `VATSummary`, `PaymentTerms`, `InvoiceDocument`, `DocumentValidationResult` | IT (structured invoice generation), future BE/PL/DE/ES |
46
+ | `base_server.py` | `BaseDocumentGenerator`, `BaseDocumentValidator`, `BaseDocumentParser`, `BaseLifecycleManager`, `BasePartyValidator`, `EInvoicingMCPServer` | All country adapters |
47
+ | `xml_utils.py` | `format_amount`, `format_quantity`, `validate_date_iso`, `validate_iban`, `xml_element`, `xml_optional`, `format_error`, `filter_empty_values` | IT (extracted verbatim), future XML-based formats |
48
+ | `http_client.py` | `TokenCache`, `OAuthConfig`, `BaseEInvoicingClient` (OAuth2 + no-auth) | FR (extracted verbatim), future API-based countries |
49
+ | `exceptions.py` | `EInvoicingError`, `ValidationError`, `PartyValidationError`, `XSDValidationError`, `DocumentGenerationError`, `AuthenticationError`, `PlatformError` | All country adapters |
50
+ | `logging_utils.py` | `setup_logging`, `get_logger` | All country adapters |
51
+
52
+ ## Installation
53
+
54
+ ```bash
55
+ pip install mcp-einvoicing-core
56
+ ```
57
+
58
+ This package has **no country-specific dependencies**. `lxml` (needed for XSD validation
59
+ in IT and future countries) is declared by each country package individually.
60
+
61
+ ## Architecture
62
+
63
+ ```
64
+ mcp-einvoicing-core ← this package
65
+ ├── BaseDocumentGenerator ← abstract: generate(InvoiceDocument) → str
66
+ ├── BaseDocumentValidator ← abstract: validate(xml) → DocumentValidationResult
67
+ ├── BaseDocumentParser ← abstract: parse(xml) → dict
68
+ ├── BaseLifecycleManager ← abstract: submit/search/get_status (async HTTP)
69
+ ├── BasePartyValidator ← abstract: validate_seller/buyer/tax_id
70
+ ├── BaseEInvoicingClient ← concrete: async HTTP + OAuth2/no-auth/token
71
+ ├── InvoiceDocument (Pydantic) ← shared data model
72
+ └── EInvoicingMCPServer ← plugin registry wrapping FastMCP
73
+
74
+ mcp-facture-electronique-fr ← country adapter (FR)
75
+ ├── PAConfig(OAuthConfig)
76
+ ├── FlowClient(BaseEInvoicingClient) ← OAuth2, XP Z12-013 Annex A
77
+ ├── DirectoryClient(BaseEInvoicingClient) ← OAuth2, XP Z12-013 Annex B
78
+ └── FrLifecycleManager(BaseLifecycleManager)
79
+
80
+ mcp-fattura-elettronica-it ← country adapter (IT)
81
+ ├── ItalyPartyValidator(BasePartyValidator) ← Partita IVA modulo-10
82
+ ├── FatturaGenerator(BaseDocumentGenerator) ← FatturaPA XML v1.6.1
83
+ ├── FatturaValidator(BaseDocumentValidator) ← lxml XSD v1.6.1
84
+ └── FatturaParser(BaseDocumentParser) ← lxml xpath
85
+ ```
86
+
87
+ ## Plugin registration pattern
88
+
89
+ Country packages register their tools on a shared or standalone FastMCP instance:
90
+
91
+ ```python
92
+ # Standalone (existing server.py — no changes required)
93
+ from fastmcp import FastMCP
94
+ mcp = FastMCP(name="mcp-fattura-elettronica-it", instructions="…")
95
+ register_header_tools(mcp)
96
+ register_body_tools(mcp)
97
+ register_global_tools(mcp)
98
+
99
+ # Multi-country (optional EInvoicingMCPServer)
100
+ from mcp_einvoicing_core import EInvoicingMCPServer
101
+ server = EInvoicingMCPServer(name="mcp-einvoicing-eu", instructions="…")
102
+ server.register_plugin(register_header_tools, "it-header")
103
+ server.register_plugin(register_flow_tools, "fr-flow")
104
+ server.run()
105
+ ```
106
+
107
+ ## Claude Desktop / Cursor / Kiro compatibility
108
+
109
+ Existing configurations for `mcp-facture-electronique-fr` and `mcp-fattura-elettronica-it`
110
+ require **no changes**: tool names, signatures, environment variables, and entry points
111
+ (`server:main`) are fully preserved.
112
+
113
+ ## Roadmap compatibility
114
+
115
+ | Country | Standard | Inherits | Overrides | Known gaps |
116
+ |---------|----------|----------|-----------|------------|
117
+ | 🇫🇷 FR (existing) | XP Z12-013 | `BaseEInvoicingClient`, `BaseLifecycleManager` | `submit_lifecycle_status`, `healthcheck` | None |
118
+ | 🇮🇹 IT (existing) | FatturaPA v1.6.1 | `BaseDocumentGenerator`, `BaseDocumentValidator`, `BaseDocumentParser`, `BasePartyValidator` | all abstract methods | `to_invoice_document()` not yet implemented |
119
+ | 🇧🇪 BE 2026 | Peppol BIS 3.0 | all base classes | `generate()` → UBL 2.1, `validate()` → Schematron EN16931 | Need `BaseSchematronValidator` variant |
120
+ | 🇵🇱 PL 2026 | KSeF FA(2) | `BaseDocumentGenerator`, `BaseDocumentValidator`, `BaseLifecycleManager` | KSeF session auth flow | `MTLS` auth mode not yet implemented |
121
+ | 🇩🇪 DE | ZUGFeRD / XRechnung | all base classes | `generate()` returns PDF bytes (base64) | `generate()` return type: `str` vs `bytes` ambiguity |
122
+ | 🇪🇸 ES | FACeB2B / FacturaE | all base classes | mTLS auth | `MTLS` auth mode not yet implemented |
123
+
124
+ ## License
125
+
126
+ Apache 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,98 @@
1
+ # mcp-einvoicing-core
2
+
3
+ **Topics:** `mcp` `mcp-server` `e-invoicing` `electronic-invoicing` `european-invoicing` `python` `fastmcp` `peppol` `en16931` `ubl` `fatturapa` `xp-z12-013` `xml` `base-library`
4
+
5
+ Base package for European electronic invoicing MCP servers.
6
+
7
+ Provides abstract base classes, shared Pydantic models, XML utilities, and an HTTP client
8
+ so country-specific packages (`mcp-facture-electronique-fr`, `mcp-fattura-elettronica-it`, …)
9
+ share a common foundation without duplicating code.
10
+
11
+ ---
12
+
13
+ ## What this package provides
14
+
15
+ | Module | Contents | Used by |
16
+ |--------|----------|---------|
17
+ | `models.py` | `InvoiceParty`, `InvoiceLineItem`, `VATSummary`, `PaymentTerms`, `InvoiceDocument`, `DocumentValidationResult` | IT (structured invoice generation), future BE/PL/DE/ES |
18
+ | `base_server.py` | `BaseDocumentGenerator`, `BaseDocumentValidator`, `BaseDocumentParser`, `BaseLifecycleManager`, `BasePartyValidator`, `EInvoicingMCPServer` | All country adapters |
19
+ | `xml_utils.py` | `format_amount`, `format_quantity`, `validate_date_iso`, `validate_iban`, `xml_element`, `xml_optional`, `format_error`, `filter_empty_values` | IT (extracted verbatim), future XML-based formats |
20
+ | `http_client.py` | `TokenCache`, `OAuthConfig`, `BaseEInvoicingClient` (OAuth2 + no-auth) | FR (extracted verbatim), future API-based countries |
21
+ | `exceptions.py` | `EInvoicingError`, `ValidationError`, `PartyValidationError`, `XSDValidationError`, `DocumentGenerationError`, `AuthenticationError`, `PlatformError` | All country adapters |
22
+ | `logging_utils.py` | `setup_logging`, `get_logger` | All country adapters |
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ pip install mcp-einvoicing-core
28
+ ```
29
+
30
+ This package has **no country-specific dependencies**. `lxml` (needed for XSD validation
31
+ in IT and future countries) is declared by each country package individually.
32
+
33
+ ## Architecture
34
+
35
+ ```
36
+ mcp-einvoicing-core ← this package
37
+ ├── BaseDocumentGenerator ← abstract: generate(InvoiceDocument) → str
38
+ ├── BaseDocumentValidator ← abstract: validate(xml) → DocumentValidationResult
39
+ ├── BaseDocumentParser ← abstract: parse(xml) → dict
40
+ ├── BaseLifecycleManager ← abstract: submit/search/get_status (async HTTP)
41
+ ├── BasePartyValidator ← abstract: validate_seller/buyer/tax_id
42
+ ├── BaseEInvoicingClient ← concrete: async HTTP + OAuth2/no-auth/token
43
+ ├── InvoiceDocument (Pydantic) ← shared data model
44
+ └── EInvoicingMCPServer ← plugin registry wrapping FastMCP
45
+
46
+ mcp-facture-electronique-fr ← country adapter (FR)
47
+ ├── PAConfig(OAuthConfig)
48
+ ├── FlowClient(BaseEInvoicingClient) ← OAuth2, XP Z12-013 Annex A
49
+ ├── DirectoryClient(BaseEInvoicingClient) ← OAuth2, XP Z12-013 Annex B
50
+ └── FrLifecycleManager(BaseLifecycleManager)
51
+
52
+ mcp-fattura-elettronica-it ← country adapter (IT)
53
+ ├── ItalyPartyValidator(BasePartyValidator) ← Partita IVA modulo-10
54
+ ├── FatturaGenerator(BaseDocumentGenerator) ← FatturaPA XML v1.6.1
55
+ ├── FatturaValidator(BaseDocumentValidator) ← lxml XSD v1.6.1
56
+ └── FatturaParser(BaseDocumentParser) ← lxml xpath
57
+ ```
58
+
59
+ ## Plugin registration pattern
60
+
61
+ Country packages register their tools on a shared or standalone FastMCP instance:
62
+
63
+ ```python
64
+ # Standalone (existing server.py — no changes required)
65
+ from fastmcp import FastMCP
66
+ mcp = FastMCP(name="mcp-fattura-elettronica-it", instructions="…")
67
+ register_header_tools(mcp)
68
+ register_body_tools(mcp)
69
+ register_global_tools(mcp)
70
+
71
+ # Multi-country (optional EInvoicingMCPServer)
72
+ from mcp_einvoicing_core import EInvoicingMCPServer
73
+ server = EInvoicingMCPServer(name="mcp-einvoicing-eu", instructions="…")
74
+ server.register_plugin(register_header_tools, "it-header")
75
+ server.register_plugin(register_flow_tools, "fr-flow")
76
+ server.run()
77
+ ```
78
+
79
+ ## Claude Desktop / Cursor / Kiro compatibility
80
+
81
+ Existing configurations for `mcp-facture-electronique-fr` and `mcp-fattura-elettronica-it`
82
+ require **no changes**: tool names, signatures, environment variables, and entry points
83
+ (`server:main`) are fully preserved.
84
+
85
+ ## Roadmap compatibility
86
+
87
+ | Country | Standard | Inherits | Overrides | Known gaps |
88
+ |---------|----------|----------|-----------|------------|
89
+ | 🇫🇷 FR (existing) | XP Z12-013 | `BaseEInvoicingClient`, `BaseLifecycleManager` | `submit_lifecycle_status`, `healthcheck` | None |
90
+ | 🇮🇹 IT (existing) | FatturaPA v1.6.1 | `BaseDocumentGenerator`, `BaseDocumentValidator`, `BaseDocumentParser`, `BasePartyValidator` | all abstract methods | `to_invoice_document()` not yet implemented |
91
+ | 🇧🇪 BE 2026 | Peppol BIS 3.0 | all base classes | `generate()` → UBL 2.1, `validate()` → Schematron EN16931 | Need `BaseSchematronValidator` variant |
92
+ | 🇵🇱 PL 2026 | KSeF FA(2) | `BaseDocumentGenerator`, `BaseDocumentValidator`, `BaseLifecycleManager` | KSeF session auth flow | `MTLS` auth mode not yet implemented |
93
+ | 🇩🇪 DE | ZUGFeRD / XRechnung | all base classes | `generate()` returns PDF bytes (base64) | `generate()` return type: `str` vs `bytes` ambiguity |
94
+ | 🇪🇸 ES | FACeB2B / FacturaE | all base classes | mTLS auth | `MTLS` auth mode not yet implemented |
95
+
96
+ ## License
97
+
98
+ Apache 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,48 @@
1
+ # Release Notes
2
+
3
+ ## v0.1.0 — 2026-04-18
4
+
5
+ Initial public release.
6
+
7
+ ### What's included
8
+
9
+ **Abstract base classes** (`base_server.py`):
10
+ - `BaseDocumentGenerator` — generate e-invoice documents from `InvoiceDocument`
11
+ - `BaseDocumentValidator` — validate documents against a schema, returning `DocumentValidationResult`
12
+ - `BaseDocumentParser` — parse raw XML/bytes into structured dicts or `InvoiceDocument`
13
+ - `BaseLifecycleManager` — async submit, status, search, and lifecycle-event operations
14
+ - `BasePartyValidator` — validate seller/buyer parties and tax identifiers
15
+ - `EInvoicingMCPServer` — thin wrapper around `FastMCP` with plugin registration
16
+
17
+ **Shared Pydantic v2 models** (`models.py`):
18
+ - `TaxIdentifier`, `PartyAddress`, `InvoiceParty`, `InvoiceLineItem`
19
+ - `VATSummary`, `PaymentTerms`, `InvoiceDocument`, `DocumentValidationResult`
20
+
21
+ **XML utilities** (`xml_utils.py`):
22
+ - `format_amount`, `format_quantity` — Decimal-safe monetary/quantity formatting
23
+ - `validate_date_iso`, `validate_iban` — format validators
24
+ - `xml_element`, `xml_optional`, `xml_escape` — XML building helpers
25
+ - `format_error`, `filter_empty_values` — dict/response helpers
26
+
27
+ **HTTP client** (`http_client.py`):
28
+ - `BaseEInvoicingClient` — async httpx client with OAuth2 client_credentials, Bearer token, or no-auth modes; automatic token refresh and 401-retry
29
+ - `TokenCache` — in-memory token cache with configurable expiry margin
30
+ - `AuthMode` — enum (OAUTH2_CLIENT_CREDENTIALS, BEARER_TOKEN, NONE, MTLS†, API_KEY†)
31
+ - `OAuthConfig`, `BaseEInvoicingConfig` — pydantic-settings base configs
32
+
33
+ **Logging utilities** (`logging_utils.py`):
34
+ - `setup_logging`, `get_logger` — stderr-based structured logging
35
+
36
+ ### Country packages using this base
37
+
38
+ | Package | Version | Country |
39
+ |---------|---------|---------|
40
+ | `mcp-facture-electronique-fr` | v0.2.0 | 🇫🇷 France (AFNOR XP Z12-013) |
41
+ | `mcp-fattura-elettronica-it` | v0.2.0 | 🇮🇹 Italy (FatturaPA v1.6.1 / SDI) |
42
+
43
+ ### Known limitations
44
+
45
+ - MTLS and API_KEY auth modes are stubs (raise `NotImplementedError`)
46
+ - `BaseDocumentParser.to_invoice_document()` raises `NotImplementedError` by default
47
+ - `BaseLifecycleManager.submit_lifecycle_status()` and `healthcheck()` are stubs
48
+ - `lxml` is intentionally excluded — country packages that need XSD validation must declare it as their own dependency
@@ -0,0 +1,64 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "mcp-einvoicing-core"
7
+ version = "0.1.0"
8
+ description = "Base package for European electronic invoicing MCP servers"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "Apache-2.0" }
12
+ authors = [{ name = "Christophe Mendez" }]
13
+ keywords = ["mcp", "einvoicing", "e-invoicing", "europe", "b2b", "peppol", "ubl"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Programming Language :: Python :: 3.10",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "License :: OSI Approved :: Apache Software License",
20
+ "Topic :: Office/Business :: Financial :: Accounting",
21
+ ]
22
+
23
+ # [DECISION: minimal deps] Only include what is strictly needed by every country adapter.
24
+ # lxml is deliberately excluded — only countries that need XSD/XML validation (IT, DE, BE...)
25
+ # include it in their own pyproject.toml. pydantic-settings is included because every
26
+ # country needs some form of env-var config, even if minimal.
27
+ dependencies = [
28
+ "fastmcp>=2.0.0",
29
+ "httpx>=0.27.0",
30
+ "pydantic>=2.7.0",
31
+ "pydantic-settings>=2.3.0",
32
+ "python-dotenv>=1.0.0",
33
+ ]
34
+
35
+ [project.optional-dependencies]
36
+ dev = [
37
+ "pytest>=8.0.0",
38
+ "pytest-asyncio>=0.23.0",
39
+ "pytest-httpx>=0.30.0",
40
+ "mypy>=1.10.0",
41
+ "ruff>=0.4.0",
42
+ ]
43
+
44
+ [tool.hatch.build.targets.wheel]
45
+ packages = ["src/mcp_einvoicing_core"]
46
+
47
+ [tool.hatch.build.targets.sdist]
48
+ exclude = [
49
+ "tests/",
50
+ ".env*",
51
+ ".DS_Store",
52
+ ]
53
+
54
+ [tool.pytest.ini_options]
55
+ asyncio_mode = "auto"
56
+ testpaths = ["tests"]
57
+
58
+ [tool.ruff]
59
+ line-length = 100
60
+ target-version = "py310"
61
+
62
+ [tool.mypy]
63
+ python_version = "3.10"
64
+ strict = true