Skip to main content
Glama
cmendezs

mcp-fattura-elettronica-it

Generate Fattura Xml

generate_fattura_xml

Generate a complete FatturaPA XML by combining prepared invoice blocks—use as the final assembly step before XSD validation.

Instructions

Assemble a complete FatturaPA v1.2.3 XML document from all prepared blocks.

Use this as step 10 in the invoice generation workflow — the final assembly step. All required blocks must come from their respective builder/validator tools; pass the full dict returned by each tool (the function unwraps the top-level key).

Required: dati_trasmissione, cedente_prestatore, cessionario_committente, dati_generali, dettaglio_linee (list), dati_riepilogo (list from compute_totali()). Optional: dati_pagamento, allegati (list), dati_ritenuta.

Does NOT validate against the XSD schema — call validate_fattura_xsd() (step 11) on the returned 'xml' string immediately after to confirm conformance.

On success returns {'xml': str, 'filename': str, 'formato_trasmissione': str, 'length_bytes': int}. On unexpected error returns {'error': ''}.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
allegatiNoList of Allegati dicts from add_allegato(). Optional.
dati_generaliYesDatiGenerali block from build_dati_generali(). Contains document type, date, number, and currency.
dati_ritenutaNoDatiRitenuta block from check_ritenuta_acconto(). Required for professional invoices with withholding tax (ritenuta d'acconto).
dati_pagamentoNoDatiPagamento block from build_dati_pagamento(). Optional.
dati_riepilogoYesList of DatiRiepilogo dicts from compute_totali(). Contains VAT summary grouped by AliquotaIVA.
dettaglio_lineeYesList of DettaglioLinee dicts from add_linea_dettaglio(). Each entry must have NumeroLinea, Descrizione, PrezzoUnitario, PrezzoTotale, and AliquotaIVA.
additional_bodiesNoAdditional FatturaElettronicaBody blocks for FPA12 batch invoicing. Each entry is a dict with keys: dati_generali, dettaglio_linee, dati_riepilogo, and optionally dati_pagamento, allegati, dati_ritenuta. Only valid for FPA12 (B2G) transmissions; FPR12 does not support batching.
dati_trasmissioneYesDatiTrasmissione block from build_transmission_header(). Must contain IdTrasmittente, ProgressivoInvio, FormatoTrasmissione, and CodiceDestinatario.
cedente_prestatoreYesCedentePrestatore block from validate_cedente_prestatore(). Contains seller's tax ID, name, address, and fiscal regime.
cessionario_committenteYesCessionarioCommittente block from validate_cessionario(). Contains buyer's tax ID, name, and address.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.7.0
    • addedInput schema / properties / additional_bodies
      Added value: +{
      +  "anyOf": [
      +    {
      +      "items": {},
      +      "type": "array"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Additional FatturaElettronicaBody blocks for FPA12 batch invoicing. Each entry is a dict with keys: dati_generali, dettaglio_linee, dati_riepilogo, and optionally dati_pagamento, allegati, dati_ritenuta. Only valid for FPA12 (B2G) transmissions; FPR12 does not support batching."
      +}
  2. First observedv0.2.0

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Since there are no annotations, the description carries the behavioral burden. It plainly discloses that the tool does NOT validate against the XSD schema, that it unwraps the top-level key of input dicts, and that it returns either a success dict or an unexpected-error dict. This is enough for an agent to call it correctly and know what to do afterward.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and well organized: purpose, workflow placement, required/optional inputs, warning about lack of validation, and output/error shapes. Every sentence provides actionable information and there is no filler or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 10-parameter assembly function with no annotations, the description is nearly complete: it names inputs, output fields, errors, and the required next validation step. It loses one point because the main description does not mention the additional_bodies parameter explicitly; an agent would need to rely on the schema, but the schema does provide enough context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is already 100%, so the schema carries the detailed parameter descriptions. The description still adds useful cross-tool context, such as which builder tools supply each block, which parameters are lists, and what must exist inside each block. It is not a 5 because the top-level description omits the additional_bodies parameter from its own optional list, though the schema covers it.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description starts with a specific action and resource: 'Assemble a complete FatturaPA v1.2.3 XML document from all prepared blocks.' It also positions this as the final assembly step, which distinguishes it from the builder/validation siblings and from simplified/UBL/CII invoice formats.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explicitly says this is step 10 in the invoice generation workflow and instructs the agent to call validate_fattura_xsd() as step 11 immediately after. It also states that all required blocks must come from the appropriate builder/validator tools, giving clear when-to-use and next-step guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.