Skip to main content
Glama
cmendezs

mcp-fattura-elettronica-it

generate_progressivo_invio

Generates a unique ProgressivoInvio identifier for the DatiTrasmissione block. Use as step 2 in the invoice generation workflow to ensure each transmission has a distinct sequence per Partita IVA.

Instructions

Generate a ProgressivoInvio identifier for the DatiTrasmissione block.

Use this as step 2 in the invoice generation workflow, before build_transmission_header(). The SDI requires each ProgressivoInvio to be unique per transmitter Partita IVA — in production, pass an explicit monotonically increasing sequence number; use the random default only for testing.

prefix (optional): alphabetic 1–3 char prefix, e.g. 'INV' → 'INV00001'. sequence (optional): integer 1–9999999; random 5-digit value if omitted. Total length must not exceed 10 characters.

On success returns {'progressivo_invio': str, 'length': int}. On failure (invalid prefix) returns {'error': ''}.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
prefixNoOptional alphabetic prefix (max 3 chars) to prepend to the sequence number. E.g. 'INV' → 'INV00001'. Total length must not exceed 10 chars.
sequenceNoExplicit sequence number (1–9999999). If omitted, a random 5-digit number is generated. Callers should track their own sequence in production.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The actual handler function for generate_progressivo_invio. Implements the logic: validates prefix (1-3 alphabetic chars), generates a sequence number (explicit or random 5-digit), pads to max 10 chars, and returns the ProgressivoInvio string with its length.
    @mcp.tool()
    def generate_progressivo_invio(
        prefix: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Optional alphabetic prefix (max 3 chars) to prepend to the sequence number. "
                    "E.g. 'INV' → 'INV00001'. Total length must not exceed 10 chars."
                ),
            ),
        ] = None,
        sequence: Annotated[
            Optional[int],
            Field(
                default=None,
                ge=1,
                le=9999999,
                description=(
                    "Explicit sequence number (1–9999999). If omitted, a random 5-digit "
                    "number is generated. Callers should track their own sequence in production."
                ),
            ),
        ] = None,
    ) -> dict:
        """Generate a ProgressivoInvio identifier for the DatiTrasmissione block.
    
        Use this as step 2 in the invoice generation workflow, before
        build_transmission_header(). The SDI requires each ProgressivoInvio to be unique
        per transmitter Partita IVA — in production, pass an explicit monotonically
        increasing sequence number; use the random default only for testing.
    
        prefix (optional): alphabetic 1–3 char prefix, e.g. 'INV' → 'INV00001'.
        sequence (optional): integer 1–9999999; random 5-digit value if omitted.
        Total length must not exceed 10 characters.
    
        On success returns {'progressivo_invio': str, 'length': int}.
        On failure (invalid prefix) returns {'error': '<reason>'}.
        """
        if prefix and not re.match(r"^[A-Za-z]{1,3}$", prefix):
            return {"error": "prefix must be 1–3 alphabetic characters."}
    
        seq_num = sequence if sequence is not None else random.randint(1, 99999)
        prefix_str = prefix.upper() if prefix else ""
    
        # Pad sequence to fill remaining width up to 10 chars
        remaining = 10 - len(prefix_str)
        seq_str = str(seq_num).zfill(min(remaining, 5))
    
        progressivo = (prefix_str + seq_str)[:10]
    
        return {"progressivo_invio": progressivo, "length": len(progressivo)}
  • Input parameter definitions (prefix and sequence) using Pydantic Field with validation constraints: prefix optional 1-3 alpha, sequence optional int 1-9999999.
    def generate_progressivo_invio(
        prefix: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Optional alphabetic prefix (max 3 chars) to prepend to the sequence number. "
                    "E.g. 'INV' → 'INV00001'. Total length must not exceed 10 chars."
                ),
            ),
        ] = None,
        sequence: Annotated[
            Optional[int],
            Field(
                default=None,
                ge=1,
                le=9999999,
                description=(
                    "Explicit sequence number (1–9999999). If omitted, a random 5-digit "
                    "number is generated. Callers should track their own sequence in production."
                ),
            ),
        ] = None,
  • The register_header_tools function that registers all header tools on the FastMCP instance. The @mcp.tool() decorator on line 430 registers generate_progressivo_invio.
    def register_header_tools(mcp: FastMCP) -> None:
        """Register the 7 FatturaElettronicaHeader tools on the FastMCP instance."""
  • server.py:83-85 (registration)
    Call to register_header_tools(mcp) in the main server entry point, which triggers registration of generate_progressivo_invio among other header tools.
    register_header_tools(mcp)
    register_body_tools(mcp)
    register_global_tools(mcp)
  • Imports used by the handler: random for random sequence generation, re for prefix validation.
    import random
    import re
    from typing import Annotated, Optional
    
    from fastmcp import FastMCP
    from pydantic import Field
Behavior4/5

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

No annotations are provided, so the description carries the full burden. It explains the behavior: returns success with progressivo_invio and length on valid input, or error on invalid prefix. It also notes the total length constraint. Though it doesn't explicitly state non-destructiveness, the generation nature implies no side effects.

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 well-structured with clear paragraphs, bullet points for return values, and no unnecessary words. Every sentence serves a purpose, and the content is front-loaded with the primary action.

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?

Given the tool's simplicity, the description covers purpose, parameters, usage context, and return values. The only minor gap is that it does not mention that the tool is safe for testing, but the testing hint in the sequence parameter implies it. With no output schema provided, the description adequately documents the return structure.

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 100%, with each parameter described. The description adds value by explaining the production vs testing use case for the sequence parameter and the default random behavior. This goes beyond the schema's constraints and enhances understanding.

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 it generates a ProgressivoInvio identifier for the DatiTrasmissione block, and distinguishes it from sibling tools by specifying its place in the workflow (step 2 before build_transmission_header). The verb 'generate' and specific resource 'ProgressivoInvio' make the purpose unambiguous.

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?

The description explicitly states when to use it (step 2 in the invoice workflow, before build_transmission_header) and provides context on uniqueness requirements per Partita IVA. It distinguishes between production (explicit sequence) and testing (random default). While it lacks an explicit 'when not to use', the context is sufficient for an agent to determine appropriate usage.

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