Skip to main content
Glama
cmendezs

mcp-fattura-elettronica-it

validate_partita_iva_format

Validate an Italian Partita IVA by verifying it has exactly 11 digits and passes the official checksum. Use this as the first step in invoice generation to prevent errors.

Instructions

Validate an Italian Partita IVA for format (11 digits) and modulo-10 checksum.

Use this as step 1 in the invoice generation workflow before any other tool. Equivalent to validate_partita_iva() in header tools — use this standalone version when you only need the validation result without importing header tools.

Strips whitespace, checks for exactly 11 digits, then applies the official Agenzia delle Entrate control algorithm to verify the check digit.

On success returns {'valid': true, 'value': '<cleaned_piva>'}. On failure returns {'valid': false, 'value': '', 'error': ''}.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
partita_ivaYesItalian Partita IVA (VAT number) to validate. Must be exactly 11 digits. Whitespace is stripped before validation.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The actual handler function that validates an Italian Partita IVA: strips whitespace, checks 11-digit format, computes modulo-10 checksum per Agenzia delle Entrate algorithm.
    @mcp.tool()
    def validate_partita_iva_format(
        partita_iva: Annotated[
            str,
            Field(
                description=(
                    "Italian Partita IVA (VAT number) to validate. "
                    "Must be exactly 11 digits. Whitespace is stripped before validation."
                )
            ),
        ],
    ) -> dict:
        """Validate an Italian Partita IVA for format (11 digits) and modulo-10 checksum.
    
        Use this as step 1 in the invoice generation workflow before any other tool.
        Equivalent to validate_partita_iva() in header tools — use this standalone version
        when you only need the validation result without importing header tools.
    
        Strips whitespace, checks for exactly 11 digits, then applies the official
        Agenzia delle Entrate control algorithm to verify the check digit.
    
        On success returns {'valid': true, 'value': '<cleaned_piva>'}.
        On failure returns {'valid': false, 'value': '<input>', 'error': '<reason>'}.
        """
        piva = partita_iva.strip()
    
        if not re.match(r"^\d{11}$", piva):
            return {
                "valid": False,
                "value": piva,
                "error": "Partita IVA must be exactly 11 digits.",
            }
    
        total = 0
        for i, digit in enumerate(piva[:10]):
            d = int(digit)
            if i % 2 == 1:
                d *= 2
                if d > 9:
                    d -= 9
            total += d
    
        expected = (10 - (total % 10)) % 10
        actual = int(piva[10])
    
        if expected != actual:
            return {
                "valid": False,
                "value": piva,
                "error": f"Checksum mismatch: expected {expected}, got {actual}.",
            }
    
        return {"valid": True, "value": piva}
  • Registration function that wraps the tool with @mcp.tool() decorator, registering it on the FastMCP instance.
    def register_global_tools(mcp: FastMCP) -> None:
        """Register the 7 global FatturaPA tools on the FastMCP instance."""
  • server.py:83-85 (registration)
    Top-level registration call in server.py entry point that triggers tool registration.
    register_header_tools(mcp)
    register_body_tools(mcp)
    register_global_tools(mcp)
  • Pydantic Field annotation defining the input schema for the partita_iva parameter.
        partita_iva: Annotated[
            str,
            Field(
                description=(
                    "Italian Partita IVA (VAT number) to validate. "
                    "Must be exactly 11 digits. Whitespace is stripped before validation."
                )
            ),
        ],
    ) -> dict:
Behavior5/5

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

With no annotations provided, the description fully discloses behavior: it strips whitespace, checks for exactly 11 digits, applies the official control algorithm, and specifies both success and failure return formats. This is comprehensive for a validation tool.

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?

The description is concise and well-structured: it starts with a clear purpose, then usage context, then behavioral steps, and finally return format. Every sentence adds value without redundancy.

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?

Given the tool has a simple input schema and an output schema (as per context signals), the description covers all needed aspects: validation logic, return values, and usage context. It is fully complete for an agent to invoke correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description reiterates the parameter constraints and adds cleaning steps (stripping whitespace), but does not provide additional semantic meaning beyond what the schema already conveys.

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 description clearly states the tool validates an Italian Partita IVA for format and checksum. It distinguishes itself from the sibling tool 'validate_partita_iva' by specifying it's a standalone version, thus clarifying the resource and avoiding ambiguity.

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

Usage Guidelines5/5

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

The description explicitly says 'Use this as step 1 in the invoice generation workflow before any other tool' and provides an alternative (the header tool version), giving clear guidance on when to use this tool versus alternatives.

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-fattura-elettronica-it'

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