Skip to main content
Glama
verifactu-mcp

verifactu-mcp

verifactu-mcp

On PyPI as verifactu-keyflint-mcp (the name verifactu-mcp belongs to another project).

MCP server for Spanish invoicing compliance, built for AI agents working for gestorías, accountants and invoicing-software teams. Offline and stateless: nothing is stored and nothing is sent to the AEAT.

  • Audit VERI*FACTU chains: recompute the SHA-256 fingerprint (huella) of every record (alta and anulación) exactly as the AEAT specifies, and check that each record links to the previous one. Works on JSON records or on the XML any invoicing program exports (validated against the official SuministroLR.xsd).

  • AEAT tax QR: URL and PNG/SVG image (error correction M) for VERI*FACTU and non-VERI*FACTU systems, production or test portal, with the printing rules.

  • Facturae 3.2.2: build an invoice from plain data (totals, VAT breakdown, IRPF withholding, recargo de equivalencia, DIR3 codes for FACe, IBAN) and validate any Facturae file: official XSD, the arithmetic FACe checks, NIFs, DIR3 roles and signature presence.

The fingerprint code is tested against the three reference vectors published by the AEAT.

Tools

Tool

Credits

What it does

validate_invoice_chain

3

Audit a chain of records (JSON, up to 20,000): fingerprints, links, PrimerRegistro, duplicates, cancellations of unknown invoices, timestamps, NIF/date/amount/TipoFactura formats. continues_from audits a chain in pieces.

validate_verifactu_xml

3

Same audit on exported XML (RegFactuSistemaFacturacion, SOAP envelope or any XML with RegistroAlta/RegistroAnulacion), plus XSD validation.

verifactu_hash

1

Fingerprint of one record, with the exact string hashed.

generate_verifactu_qr

1

Tax QR URL + image + printing rules.

build_facturae

3

Facturae 3.2.2 XML (unsigned) from plain invoice data, XSD-validated.

validate_facturae

2

XSD + arithmetic + NIF + DIR3 + signature check of a Facturae file.

verifactu_calendar

free

Deadlines in force and what is pending in the BOE, with sources.

check_qr_url, validate_nif, pricing, credits_balance

free

Helpers.

Unreadable or invalid input is never charged; a tool that fails after charging is refunded.

Related MCP server: BeeL MCP server

Install

Claude Desktop / Claude Code / Cursor (mcpServers entry):

{
  "verifactu": {
    "command": "uvx",
    "args": ["--from", "verifactu-keyflint-mcp", "verifactu-mcp"],
    "env": { "KEYFLINT_LICENSE": "LIC-..." }
  }
}

Hosted (one server, many buyers): verifactu-mcp --http or the Dockerfile; each request carries Authorization: Bearer LIC-....

Environment: KEYFLINT_LICENSE, KEYFLINT_URL, KEYFLINT_PUBLIC_KEYS, KEYFLINT_CHECKOUT_URL, VERIFACTU_PRICES (e.g. validate_invoice_chain=5,build_facturae=4), VERIFACTU_MAX_BYTES (default 10 MB).

Visual cards (MCP Apps)

In Claude, ChatGPT, VS Code and Goose every paid tool and credits_balance renders as an interactive card in the chat: credit balance with a refill bar and a buy button, or a result summary (key figures, issues, table preview and credits charged). It is the ui://verifactu/card.html resource, self-contained with no network access. Other clients keep getting the same JSON as before.

  • VERI*FACTU (RD 1007/2023, Orden HAC/1177/2024; dates from RD-ley 15/2025): 1 Jan 2027 for corporate income tax payers, 1 Jul 2027 for everyone else. Hacienda announced on 5 Oct 2026 a further delay to October 2028, not yet published in the BOE. Taxpayers on SII and the foral territories are out of scope.

  • Mandatory B2B e-invoicing (RD 238/2026, Orden HAC/1028/2026): 6 Oct 2027 for turnover above 8 M EUR, 6 Oct 2028 for the rest; EN 16931 in UBL, CII, EDIFACT or Facturae.

  • Facturae with XAdES signature is mandatory for invoices to public administrations through FACe.

verifactu_calendar returns this with sources. Always confirm in the BOE.

Scope and limits

  • Not an invoicing system (SIF): it keeps no records, sends nothing to the AEAT and does not replace the producer's declaración responsable. Use it to check what a SIF produced, or to prepare data.

  • build_facturae produces unsigned XML. Sign it (XAdES-EPES) with the issuer's certificate before sending to FACe or a B2B platform. Corrective invoices (InvoiceClass OR) and batches are validated but not built yet.

  • If a stored fingerprint only matches after removing trailing zeros from the amounts, it is reported as a warning (correcta_sin_ceros): the record was generated with amounts written differently from the XML.

