Skip to main content
Glama
MaurizioLisanti

fatturapa-mcp-server

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
FATTURAPA_ALLOWED_ROOTSNoLists the only folders the server may read (`:` separated on macOS/Linux, `;` on Windows). Without it every `file_path` read is refused and documents must be passed as `xml_content`.

Instructions

Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.

This server publishes no instructions, or was last inspected before Glama recorded them.

Capabilities

Features and capabilities supported by this server

Protocol revision2025-11-25

CapabilityDetails
tools
{
  "listChanged": false
}
prompts
{
  "listChanged": false
}
resources
{
  "subscribe": false,
  "listChanged": false
}
experimental
{}

Tools

Functions exposed to the LLM to take actions

NameDescription
validate_invoiceA

Validate a FatturaPA XML document against the appropriate XSD schema.

Auto-detects schema version (v1.2 or v1.3) from the XML namespace. Returns a structured result without logging any XML content.

When file_path is given the document is read from disk; the path is checked against the roots configured in FATTURAPA_ALLOWED_ROOTS before any read is attempted. Pass xml_content directly to skip file I/O.

Args: xml_content: Raw XML string of the FatturaPA document. ctx: Optional MCP context for structured log emission. file_path: Optional filesystem path to read the document from. Checked against allowed roots before reading.

Returns: A ValidateResult with keys: valid (bool): Whether the document passed XSD validation. version (str): Detected schema version ("1.2", "1.3", or "unknown"). errors (list[str]): Validation error messages, empty if valid.

Raises: PermissionError: If file_path is outside the configured allowed roots. ValueError: If neither xml_content nor file_path is provided.

extract_invoice_dataA

Extract key fields from a validated FatturaPA XML document.

Parses the header and first body section to return structured invoice metadata. Never logs or persists XML content — only derived values are returned. Missing fields yield None rather than raising KeyError.

When file_path is given the document is read from disk; the path is checked against the roots configured in FATTURAPA_ALLOWED_ROOTS before any read is attempted. Pass xml_content directly to skip file I/O.

Args: xml_content: Raw XML string of a validated FatturaPA document. ctx: Optional MCP context for structured log emission. file_path: Optional filesystem path to read the document from. Checked against allowed roots before reading.

Returns: An ExtractResult TypedDict with supplier, customer, invoice header fields, and aggregated line_items from all body sections.

Raises: PermissionError: If file_path is outside the configured allowed roots. ValueError: If neither xml_content nor file_path is provided. lxml.etree.XMLSyntaxError: If the XML is not well-formed.

lookup_sdi_errorA

Look up an SDI error code and return its human-readable description.

Uses a local static table of official AdE error codes. No network call required.

Args: error_code: SDI error code string (e.g., "00001", "00002"). ctx: Optional MCP context for structured log emission.

Returns: A LookupResult with keys: code (str): The queried error code. description (str): Official Italian description. category (str): Error category (e.g., "STRUTTURA", "CONTENUTO"). resolution (str): Suggested resolution hint.

Raises: ValueError: If error_code is not found in the known error table.

check_pivaA

Validate an Italian VAT number using the official MEF checksum algorithm.

Performs format validation and the Ministry of Economy checksum algorithm. No network call — fully local computation.

Args: piva: Italian VAT number string. May include or omit the "IT" prefix. Expected: 11 digits after stripping prefix and whitespace. ctx: Optional MCP context for structured log emission.

Returns: A CheckPivaResult with keys: valid (bool): Whether the P.IVA passes format and checksum checks. piva (str): Normalised P.IVA (11 digits, no prefix). reason (str | None): Failure reason if valid is False, else None.

verify_piva_viesA

Verify a VAT number against the EU VIES (VAT Information Exchange System).

Calls the official EU VIES REST endpoint with a configurable timeout. On timeout or service unavailability, returns a degraded response with source="unavailable" rather than raising — the caller must handle this case.

