Skip to main content
Glama
cmendezs

mcp-facture-electronique-fr

validate_ereporting_xml

Validate a DGFiP e-reporting FRR XML payload against the official schema and identify structural errors before submission.

Instructions

Validate a DGFiP e-reporting (Flux 10) FRR XML payload.

Checks the XML against the DGFiP Spécifications Externes v3.2 ereporting.xsd. Returns validation result with errors if any. Use this before submitting to catch structural problems early.

Validation levels (in order of preference):

  • xsd — full schema validation (requires lxml)

  • wellformedness — basic XML parsing only (stdlib fallback)

  • none — XSD files not found on disk

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xml_contentYesFRR XML content to validate. Must be a complete Report document per DGFiP Spécifications Externes v3.2 ereporting.xsd. Full XSD validation requires lxml (`pip install lxml`); otherwise well-formedness is checked.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main async handler for the 'validate_ereporting_xml' MCP tool. Accepts 'xml_content' parameter and delegates to _validate_against_xsd().
    async def validate_ereporting_xml(
        xml_content: Annotated[
            str,
            Field(
                description=(
                    "FRR XML content to validate. Must be a complete Report document "
                    "per DGFiP Spécifications Externes v3.2 ereporting.xsd. "
                    "Full XSD validation requires lxml (`pip install lxml`); "
                    "otherwise well-formedness is checked."
                )
            ),
        ],
    ) -> dict[str, Any]:
        """Validate a DGFiP e-reporting (Flux 10) FRR XML payload.
    
        Checks the XML against the DGFiP Spécifications Externes v3.2 ereporting.xsd.
        Returns validation result with errors if any. Use this before submitting to
        catch structural problems early.
    
        Validation levels (in order of preference):
          - xsd           — full schema validation (requires lxml)
          - wellformedness — basic XML parsing only (stdlib fallback)
          - none          — XSD files not found on disk
        """
        return _validate_against_xsd(xml_content)
  • Core validation helper that checks XML against DGFiP ereporting.xsd. Falls back to well-formedness check if lxml is not installed, or 'none' if XSD files not found on disk.
    def _validate_against_xsd(xml_content: str) -> dict[str, Any]:
        """Validate XML against DGFiP ereporting.xsd.
    
        Falls back to well-formedness check if lxml is not installed.
        """
        xsd_path = _XSD_DIR / "ereporting.xsd"
        if not xsd_path.exists():
            return {
                "valid": None,
                "level": "none",
                "message": (
                    f"XSD files not found at {_XSD_DIR}. "
                    "Install the package from source to enable XSD validation."
                ),
            }
    
        # Try well-formedness first (always available)
        import xml.etree.ElementTree as ET  # noqa: PLC0415
    
        try:
            ET.fromstring(xml_content.encode("utf-8"))
        except ET.ParseError as exc:
            return {"valid": False, "level": "wellformedness", "errors": [str(exc)]}
    
        # Try lxml XSD validation
        try:
            from lxml import etree  # type: ignore[import-not-found]  # noqa: PLC0415
    
            xml_doc = etree.fromstring(xml_content.encode("utf-8"))
            xsd_doc = etree.parse(str(xsd_path))
            schema = etree.XMLSchema(xsd_doc)
            is_valid = schema.validate(xml_doc)
            errors = [str(e) for e in schema.error_log]
            return {
                "valid": is_valid,
                "level": "xsd",
                "errors": errors if not is_valid else [],
            }
        except ImportError:
            return {
                "valid": True,
                "level": "wellformedness",
                "message": (
                    "Well-formed XML. Full XSD validation requires lxml "
                    "(`pip install lxml`). Install it for strict DGFiP schema checks."
                ),
            }
        except Exception as exc:  # noqa: BLE001
            return {
                "valid": None,
                "level": "error",
                "message": f"Validation error: {exc}",
            }
  • Registration function that decorates the function with @mcp.tool() to register it with the FastMCP server.
    def register_ereporting_tools(mcp: FastMCP) -> None:
        """Register all e-reporting tools with the MCP server."""
    
        @mcp.tool()
        async def validate_ereporting_xml(
            xml_content: Annotated[
                str,
                Field(
                    description=(
                        "FRR XML content to validate. Must be a complete Report document "
                        "per DGFiP Spécifications Externes v3.2 ereporting.xsd. "
                        "Full XSD validation requires lxml (`pip install lxml`); "
                        "otherwise well-formedness is checked."
                    )
                ),
            ],
        ) -> dict[str, Any]:
            """Validate a DGFiP e-reporting (Flux 10) FRR XML payload.
    
            Checks the XML against the DGFiP Spécifications Externes v3.2 ereporting.xsd.
            Returns validation result with errors if any. Use this before submitting to
            catch structural problems early.
    
            Validation levels (in order of preference):
              - xsd           — full schema validation (requires lxml)
              - wellformedness — basic XML parsing only (stdlib fallback)
              - none          — XSD files not found on disk
            """
            return _validate_against_xsd(xml_content)
  • Parameter schema for xml_content using Annotated type with Pydantic Field description, defining the input structure for this tool.
    xml_content: Annotated[
        str,
        Field(
            description=(
                "FRR XML content to validate. Must be a complete Report document "
                "per DGFiP Spécifications Externes v3.2 ereporting.xsd. "
                "Full XSD validation requires lxml (`pip install lxml`); "
                "otherwise well-formedness is checked."
            )
        ),
    ],
Behavior4/5

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

No annotations provided; description details validation logic, fallback behavior (lxml/stdlib), and return of errors. Does not explicitly state it's read-only, but mutation is unlikely for validation.

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?

Concise sentences with clear hierarchy (purpose, then validation levels). Front-loaded with key action and audience; no filler.

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?

Covers purpose, dependencies, return type ('validation result with errors'), and fallback behavior. Lacks detailed output schema description but is sufficient for a validation tool.

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?

Input schema already provides 100% coverage; description adds context ('complete Report document', 'per DGFiP Spécifications Externes v3.2'), reinforcing expected format and standard.

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?

Explicitly states validation of DGFiP e-reporting FRR XML, matching the tool name. Differentiates from sibling 'submit_flow' by indicating pre-submission use.

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

Usage Guidelines4/5

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

Advises using 'before submitting' and lists validation levels (xsd, wellformedness, none) with dependency info. Lacks explicit exclusions compared to siblings but provides clear context.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cmendezs/mcp-facture-electronique-fr'

If you have feedback or need assistance with the MCP directory API, please join our Discord server