Skip to main content
Glama
MaurizioLisanti

fatturapa-mcp-server

validate_invoice

Validate FatturaPA XML documents against the correct XSD schema, auto-detecting v1.2 or v1.3 and returning validity, version, and errors from content or an allowed file path.

Instructions

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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathNo
xml_contentNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
validYes
errorsYes
versionYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.2

TDQS

A4.4/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and does so thoroughly: it discloses auto-detection of the schema version, that no XML content is logged, that file_path is validated against FATTURAPA_ALLOWED_ROOTS before reading, and the exact exceptions (PermissionError, ValueError) and their triggers.

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

Conciseness4/5

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

The docstring format is front-loaded with purpose, then behavioral notes, then Args/Returns/Raises. It is slightly verbose and the Returns block partially duplicates the output schema, but every paragraph adds information an agent needs.

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

Completeness5/5

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

For a two-parameter validation tool with an output schema present, the description covers the full picture: version detection, error semantics, permission constraints, privacy behavior, and input-source selection. Nothing needed to invoke it correctly is missing.

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 description coverage is 0%, so the prose must compensate, and it largely does: xml_content is described as a raw XML string and file_path as an optional path subject to allowed-root checking. It also documents the mutual-exclusion rule (ValueError when neither is given) that the schema's empty defaults do not convey.

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 first sentence gives a precise verb+resource+target: 'Validate a FatturaPA XML document against the appropriate XSD schema.' This clearly separates it from siblings like extract_invoice_data or find_invoice_anomalies, which transform or analyze rather than schema-validate.

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

Usage Guidelines3/5

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

It clearly explains the two invocation modes (file_path reads from disk, xml_content skips I/O), but gives no explicit guidance about when to choose this tool over sibling tools such as extract_invoice_data or find_invoice_anomalies. Usage is implied rather than routed.

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