Skip to main content
Glama

Mx Build Cfdi

mx__build_cfdi

Generate a valid, unsealed CFDI 4.0 XML Comprobante for Ingreso or Egreso invoices. Validates RFC fields and outputs the computed total for subsequent sealing.

Instructions

Build a well-formed, unsealed CFDI 4.0 Comprobante XML (Ingreso or Egreso).

comprobante_data is validated against CFDIComprobante — see that model for the full field list (seller/buyer as MXEmisor/ MXReceptor, lines as CFDIConcepto, tipo_de_comprobante, etc.). RFC fields are validated via TaxIdentifier.validate_mx_rfc as part of model construction; a malformed RFC is reported as a validation error, not a generated document.

The output XML omits Sello/NoCertificado/Certificado — those three schema-required attributes are populated by mx__seal_cfdi, run afterward. mx__validate_cfdi run on this output is expected to report exactly those three attributes missing; that is not a bug in this tool.

For TipoDeComprobante="P" (Complemento de Pagos), use mx__build_pago instead — this tool only builds Ingreso/Egreso Comprobantes.

Returns a dict with:

  • xml: the generated, unsealed CFDI 4.0 XML string

  • total: the computed Total attribute (SubTotal - Descuento + traslados - retenciones)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
comprobante_dataYesFields matching the CFDIComprobante schema (Ingreso or Egreso only)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv0.3.0

TDQS

A5/5.0
Behavior5/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It honestly states that the output is unsealed, omits Sello/NoCertificado/Certificado, and that validation on the output should report exactly those three missing attributes. It also documents RFC validation behavior as a validation error rather than a generated document.

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 dense but every sentence earns its place. It is front-loaded with the core purpose, then adds exclusions, validation behavior, workflow, and return shape without unnecessary filler. Code formatting and structured bullets improve scannability.

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?

For a complex nested-object tool with no annotations, the description is remarkably complete. It covers model validation, RFC validation behavior, sealed vs unsealed output, expected downstream validation results, and the return dict including the total computation formula. An agent can select and invoke this tool correctly with confidence.

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?

The input schema only describes comprobante_data as an object matching a schema, but the description adds substantial meaning: full field list reference, seller/buyer as MXEmisor/MXReceptor, lines as CFDIConcepto, and RFC validation via TaxIdentifier.validate_mx_rfc. This is critical because the schema uses additionalProperties: true and does not enumerate fields.

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 states a specific verb ('Build'), a specific resource ('CFDI 4.0 Comprobante XML'), and a clear scope ('Ingreso or Egreso'). It also distinguishes itself from the sibling mx__build_pago by explicitly excluding Pago documents, making tool selection unambiguous.

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 when not to use this tool ('For tipo_de_comprobante="P" (Pago), use mx__build_pago instead'), and it names the follow-up tool mx__seal_cfdi for sealing. It also explains what mx__validate_cfdi should report, giving clear workflow guidance.

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

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-cfdi-mx'

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