Skip to main content
Glama
mx-fiscal-mcp-server

mx-fiscal-mcp-server

by OrtaMarco

CFDI Status at the SAT

cfdi_status
Read-onlyIdempotent

Ask the SAT whether an invoice actually exists and is still live. This queries the public ConsultaCFDIService SOAP endpoint — the same service the QR code printed on every Mexican invoice points at — so it needs **no credentials, no CSD…

Instructions

Ask the SAT whether an invoice actually exists and is still live. This queries the public ConsultaCFDIService SOAP endpoint — the same service the QR code printed on every Mexican invoice points at — so it needs no credentials, no CSD and no PAC contract.

Pass either the four values the SAT keys on (issuer RFC, receiver RFC, total, UUID) or the whole xml, in which case they are derived from it with the same reader parse_cfdi uses. Deriving them from the XML is the more reliable route: the total must be formatted exactly the way the printed-representation spec demands (six decimals, trailing zeros trimmed), and a total written in another format can come back as a spurious 'No Encontrado'.

What comes back, each with its meaning spelled out:

  • Estado — Vigente / Cancelado / No Encontrado.

  • EsCancelable — whether the issuer can cancel it unilaterally, needs the receiver's approval, or cannot cancel it at all.

  • EstatusCancelacion — whether a cancellation is in progress, was accepted, was rejected, or lapsed.

  • ValidacionEFOS — whether the issuer, and any third-party RFC the invoice was issued on behalf of (a cuenta de terceros), appears on the SAT's definitive 69-B list of companies that invoice simulated operations. Read with the code table the SAT documents (service documentation v1.4, section 3): 100, 101 and 104 put the issuer on the list; 102 and 103 mean the issuer is NOT on it but a third-party RFC is; 200 and 201 mean the issuer is not on it (201: nor any third party). efos_state speaks of the issuer only and efos_third_party_state of the third parties; an empty field or an undocumented code is unknown, with the raw code kept in validacion_efos.

  • CodigoEstatus — the service's own result code.

Fail-soft by design. The SAT publishes no SLA and no status page, and the endpoint does go down; its documentation states capacity for up to 2 million queries per hour and asks callers not to raise their query volume, so query once per invoice and cache the answer. On timeout, refusal or a malformed answer this returns available: false with the reason instead of raising — a failed lookup is a statement about the SAT, never about the invoice. Never report a document as invalid on the strength of an unreachable service. 10-second timeout; one retry after a timeout, network error or 5xx, never after a 4xx.

Args (either shape):

  • xml (string), OR rfc_emisor + rfc_receptor + total + uuid (all strings).

  • response_format ('markdown' | 'json'): output format (default 'markdown').

Returns: { available, unavailable_reason, endpoint, expression, attempts, elapsed_ms, source, status{codigo_estatus, query_outcome, estado, document_state, document_meaning, es_cancelable, cancellable_state, cancellable_meaning, estatus_cancelacion, cancellation_state, cancellation_meaning, validacion_efos, efos_state, efos_third_party_state, efos_meaning, raw} | null, findings[] }.

Example: "Is this invoice still valid?" -> cfdi_status(xml="<cfdi:Comprobante …>").

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "cfdi_status"
  }
}

Input Schema

NameRequiredDescriptionDefault
xmlNoThe complete CFDI XML. When given, the four query fields are derived from it and any values passed alongside are ignored.
uuidNoThe fiscal folio (UUID) from the Timbre Fiscal Digital. Required unless `xml` is given.
totalNoInvoice total exactly as written in the XML, e.g. '1160.00'. Required unless `xml` is given.
rfc_emisorNoIssuer's RFC. Required unless `xml` is given.
rfc_receptorNoReceiver's RFC. Required unless `xml` is given.
response_formatNoOutput format: 'markdown' for a human-readable summary (default) or 'json' for the full structured payload.markdown

Output Schema

