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
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | No | ||
| xml_content | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| valid | Yes | ||
| errors | Yes | ||
| version | Yes |