Sources

  • AEAT, Detalle de las especificaciones técnicas para generación de la huella o hash de los registros de facturación (reference vectors in tests/test_core.py).

  • AEAT, Características del QR y especificaciones del servicio de cotejo.

  • AEAT web service schemas SuministroLR.xsd / SuministroInformacion.xsd, and Facturaev3_2_2.xsd (facturae.gob.es), bundled in src/verifactu_mcp/schemas/ with the W3C xmldsig schema.

Development

pip install -e '.[test]'
pytest -q

Business Source License 1.1. Source available; production use needs a KeyFlint license (or must be non-commercial). Each version becomes Apache 2.0 four years after release. See LICENSE. The bundled XSD files belong to their publishers (AEAT, Ministerio de Hacienda, W3C).

Available Tools

11 tools
build_facturaeA
Read-onlyIdempotent
Inspect

Build a Facturae 3.2.2 invoice (XML) from plain data, with totals computed and the official XSD checked.

invoice: number (max 20), series, issue_date, operation_date?, currency (EUR), description?, notes?, legal_literals? [text], receiver_contract_reference?, seller / buyer: nif, name (company name, or first name with first_surname/second_surname for a person), address, post_code, town, province, country (ISO alfa-3, default ESP), residence? (R/U/E), email?, phone?; buyer.face: {oficina_contable, organo_gestor, unidad_tramitadora, organo_proponente?} DIR3 codes for public administration invoices (FACe), or administrative_centres: [{code, role 01-04, name?}], lines: [{description, quantity, unit_price, tax_rate (21, 10, 4, 0...), discount_pct?, surcharge_rate? (recargo de equivalencia 5.2, 1.4, 0.5), tax_type? (01 IVA, 03 IGIC, 02 IPSI), unit? (01 unidades), receiver_reference?, file_reference?, article_code?}], withholding?: {rate} (IRPF retention, e.g. 15 or 7), payment?: {due_date, method (transferencia, domiciliacion, efectivo, tarjeta...), iban, bic?}. Amounts accept "1.234,56" or "1234.56". Returns xml (UTF-8, unsigned), xml_base64, totals and the validation report. Invalid data is refused before charging. Sign the XML (XAdES) before sending to FACe.

Inputs: invoice (required). Returns: object

check_qr_urlB
Read-onlyIdempotent
Inspect

Check a tax QR URL read from an invoice: official AEAT host, path, parameters and formats. Free.

Inputs: url (required). Returns: object

credits_balanceA
Read-only
Inspect

Remaining credits on your KeyFlint license. Free.

Inputs: no named parameters. Returns: object

generate_verifactu_qrA
Read-onlyIdempotent
Inspect

Generate the AEAT tax QR ("QR tributario") of an invoice: URL and image.

Args: nif: Issuer NIF. numserie: Invoice series + number exactly as registered. fecha: Issue date (DD-MM-AAAA; AAAA-MM-DD and DD/MM/AAAA are converted). importe: ImporteTotal with decimal point, e.g. "241.40". verifactu: true for VERI*FACTU systems (ValidarQR), false for non-verifiable systems (ValidarQRNoVerifactu). environment: produccion (default) or pruebas (AEAT test portal). size_px: Image width in pixels (100-2000). image_format: png (default) or svg. The image uses error correction level M. print_rules says how it must appear on the invoice.

Inputs: nif (required), fecha (required), importe (required), numserie (required), +4 more. Returns: object

pricingA
Read-only
Inspect

Credit price of each tool and where to buy credits. Free.

Inputs: no named parameters. Returns: object

validate_facturaeA
Read-onlyIdempotent
Inspect

Validate a Facturae 3.2.2 file (.xml or signed .xsig) before sending it to FACe or a client.

Checks the official XSD, the arithmetic FACe checks (line amounts, tax quotas, header vs line bases, totals, batch totals, installments), NIFs of resident parties, the three DIR3 codes for public administrations, and whether the file is signed. Files that are not Facturae are not charged.

Inputs: content, content_base64. Returns: object

validate_invoice_chainA
Read-onlyIdempotent
Inspect

Audit a VERI*FACTU chain of records (in generation order) given as JSON objects.

Each record has the fields of verifactu_hash plus Huella (stored fingerprint) and optionally HuellaAnterior or RegistroAnterior {IDEmisorFactura, NumSerieFactura, FechaExpedicionFactura, Huella} and PrimerRegistro ("S"). For every record the fingerprint is recomputed and compared, and the link to the previous record checked. Reports chain breaks, altered records, PrimerRegistro misuse, duplicate invoices, cancellations of unknown invoices, timestamps going backwards, invalid NIF/dates/amounts/TipoFactura. continues_from: last fingerprint of the previous batch, to audit a chain in pieces. Up to 20,000 records. last_huella is what the next record must link to.