NameRequiredDescriptionDefault
sourceYes
statusYes
attemptsYes
endpointYes
findingsYes
availableYes
elapsed_msYes
expressionYes
unavailable_reasonYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.1.1
    • changedOutput schema / required
      Previous value: -[
      -  "available",
      -  "unavailable_reason",
      -  "endpoint",
      -  "expression",
      -  "attempts",
      -  "elapsed_ms",
      -  "source",
      -  "status",
      -  "findings"
      -]New value: +[
      +  "available",
      +  "unavailable_reason",
      +  "endpoint",
      +  "expression",
      +  "attempts",
      +  "elapsed_ms",
      +  "status",
      +  "findings",
      +  "source"
      +]
  2. Changed1 schema field changedv1.0.2
    • changedOutput schema / properties / status / anyOf
      Previous value: -[
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "cancellable_meaning": {
      -        "type": "string"
      -      },
      -      "cancellable_state": {
      -        "enum": [
      -          "sin_aceptacion",
      -          "con_aceptacion",
      -          "no_cancelable",
      -          "unknown"
      -        ],
      -        "type": "string"
      -      },
      -      "cancellation_meaning": {
      -        "type": "string"
      -      },
      -      "cancellation_state": {
      -        "enum": [
      -          "cancelado_sin_aceptacion",
      -          "cancelado_con_aceptacion",
      -          "plazo_vencido",
      -          "en_proceso",
      -          "solicitud_rechazada",
      -          "ninguno"
      -        ],
      -        "type": "string"
      -      },
      -      "codigo_estatus": {
      -        "type": "string"
      -      },
      -      "document_meaning": {
      -        "type": "string"
      -      },
      -      "document_state": {
      -        "enum": [
      -          "vigente",
      -          "cancelado",
      -          "no_encontrado"
      -        ],
      -        "type": "string"
      -      },
      -      "efos_meaning": {
      -        "type": "string"
      -      },
      -      "efos_state": {
      -        "enum": [
      -          "not_listed",
      -          "listed",
      -          "unknown"
      -        ],
      -        "type": "string"
      -      },
      -      "es_cancelable": {
      -        "type": "string"
      -      },
      -      "estado": {
      -        "type": "string"
      -      },
      -      "estatus_cancelacion": {
      -        "type": "string"
      -      },
      -      "query_outcome": {
      -        "enum": [
      -          "found",
      -          "not_found"
      -        ],
      -        "type": "string"
      -      },
      -      "raw": {
      -        "additionalProperties": {
      -          "type": "string"
      -        },
      -        "propertyNames": {
      -          "type": "string"
      -        },
      -        "type": "object"
      -      },
      -      "validacion_efos": {
      -        "type": "string"
      -      }
      -    },
      -    "required": [
      -      "codigo_estatus",
      -      "query_outcome",
      -      "estado",
      -      "document_state",
      -      "document_meaning",
      -      "es_cancelable",
      -      "cancellable_state",
      -      "cancellable_meaning",
      -      "estatus_cancelacion",
      -      "cancellation_state",
      -      "cancellation_meaning",
      -      "validacion_efos",
      -      "efos_state",
      -      "efos_meaning",
      -      "raw"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "cancellable_meaning": {
      +        "type": "string"
      +      },
      +      "cancellable_state": {
      +        "enum": [
      +          "sin_aceptacion",
      +          "con_aceptacion",
      +          "no_cancelable",
      +          "unknown"
      +        ],
      +        "type": "string"
      +      },
      +      "cancellation_meaning": {
      +        "type": "string"
      +      },
      +      "cancellation_state": {
      +        "enum": [
      +          "cancelado_sin_aceptacion",
      +          "cancelado_con_aceptacion",
      +          "plazo_vencido",
      +          "en_proceso",
      +          "solicitud_rechazada",
      +          "ninguno"
      +        ],
      +        "type": "string"
      +      },
      +      "codigo_estatus": {
      +        "type": "string"
      +      },
      +      "document_meaning": {
      +        "type": "string"
      +      },
      +      "document_state": {
      +        "enum": [
      +          "vigente",
      +          "cancelado",
      +          "no_encontrado"
      +        ],
      +        "type": "string"
      +      },
      +      "efos_meaning": {
      +        "type": "string"
      +      },
      +      "efos_state": {
      +        "enum": [
      +          "not_listed",
      +          "listed",
      +          "unknown"
      +        ],
      +        "type": "string"
      +      },
      +      "efos_third_party_state": {
      +        "enum": [
      +          "listed",
      +          "not_listed",
      +          "not_reported",
      +          "unknown"
      +        ],
      +        "type": "string"
      +      },
      +      "es_cancelable": {
      +        "type": "string"
      +      },
      +      "estado": {
      +        "type": "string"
      +      },
      +      "estatus_cancelacion": {
      +        "type": "string"
      +      },
      +      "query_outcome": {
      +        "enum": [
      +          "found",
      +          "not_found"
      +        ],
      +        "type": "string"
      +      },
      +      "raw": {
      +        "additionalProperties": {
      +          "type": "string"
      +        },
      +        "propertyNames": {
      +          "type": "string"
      +        },
      +        "type": "object"
      +      },
      +      "validacion_efos": {
      +        "type": "string"
      +      }
      +    },
      +    "required": [
      +      "codigo_estatus",
      +      "query_outcome",
      +      "estado",
      +      "document_state",
      +      "document_meaning",
      +      "es_cancelable",
      +      "cancellable_state",
      +      "cancellable_meaning",
      +      "estatus_cancelacion",
      +      "cancellation_state",
      +      "cancellation_meaning",
      +      "validacion_efos",
      +      "efos_state",
      +      "efos_third_party_state",
      +      "efos_meaning",
      +      "raw"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
  3. First observedv1.0.0

TDQS

A4.6/5.0
Behavior5/5

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

Annotations cover the safety profile (readOnly, idempotent, non-destructive, openWorld), and the description still adds a lot: no credentials/CSD/PAC needed, 10-second timeout, one retry only on timeout/network/5xx and never on 4xx, and fail-soft semantics returning `available: false` with a reason instead of raising. It also discloses the SAT's 2M/hour capacity note and the request to cache, which is exactly the rate-limit context annotations cannot express.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with purpose and credentials posture, then structurally segmented (input shapes, return meanings, failure behavior). It is long, and the per-field return glossary plus the 'Returns:' signature partially duplicate the existing output schema, so some of that prose does not fully earn its place.

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 an open-world network call with partial-failure semantics, the description covers everything an agent needs: both argument shapes, format pitfalls, the EFOS 69-B code table interpretation, the fail-soft contract, retry/timeout policy, and caching guidance. An agent can decide and invoke correctly without opening anything else.

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 coverage is 100%, so the baseline is 3, but the description adds real value beyond it: it frames the parameters as two alternative shapes ('either the four values the SAT keys on … or the whole `xml`'), states that values passed alongside `xml` are ignored, and warns that `total` must follow the printed-representation format or the lookup can fail spuriously.

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?

States a specific verb and resource: 'Ask the SAT whether an invoice actually exists and is still live', and pins the exact backend (ConsultaCFDIService SOAP endpoint the invoice QR code points at). It also names its relationship to parse_cfdi (same reader used to derive the four query values), so an agent can place it in the sibling set immediately.

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?

Gives explicit invocation guidance: two mutually exclusive input shapes, and a stated preference (derive from `xml` because a mis-formatted `total` yields a spurious 'No Encontrado'). Also sets operational guidance — query once per invoice and cache, never conclude an invoice is invalid from an unreachable service. The only gap is that it never routes to the sibling cfdi_batch_status for multi-invoice work.

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