Skip to main content
Glama
cmendezs

mcp-fattura-elettronica-it

add_allegato

Attach supporting documents like PDFs or contracts to an electronic invoice. Encodes the file in base64, validates input, and returns a formatted attachment entry for inclusion in the FatturaPA XML.

Instructions

Build an Allegati (attachment) entry to include in a FatturaPA document.

Use this when you need to attach supporting documents (e.g. DDT, contract, PDF) to the invoice. Call once per file, collect results in a list, and pass it to generate_fattura_xml() as the allegati parameter.

attachment_base64 must be valid standard base64 (RFC 4648); the tool verifies decodability. nome_allegato must include the file extension (e.g. 'contract.pdf'). formato_allegato (e.g. 'PDF', 'XML', 'ZIP') is optional but recommended for recipients to identify the content without decoding.

On success returns {'Allegati': {'NomeAllegato', 'Attachment', 'size_bytes', ...}}. On failure returns {'error': ''} (invalid base64 or name > 60 chars).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nome_allegatoYesAttachment file name (NomeAllegato), max 60 chars. Include the extension (e.g. 'contract.pdf', 'ddt_001.pdf').
attachment_base64YesBase64-encoded content of the attachment. Any binary file is accepted; common formats: PDF, XML, JPG, ZIP.
formato_allegatoNoMIME type or format description (FormatoAllegato), max 10 chars. Examples: 'PDF', 'XML', 'ZIP'. Optional but recommended.
descrizione_allegatoNoShort description of the attachment content, max 100 chars. Optional.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The add_allegato tool handler: accepts nome_allegato, attachment_base64, optional formato_allegato and descrizione_allegato; validates base64 decodability and name length <=60; returns {'Allegati': {...}} on success or {'error': '...'} on failure.
    @mcp.tool()
    def add_allegato(
        nome_allegato: Annotated[
            str,
            Field(
                description=(
                    "Attachment file name (NomeAllegato), max 60 chars. "
                    "Include the extension (e.g. 'contract.pdf', 'ddt_001.pdf')."
                )
            ),
        ],
        attachment_base64: Annotated[
            str,
            Field(
                description=(
                    "Base64-encoded content of the attachment. "
                    "Any binary file is accepted; common formats: PDF, XML, JPG, ZIP."
                )
            ),
        ],
        formato_allegato: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "MIME type or format description (FormatoAllegato), max 10 chars. "
                    "Examples: 'PDF', 'XML', 'ZIP'. Optional but recommended."
                ),
            ),
        ] = None,
        descrizione_allegato: Annotated[
            Optional[str],
            Field(
                default=None,
                description="Short description of the attachment content, max 100 chars. Optional.",
            ),
        ] = None,
    ) -> dict:
        """Build an Allegati (attachment) entry to include in a FatturaPA document.
    
        Use this when you need to attach supporting documents (e.g. DDT, contract, PDF)
        to the invoice. Call once per file, collect results in a list, and pass it to
        generate_fattura_xml() as the allegati parameter.
    
        attachment_base64 must be valid standard base64 (RFC 4648); the tool verifies
        decodability. nome_allegato must include the file extension (e.g. 'contract.pdf').
        formato_allegato (e.g. 'PDF', 'XML', 'ZIP') is optional but recommended for
        recipients to identify the content without decoding.
    
        On success returns {'Allegati': {'NomeAllegato', 'Attachment', 'size_bytes', ...}}.
        On failure returns {'error': '<reason>'} (invalid base64 or name > 60 chars).
        """
        try:
            decoded = base64.b64decode(attachment_base64)
        except Exception as exc:
            return {"error": f"Invalid base64 content: {exc}"}
    
        if len(nome_allegato) > 60:
            return {"error": "nome_allegato must not exceed 60 characters."}
    
        allegato: dict = {
            "NomeAllegato": nome_allegato,
            "Attachment": attachment_base64,
            "size_bytes": len(decoded),
        }
    
        if formato_allegato:
            allegato["FormatoAllegato"] = formato_allegato[:10]
        if descrizione_allegato:
            allegato["DescrizioneAllegato"] = descrizione_allegato[:100]
    
        return {"Allegati": allegato}
  • Input schema for add_allegato — four parameters: nome_allegato (str, max 60), attachment_base64 (str, base64 encoded), formato_allegato (Optional[str], max 10), descrizione_allegato (Optional[str], max 100).
    def add_allegato(
        nome_allegato: Annotated[
            str,
            Field(
                description=(
                    "Attachment file name (NomeAllegato), max 60 chars. "
                    "Include the extension (e.g. 'contract.pdf', 'ddt_001.pdf')."
                )
            ),
        ],
        attachment_base64: Annotated[
            str,
            Field(
                description=(
                    "Base64-encoded content of the attachment. "
                    "Any binary file is accepted; common formats: PDF, XML, JPG, ZIP."
                )
            ),
        ],
        formato_allegato: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "MIME type or format description (FormatoAllegato), max 10 chars. "
                    "Examples: 'PDF', 'XML', 'ZIP'. Optional but recommended."
                ),
            ),
        ] = None,
        descrizione_allegato: Annotated[
            Optional[str],
            Field(
                default=None,
                description="Short description of the attachment content, max 100 chars. Optional.",
            ),
        ] = None,
  • server.py:83-84 (registration)
    add_allegato is registered via register_body_tools(mcp) at server startup (line 84), which calls @mcp.tool() decorator on the add_allegato function inside tools/body_tools.py.
    register_header_tools(mcp)
    register_body_tools(mcp)
  • The register_body_tools function that registers add_allegato (and 6 other body tools) via @mcp.tool() decorators.
    def register_body_tools(mcp: FastMCP) -> None:
        """Register the 7 FatturaElettronicaBody tools on the FastMCP instance."""
Behavior4/5

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

With no annotations, the description provides full behavioral info: base64 validity check, filename extension requirement, optional format, and return format (success/error). Minor gap: no mention of potential side effects, but tool is a pure constructor.

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?

Six sentences, front-loaded with purpose and usage. Every sentence adds value; no redundant information.

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 output schema exists, the description effectively covers what the tool does, how to use it, and expected outputs. All necessary context for an AI agent to invoke correctly.

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

Parameters5/5

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

Schema covers all parameters. Description adds critical semantics: base64 must be RFC 4648, nome_allegato must include extension, formato_allegato optional but recommended. No contradictions.

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 builds an Allegati entry for a FatturaPA document, specifying the verb 'Build' and the resource 'Allegati entry'. It distinguishes itself from sibling tools that handle other invoice components.

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?

Explicitly states when to use ('when you need to attach supporting documents'), how to call (once per file, collect in list), and links to sibling tool 'generate_fattura_xml' as the consumer of the output.

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