Skip to main content

mcp-fattura-elettronica-it ๐Ÿ‡ฎ๐Ÿ‡น

English | Italiano

License PyPI version Python mcp-fattura-elettronica-it MCP server

A Python MCP server for Italian electronic invoicing in FatturaPA XML format (SDI / Agenzia delle Entrate standard, version 1.2.3). It enables AI agents (Claude, IDEs) to generate, validate, and analyze B2B, B2G, and cross-border electronic invoices that are directly compliant with the technical specifications of the Sistema di Interscambio (SDI).

This is a Model Context Protocol (MCP) server exposing 42 tools covering the full lifecycle of a FatturaPA XML document: transmission header construction, seller/buyer validation, document type codes (TD01-TD28), line items, VAT summary computation, payment terms, XSD validation against the official Agenzia delle Entrate schema (v1.2.3), XML generation, parsing, JSON export, SDI filename generation, withholding tax (ritenuta d'acconto) calculation, digital signatures (XAdES-BES and CAdES-BES), direct SDI transmission via SDICoop SOAP, SDI notification parsing, and conservazione sostitutiva (legally compliant archiving per AgID). Licensed under Apache 2.0.


๐Ÿš€ Installation

Via PyPI (recommended)

pip install mcp-fattura-elettronica-it

mcp-einvoicing-core is installed automatically as a dependency. lxml is also required and included, so no extra steps are needed.

Without prior installation, using uvx:

uvx mcp-fattura-elettronica-it

From source

git clone https://github.com/cmendezs/mcp-fattura-elettronica-it.git
cd mcp-fattura-elettronica-it

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

pip install -e ".[dev]"
cp .env.example .env

โš™๏ธ Configuration

The available environment variables are:

Variable Description Default
LOG_LEVEL Log level (DEBUG, INFO, WARNING, ERROR) INFO
FATTURA_XSD_PATH Path to the FatturaPA XSD file schemas/FatturaPA_v1.2.3.xsd
SDI_ENVIRONMENT SDI environment: test or production test
SDI_CERT_PATH Path to the PKCS#12 mTLS certificate for SDI (none)
SDI_CERT_PASSWORD Passphrase for the PKCS#12 file (none)
SDI_ENDPOINT_URL SDICoop endpoint URL override (auto from environment)
SDI_CHANNEL_ID Channel ID assigned during AdE accreditation (none)
EINVOICING_SIGNER_SOCKET Unix socket for the signer microservice (none)
EINVOICING_SIGNER_TOKEN Auth token for the signer microservice (none)
CONSERVAZIONE_STORAGE_PATH Local archive storage path (dev only) .conservazione/

๐Ÿค– Claude Desktop integration

Add the following to your claude_desktop_config.json file:

{
  "mcpServers": {
    "fattura-elettronica-it": {
      "command": "uvx",
      "args": ["mcp-fattura-elettronica-it"]
    }
  }
}

โŒจ๏ธ Cursor integration

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

{
  "mcpServers": {
    "fattura-elettronica-it": {
      "command": "uvx",
      "args": ["mcp-fattura-elettronica-it"]
    }
  }
}

๐Ÿช Kiro integration

{
  "mcpServers": {
    "fattura-elettronica-it": {
      "command": "uvx",
      "args": ["mcp-fattura-elettronica-it"],
      "disabled": false,
      "autoApprove": []
    }
  }
}

๐Ÿงฐ Available MCP tools

Header: FatturaElettronicaHeader (7 tools)

Tool Description
build_transmission_header Build DatiTrasmissione block: ProgressivoInvio, CodiceDestinatario, PECDestinatario
validate_cedente_prestatore Validate seller block: IdFiscaleIVA, Anagrafica, Sede, RegimeFiscale codes
validate_cessionario Validate buyer block: IdFiscaleIVA or CodiceFiscale, Sede
get_regime_fiscale_codes Return all valid RegimeFiscale codes with descriptions (RF01-RF19)
validate_partita_iva Validate Italian VAT number (Partita IVA) format and checksum (11 digits)
generate_progressivo_invio Generate a unique ProgressivoInvio identifier (max 10 alphanumeric chars)
lookup_codice_destinatario Return info about a CodiceDestinatario (6-char SDI code) or PEC address

Body: FatturaElettronicaBody (7 tools)

Tool Description
build_dati_generali Build DatiGenerali block: TipoDocumento, Divisa, Data, Numero, Causale
get_tipo_documento_codes Return all TD01-TD28 codes with descriptions and use cases (incl. cross-border)
add_linea_dettaglio Add a DettaglioLinee entry: NumeroLinea, Descrizione, Quantita, PrezzoUnitario
compute_totali Compute DatiRiepilogo: imponibile, imposta, AliquotaIVA from line items
get_natura_codes Return all Natura codes (N1-N7 and sub-codes) for VAT exemption with legal references
build_dati_pagamento Build DatiPagamento: CondizioniPagamento (TP01/02/03), ModalitaPagamento (MP01-MP23)
add_allegato Attach a base64-encoded document to the Allegati block with name and format

Global: generation and validation (7 tools)

Tool Description
generate_fattura_xml Generate a complete FatturaPA XML file from structured input data
validate_fattura_xsd Validate a FatturaPA XML string against the official XSD schema v1.2.3
parse_fattura_xml Parse an existing FatturaPA XML string and return a structured JSON dict
export_to_json Export a parsed FatturaPA structure to clean JSON format
validate_partita_iva_format Validate Partita IVA format and Luhn-like checksum (11-digit Italian VAT)
get_sdi_filename Generate the official SDI filename: IT{PartitaIVA}_{ProgressivoInvio}.xml
check_ritenuta_acconto Check and compute ritenuta d'acconto (withholding tax) for professional invoices

Simplified invoices: FatturaSemplificata VFSM10 (3 tools)

Tool Description
generate_fattura_semplificata Generate a simplified invoice XML (TD07/TD08/TD09) using VFSM10 format
validate_fattura_semplificata_xsd Validate a simplified invoice XML against the VFSM10 XSD v1.0.2
parse_fattura_semplificata_xml Parse a simplified invoice XML into a structured dict

Simplified invoices (art. 21-bis DPR 633/72) are valid for transactions up to EUR 400 (tax-inclusive). They use a flatter structure than ordinary FatturaPA: no per-line VAT breakdown, no DatiRiepilogo. Each DatiBeniServizi entry carries its own Descrizione, Importo, and DatiIVA. The VFSM10 format uses namespace v1.0 and is separate from the EN 16931 CIUS used by ordinary invoices.

Digital signatures (2 tools)

Tool Description
sign_fattura_xades Apply XAdES-BES enveloped XML signature (.xml). Requires PKCS#12 cert.
sign_fattura_cades Apply CAdES-BES CMS/PKCS#7 attached signature (.xml.p7m). Requires PKCS#12 cert.

Both signature formats are accepted by SDI (Specifiche tecniche SDI v1.8.4, section 2.1). Supports dual mode: signer microservice (keeps keys out of the MCP process) or direct PKCS#12 loading. Requires cryptography>=42.0.0 (installed via the [xml-sign] extra on mcp-einvoicing-core).

SDI integration (5 tools)

Tool Description
submit_to_sdi Submit a signed invoice to SDI via SDICoop SOAP (mTLS)
check_sdi_status Check submission status by IdentificativoSDI
parse_sdi_notification Parse SDI notification XML (RC/NS/MC/NE/EC/SE/DT/MT/AT)
send_esito_committente Send acceptance (EC01) or rejection (EC02) to SDI
get_sdi_channel_info Show current SDI channel configuration

Requires AdE accreditation for production use. Configure via SDI_CERT_PATH, SDI_CERT_PASSWORD, SDI_ENVIRONMENT (test/production), and SDI_ENDPOINT_URL (override) environment variables.

Conservazione sostitutiva / archiving (5 tools)

Tool Description
archive_invoice Archive a signed invoice with SHA-256 hash and 10-year retention
retrieve_archived_invoice Retrieve an archived document by ID
verify_archive_integrity Verify SHA-256 hash integrity of an archived document
list_archived_invoices List all archived invoices
build_pacchetto_versamento Build a PdV ZIP archive for transfer to an AgID-accredited conservator

Per AgID circolare 65/2014 and DM 17/06/2014, electronic invoices must be archived for a minimum of 10 years. The local filesystem backend is for development only; production requires integration with an AgID-accredited conservazione provider.


Usage examples

Example 1: Generate a complete B2B invoice

1. validate_partita_iva_format("01234567897")
   โ†’ { "valid": true }

2. generate_progressivo_invio(sequence=1)
   โ†’ { "progressivo_invio": "00001" }

3. build_transmission_header(id_paese="IT", id_codice="01234567897",
     progressivo_invio="00001", formato_trasmissione="FPR12",
     codice_destinatario="ABC123")

4. validate_cedente_prestatore(id_paese="IT", id_codice="01234567897",
     denominazione="ACME Srl", regime_fiscale="RF01",
     indirizzo="Via Roma 1", cap="00100", comune="Roma", nazione="IT")

5. validate_cessionario(denominazione="Buyer Srl",
     id_paese="IT", id_codice="98765432109",
     indirizzo="Via Verdi 2", cap="20100", comune="Milano")

6. build_dati_generali(tipo_documento="TD01", data="2026-01-15",
     numero="2026/001", divisa="EUR")

7. add_linea_dettaglio(numero_linea=1, descrizione="Consulenza informatica",
     quantita=8, unita_misura="ORE", prezzo_unitario=100.0,
     prezzo_totale=800.0, aliquota_iva=22.0)

8. compute_totali(linee=[{"prezzo_totale": 800.0, "aliquota_iva": 22.0}])
   โ†’ { "totale_fattura": "976.00" }

9. build_dati_pagamento(condizioni_pagamento="TP02", modalita_pagamento="MP05",
     importo_pagamento=976.0, iban="IT60X0542811101000000123456")

10. generate_fattura_xml(...all previous blocks...)
    โ†’ { "xml": "<?xml ...", "filename": "IT01234567897_00001.xml" }

11. validate_fattura_xsd(xml_string=...)
    โ†’ { "valid": true }

Example 2: Professional invoice with withholding tax

check_ritenuta_acconto(imponibile=1000.0, tipo_ritenuta="RT02",
  causale_pagamento="A")
โ†’ {
    "DatiRitenuta": {
      "TipoRitenuta": "RT02",
      "ImportoRitenuta": "200.00",
      "AliquotaRitenuta": "20.00",
      "CausalePagamento": "A"
    },
    "importo_ritenuta": "200.00"
  }

Example 3: Look up VAT exemption codes

get_natura_codes()
โ†’ codes: [
    { "code": "N3.1", "description": "Non imponibili โ€” esportazioni",
      "legal_ref": "Art. 8 DPR 633/72" },
    { "code": "N6.1", "description": "Inversione contabile โ€” rottami",
      "legal_ref": "Art. 74 c. 7-8 DPR 633/72" },
    ...
  ]

Architecture

mcp-fattura-elettronica-it (this package, standalone MCP server)
โ”œโ”€โ”€ ItalyPartyValidator(BasePartyValidator)   โ† Partita IVA modulo-10
โ”œโ”€โ”€ FatturaGenerator(BaseDocumentGenerator)   โ† FatturaPA XML v1.2.3
โ”œโ”€โ”€ FatturaValidator(BaseDocumentValidator)   โ† lxml XSD v1.2.3
โ””โ”€โ”€ FatturaParser(BaseDocumentParser)         โ† lxml xpath

        โ†‘ extends
mcp-einvoicing-core (shared foundation, installed as dependency)
โ”œโ”€โ”€ BaseDocumentGenerator / Validator / Parser / PartyValidator
โ”œโ”€โ”€ InvoiceDocument, InvoiceParty, InvoiceLineItem โ€ฆ (Pydantic)
โ”œโ”€โ”€ xml_utils, logging_utils, exceptions
โ””โ”€โ”€ EInvoicingMCPServer (optional multi-country aggregator)

๐Ÿ“š Reference standards

Resource Link
FatturaPA specifications fatturapa.gov.it
Official XSD v1.2.3 Schema v1.2.2, Agenzia delle Entrate
XML namespace http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2
SDI, Sistema di Interscambio Agenzia delle Entrate
Withholding tax (ritenuta d'acconto) Art. 25 DPR 600/73, Modello 770

๐Ÿงช Tests

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

# Run all tests
pytest tests/ -v

# Run only MCP integration tests
pytest tests/test_mcp_integration.py -v

Roadmap

Version Features
v0.1.0 XML generation, XSD validation, parsing, 21 MCP tools, withholding tax
v0.2.0 Simplified invoices (TD07/TD08/TD09), FPA12 batch invoicing, Codice Fiscale validation, VAT rate warnings, 30 MCP tools
v0.3.0 SdI lifecycle scope boundary documented, transmission field defaults removed
v0.5.0 (current) XAdES-BES and CAdES-BES digital signatures, direct SDI integration (SDICoop SOAP), conservazione sostitutiva (AgID archiving), 42 MCP tools
v0.6.0 SFTP channel, AgID-accredited provider API integration

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 distributed under the Apache 2.0 license. See the LICENSE file for full details.

Copyright 2026 cmendezs


Project maintained by cmendezs. For questions about the FatturaPA standard implementation, please open an Issue.

Download files

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

Source Distribution

mcp_fattura_elettronica_it-0.6.0.tar.gz (8.8 MB view details)

Uploaded Source

Built Distribution

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

mcp_fattura_elettronica_it-0.6.0-py3-none-any.whl (99.4 kB view details)

Uploaded Python 3

File details

Details for the file mcp_fattura_elettronica_it-0.6.0.tar.gz.

File metadata

File hashes

Hashes for mcp_fattura_elettronica_it-0.6.0.tar.gz
Algorithm Hash digest
SHA256 e55906cdf3657e2328b2e8f3d3dea0bba498e066410dbef3577fabcf690c9449
MD5 3a06e6861bee9491fdf6c361dee0121c
BLAKE2b-256 2f63dea378568a0407bad7851913167612ca41e5c7743fa13fe9f64e6c3b49bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_fattura_elettronica_it-0.6.0.tar.gz:

Publisher: publish.yml on cmendezs/mcp-fattura-elettronica-it

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_fattura_elettronica_it-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_fattura_elettronica_it-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a7e4316c6f11f345ecbdf90dfce4444ade426d3fdfef0003126bd3680d57e52
MD5 d78022df8c5a91a00d48385982e1c264
BLAKE2b-256 da66afe507cd3445c0b06eea863938ce0918aa9545482e3941c25d7ca88c1d81

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcp_fattura_elettronica_it-0.6.0-py3-none-any.whl:

Publisher: publish.yml on cmendezs/mcp-fattura-elettronica-it

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

Release history Release notifications | RSS feed

0.7.0

2 files

0.6.1

2 files

This release

0.6.0 This release

2 files

0.5.0

2 files

0.3.0

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

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