Skip to main content
Glama
cmendezs

mcp-facturacion-electronica-es

es__submit_verifactu_to_aeat

Submit signed VERI*FACTU XML invoices to the AEAT real-time endpoint using MTLS authentication with FNMT-RCM certificate. Requires sender NIF and signed XML.

Instructions

Envía un registro VERI*FACTU firmado al endpoint en tiempo real de la AEAT mediante MTLS (certificado FNMT-RCM). Requiere AEAT_ENV, AEAT_CERTIFICATE_PATH y AEAT_CERTIFICATE_PASSWORD.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xmlYesRegistro VERI*FACTU XML firmado.
nifYesNIF del remitente.

Implementation Reference

  • Handler function `handle_es_submit_verifactu_to_aeat` — sends a signed VERI*FACTU XML to the AEAT endpoint via MTLS (FNMT-RCM certificate). Validates required params (xml, nif), reads AEAT_CERTIFICATE_PATH/PASSWORD from env, picks endpoint based on AEAT_ENV, uses BaseEInvoicingClient with AuthMode.MTLS, POSTs the XML as a multipart file upload, returns status_code, env, and response_text.
    async def handle_es_submit_verifactu_to_aeat(
        arguments: dict[str, Any],
    ) -> list[types.TextContent]:
        try:
            from mcp_einvoicing_core.http_client import AuthMode, BaseEInvoicingClient
    
            xml_str = arguments.get("xml", "")
            nif = arguments.get("nif", "")
            if not xml_str:
                return err("xml is required", "MISSING_PARAM")
            if not nif:
                return err("nif is required", "MISSING_PARAM")
    
            cert_path = os.environ.get("AEAT_CERTIFICATE_PATH")
            cert_password = os.environ.get("AEAT_CERTIFICATE_PASSWORD")
            if not cert_path:
                return err(
                    "AEAT_CERTIFICATE_PATH no está configurado. "
                    "Proporcione la ruta al certificado FNMT-RCM PKCS#12.",
                    "MISSING_CONFIG",
                )
    
            env = aeat_env()
            base_url = VERIFACTU_ENDPOINTS[env]
    
            client = BaseEInvoicingClient(
                base_url=base_url,
                auth_mode=AuthMode.MTLS,
                cert_path=cert_path,
                cert_password=cert_password,
            )
    
            xml_bytes = xml_str.encode() if isinstance(xml_str, str) else xml_str
            response = await client._request(
                "POST",
                "",
                data=None,
                json=None,
                files={"xml": ("registro.xml", xml_bytes, "application/xml")},
            )
    
            # [NEED: parse AEAT VERI*FACTU response — use es__parse_aeat_response]
            return ok({
                "status_code": response.status_code,
                "environment": env,
                "response_text": response.text[:2000],
                "note": (
                    "Use es__parse_aeat_response to parse the response XML "
                    "and extract EstadoEnvio and CSV."
                ),
            })
    
        except Exception as exc:
            logger.exception("es__submit_verifactu_to_aeat failed")
            return err(str(exc))
  • Tool definition `TOOL_ES_SUBMIT_VERIFACTU_TO_AEAT` — declares the tool name 'es__submit_verifactu_to_aeat', description about MTLS submission to AEAT, and inputSchema requiring 'xml' (signed XML string) and 'nif' (sender NIF).
    TOOL_ES_SUBMIT_VERIFACTU_TO_AEAT = types.Tool(
        name="es__submit_verifactu_to_aeat",
        description=(
            "Envía un registro VERI*FACTU firmado al endpoint en tiempo real de la AEAT mediante MTLS "
            "(certificado FNMT-RCM). Requiere AEAT_ENV, AEAT_CERTIFICATE_PATH y AEAT_CERTIFICATE_PASSWORD."
        ),
        inputSchema={
            "type": "object",
            "properties": {
                "xml": {"type": "string", "description": "Registro VERI*FACTU XML firmado."},
                "nif": {"type": "string", "description": "NIF del remitente."},
            },
            "required": ["xml", "nif"],
        },
    )
  • Tool list `_ALL_TOOLS` includes TOOL_ES_SUBMIT_VERIFACTU_TO_AEAT on line 81, registering it as an available MCP tool.
    _ALL_TOOLS: list[types.Tool] = [
        # VERI*FACTU
        TOOL_ES_GENERATE_VERIFACTU_RECORD,
        TOOL_ES_VALIDATE_VERIFACTU_RECORD,
        TOOL_ES_SUBMIT_VERIFACTU_TO_AEAT,
        TOOL_ES_GENERATE_QR_VERIFACTU,
        TOOL_ES_CANCEL_VERIFACTU_RECORD,
        # Facturae / FACe
        TOOL_ES_GENERATE_FACTURAE_XML,
        TOOL_ES_SIGN_FACTURAE_XADES,
        TOOL_ES_SUBMIT_TO_FACE,
        TOOL_ES_GET_FACE_INVOICE_STATUS,
        TOOL_ES_VALIDATE_FACTURAE_SCHEMA,
        # SII
        TOOL_ES_BUILD_SII_INVOICE_RECORD,
        TOOL_ES_SUBMIT_SII_BATCH,
        TOOL_ES_QUERY_SII_STATUS,
        TOOL_ES_GENERATE_SII_CORRECTION,
        # TicketBAI
        TOOL_ES_GENERATE_TICKETBAI_XML,
        TOOL_ES_SUBMIT_TICKETBAI,
        TOOL_ES_VALIDATE_TICKETBAI_SCHEMA,
        # Crea y Crece / B2B
        TOOL_ES_GENERATE_B2B_EINVOICE_ES,
        TOOL_ES_CHECK_B2B_MANDATE_APPLICABILITY,
        # Utilities
        TOOL_ES_DETECT_REGIONAL_REGIME,
        TOOL_ES_GET_COMPLIANCE_STATUS,
        TOOL_ES_PARSE_AEAT_RESPONSE,
    ]
  • Handler map `_TOOL_HANDLERS` maps the string 'es__submit_verifactu_to_aeat' to the function handle_es_submit_verifactu_to_aeat on line 112.
    _TOOL_HANDLERS: dict[str, Any] = {
        # VERI*FACTU
        "es__generate_verifactu_record":      handle_es_generate_verifactu_record,
        "es__validate_verifactu_record":      handle_es_validate_verifactu_record,
        "es__submit_verifactu_to_aeat":       handle_es_submit_verifactu_to_aeat,
        "es__generate_qr_verifactu":          handle_es_generate_qr_verifactu,
        "es__cancel_verifactu_record":        handle_es_cancel_verifactu_record,
        # Facturae / FACe
        "es__generate_facturae_xml":          handle_es_generate_facturae_xml,
        "es__sign_facturae_xades":            handle_es_sign_facturae_xades,
        "es__submit_to_face":                 handle_es_submit_to_face,
        "es__get_face_invoice_status":        handle_es_get_face_invoice_status,
        "es__validate_facturae_schema":       handle_es_validate_facturae_schema,
        # SII
        "es__build_sii_invoice_record":       handle_es_build_sii_invoice_record,
        "es__submit_sii_batch":               handle_es_submit_sii_batch,
        "es__query_sii_status":               handle_es_query_sii_status,
        "es__generate_sii_correction":        handle_es_generate_sii_correction,
        # TicketBAI
        "es__generate_ticketbai_xml":         handle_es_generate_ticketbai_xml,
        "es__submit_ticketbai":               handle_es_submit_ticketbai,
        "es__validate_ticketbai_schema":      handle_es_validate_ticketbai_schema,
        # Crea y Crece / B2B
        "es__generate_b2b_einvoice_es":       handle_es_generate_b2b_einvoice_es,
        "es__check_b2b_mandate_applicability": handle_es_check_b2b_mandate_applicability,
        # Utilities
        "es__detect_regional_regime":         handle_es_detect_regional_regime,
        "es__get_compliance_status":          handle_es_get_compliance_status,
        "es__parse_aeat_response":            handle_es_parse_aeat_response,
    }
  • VERIFACTU_ENDPOINTS dictionary mapping sandbox/production environments to AEAT VERI*FACTU submission URLs. Used by the handler to determine the target endpoint.
    VERIFACTU_ENDPOINTS: dict[str, str] = {
        "sandbox": (
            "https://prewww2.aeat.es/wlpl/TIKE-CONT/ws/SistemaFacturacion/FactSistemaFacturacion"
        ),
        "production": (
            "https://www2.agenciatributaria.gob.es"
            "/wlpl/TIKE-CONT/ws/SistemaFacturacion/FactSistemaFacturacion"
        ),
        # [NEED: verify production URL against published AEAT technical guide]
Behavior3/5

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

No annotations are provided, so the description must disclose behavioral traits. It mentions MTLS authentication and certificate requirements, but omits details on response handling, error conditions, rate limits, or side effects. For a submission tool, more information is needed.

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 two sentences with no wasted words. The first sentence states the purpose and method, the second lists prerequisites. It is front-loaded and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's critical nature (submission to tax authority), the description lacks details on return values or errors, despite having no output schema. However, with only 2 parameters and no nested objects, it covers the essential context partially.

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 the schema already documents both parameters. The description adds minimal value beyond repeating that the XML is signed and NIF is the sender. Baseline 3 is appropriate.

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 action (sending/submitting a signed VERI*FACTU record) and the resource (AEAT real-time endpoint via MTLS). It distinguishes from siblings like es__cancel_verifactu_record and es__submit_ticketbai, which handle different operations.

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

Usage Guidelines3/5

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

The description lists required environment variables but provides no guidance on when to use this tool versus alternatives (e.g., es__submit_sii_batch). It does not specify exclusions or context for appropriate use.

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-facturacion-electronica-es'

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