Args: country_code: Two-letter ISO 3166-1 alpha-2 country code (e.g., "IT"). vat_number: VAT number without the country prefix (e.g., "12345678901"). ctx: Optional MCP context for structured log emission.

Returns: A VerifyPivaViesResult with keys: valid (bool): Whether VIES confirmed the VAT number as active. name (str | None): Registered business name, if disclosed by VIES. address (str | None): Registered address, if disclosed by VIES. source (str): "vies" if live response, "unavailable" if service down.

find_invoice_anomaliesA

Detect inconsistencies and anomalies in a FatturaPA XML document.

Checks eight anomaly categories: document total mismatch, VAT calculation error, future invoice date, invalid Italian P.IVA checksum, missing or suspicious destination code, incomplete line items, unjustified negative amount, and missing payment data. Never logs or persists XML content.

When file_path is given the document is read from disk; the path is checked against the roots configured in FATTURAPA_ALLOWED_ROOTS before any read is attempted. Pass xml_content directly to skip file I/O.

Args: xml_content: Raw XML string of the FatturaPA document. ctx: Optional MCP context for structured log emission. file_path: Optional filesystem path to read the document from. Checked against allowed roots before reading.

Returns: A FindAnomaliesResult with keys: anomalies_found (int): Total number of anomalies detected. anomalies (list): All anomaly records. warnings (list): Only warning-severity anomalies. errors (list): Only error-severity anomalies. is_clean (bool): True when no anomalies are found.

Raises: PermissionError: If file_path is outside the configured allowed roots. ValueError: If neither xml_content nor file_path is provided. lxml.etree.XMLSyntaxError: If the XML is not well-formed.

generate_invoice_reportA

Aggregate a batch of FatturaPA XML documents into a structured report.

Processes each invoice through extract_invoice_data and find_invoice_anomalies, then aggregates the results into totals, supplier/customer breakdowns, and an anomaly summary. Documents that cannot be parsed are counted separately in the errors list; they do not affect the monetary totals. Never logs or persists XML content.

Progress notifications: one step per invoice (1..N), then a final step (N+1) for the aggregation phase.

Args: xml_contents: List of raw FatturaPA XML strings to process. title: Optional report title; defaults to "Invoice Report". ctx: Optional MCP context for structured log emission.

Returns: An InvoiceReportResult TypedDict with aggregated statistics, party breakdowns (suppliers/customers), and an anomaly summary.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription
list_allowed_rootsExpose the configured file-system roots that tools may read from. Returns a newline-separated list of allowed directory paths, or a human-readable notice when no restrictions are configured. Clients can read this resource to discover which paths are accessible before calling validate_invoice or extract_invoice_data with a file_path argument. Returns: Newline-separated root paths; ``"(unrestricted)"`` when the operator opted out of the guard; ``"(no roots configured)"`` when file-system reads are disabled and documents must be passed as xml_content.

TDQS

A4.1/5.0

Scored across 7 tools

Disambiguation5/5

Each tool targets a clearly distinct action: schema validation, field extraction, error-code lookup, local VAT checksum, network VIES verification, anomaly detection, and batch reporting. The only superficially similar pair, check_piva vs verify_piva_vies, is explicitly differentiated (local MEF checksum vs live EU VIES call).

Naming Consistency5/5

All tools follow a consistent snake_case verb_noun pattern (validate_invoice, extract_invoice_data, lookup_sdi_error, check_piva, verify_piva_vies, find_invoice_anomalies, generate_invoice_report). No mixed conventions or vague verbs.

Tool Count5/5

Seven tools is well-scoped for a FatturaPA validation and analysis server, with each tool earning its place covering a distinct stage of the document lifecycle plus supporting VAT/error lookups.

Completeness4/5

Validation, extraction, anomaly detection, aggregation, and VAT/error lookups cover the analytical surface well. Minor gaps remain around document creation/generation or SDI submission, but the apparent purpose (validation and analysis) is fully supported.

Maintenance

ActivityMaintained
ResponsivenessNo issues