Inputs: records (required), continues_from. Returns: object

validate_nifA
Read-onlyIdempotent
Inspect

Check a Spanish NIF / NIE / CIF control character. Free.

Inputs: nif (required). Returns: object

validate_verifactu_xmlB
Read-onlyIdempotent
Inspect

Audit VERI*FACTU XML exported by an invoicing program (RegFactuSistemaFacturacion, a SOAP envelope, or any XML holding RegistroAlta / RegistroAnulacion elements, in document order).

Validates RegFactuSistemaFacturacion against the official AEAT schema (SuministroLR.xsd) when present, then runs every chain and fingerprint check of validate_invoice_chain. XML that holds no records is not charged.

Inputs: content, content_base64, continues_from. Returns: object

verifactu_calendarA
Read-only
Inspect

Legal deadlines for VERI*FACTU and mandatory B2B e-invoicing in Spain, with sources and what is still pending publication. Free.

Inputs: no named parameters. Returns: object

verifactu_hashA
Read-onlyIdempotent
Inspect

Compute the VERI*FACTU fingerprint (huella, SHA-256) of one invoicing record.

record (AEAT field names; snake_case aliases accepted): alta: IDEmisorFactura, NumSerieFactura, FechaExpedicionFactura (DD-MM-AAAA), TipoFactura (F1, F2, F3, R1-R5), CuotaTotal, ImporteTotal (as written in the XML, decimal point), FechaHoraHusoGenRegistro (AAAA-MM-DDThh:mm:ss+hh:mm). anulación (TipoRegistro="anulacion"): IDEmisorFacturaAnulada, NumSerieFacturaAnulada, FechaExpedicionFacturaAnulada, FechaHoraHusoGenRegistro. previous_huella: fingerprint of the previous record of the chain; empty for the first record. Returns the fingerprint, the exact string hashed and any field problems (an error means the AEAT would reject the record).

Inputs: record (required), previous_huella. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 11 tools

    Disambiguation4/5

    Each tool targets a distinct artifact and action: hash one record, audit a JSON chain, audit an XML export, generate vs. check a QR, build vs. validate Facturae, check a NIF. The cluster verifactu_hash / validate_invoice_chain / validate_verifactu_xml is related but differentiated by input (single record, JSON array, XML file), and the descriptions make the boundaries explicit. Only slight residual risk that an agent picks validate_invoice_chain when it actually has XML, or verifactu_hash when it wants the whole chain.

    Naming Consistency3/5

    The dominant pattern is verb_noun (validate_invoice_chain, validate_verifactu_xml, validate_facturae, validate_nif, generate_verifactu_qr, build_facturae, check_qr_url). However verifactu_calendar and verifactu_hash are resource-first with no verb, and pricing / credits_balance are bare nouns, so conventions are mixed. Still readable overall, but not a predictable single scheme.

    Tool Count5/5

    11 tools is well inside the comfortable range and every tool earns its place: four free utility/meta tools (calendar, pricing, balance, NIF) plus seven paid domain operations. No obvious redundancy or filler.

    Completeness4/5

    The surface covers the full compliance lifecycle for Spanish e-invoicing: NIF validation, record hashing, chain and XML auditing, QR generation and verification, and Facturae build/validate with XSD checks. Minor gaps: there is no tool to emit the full VERI*FACTU submission XML or sign documents, and QR checking has no counterpart image-decoding step, but these are reasonably out of scope and workable around.

    Maintenance

    ActivityMaintained
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Provides access to official Spanish fiscal data and tools based on AEAT and BOE sources, covering income tax, VAT, and regional deductions. It enables AI assistants to answer tax-related queries and verify filing deadlines using verified information.
      10
      10 npm
      13
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to issue, correct, and register legally compliant Spanish electronic invoices with AEAT VeriFactu, supporting F1/F2 types, R1–R5 correctives, and NIF validation from Claude, ChatGPT, Cursor, or VS Code.
      136
      480 npm
      2
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI assistants to locally parse, validate, audit, explain, generate, and convert XRechnung and ZUGFeRD/Factur-X e-invoices using official rule sets, fully offline with no API keys required.
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to validate Mexican RFC, CURP, CLABE and NSS identifiers with real check digits, parse CFDI 4.0 invoices with labelled SAT catalogue codes and verified totals, and query the SAT's public status service to see whether an invoice is still valid. It also generates coherent test people and companies, all read-only and without API keys, certificates or PAC contracts.
      9
      280 npm
      1
      MIT