Mcp Cfdi Mx

io.github.cmendezs由 GitHub 帳號 cmendezs 發布v0.4.1更新於 Oct 27, 2026

MCP server for Mexican electronic invoicing (CFDI 4.0, Pagos 2.0)

概覽

AI 產生的概覽

本機 MCP 伺服器,讓助理建立、依 XSD 驗證並數位簽署墨西哥 CFDI 4.0 發票與 Pagos 2.0 付款補充文件。

可以做什麼
  • 依結構化輸入產生 CFDI 4.0 的 Ingreso 或 Egreso 憑證 XML,以及 Pagos 2.0 付款補充文件
  • 依 SAT 的 XSD 結構定義驗證文件,包含 TFD 與 Pagos 補充文件
  • 使用開立方的 CSD 計算數位簽章,可選擇本機簽署或交由 PAC 簽署
  • 解析 PAC 回傳的 Timbre Fiscal Digital 印章,並在提供 PAC 憑證時進行密碼學驗證
  • 查詢目前支援的文件類型、補充文件與簽署模式
適用情境
適合處理墨西哥電子發票的情境:希望助理在把 CFDI 4.0 文件交給 PAC 之前,先在本機草擬、檢查或簽署。適合開發者與財務團隊建置開票流程,不適合需要端到端蓋章或送件的使用者。
執行需求
以 Python 套件形式在本機執行(pip install mcp-cfdi-mx 或 uvx mcp-cfdi-mx),透過 stdio 通訊;需要 Claude Desktop、Cursor、Kiro 等桌面用戶端。不需要環境變數。CSD 憑證與私鑰路徑及其密碼透過工具參數傳入。
安裝前請注意
簽署會使用開立方的 CSD 憑證與私鑰,應將這些檔案與密碼視為敏感資料,避免在請求中內嵌金鑰內容。此伺服器不會向 PAC 送件,文件在 PAC 蓋章前不具法律效力。目前不支援 Carta Porte、Nómina、Retenciones 與 Comercio Exterior。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Mcp Cfdi Mx,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

mcp-cfdi-mx 🇲🇽

English | Español

[License] [PyPI version] [Python] [mcp-cfdi-mx MCP server]

A Python MCP server providing tools for Mexican electronic invoicing compliant with CFDI 4.0 and Complemento de Pagos 2.0, per SAT's Anexo 20 technical standard. It enables AI agents (Claude, IDEs) to build, XSD-validate, and seal CFDI 4.0 documents (Ingreso, Egreso, and Complemento de Pagos 2.0), verify a PAC-returned Timbre Fiscal Digital stamp, and validate Mexican RFC tax identifiers.

Phase 1 scope. This package covers CFDI 4.0 Ingreso, Egreso, and Complemento de Pagos 2.0 only — Carta Porte, Complemento de Nómina, Retenciones, and Comercio Exterior are not yet supported, and it does not submit to any PAC. See Available tools for exactly what is implemented today.


Introduction

This package is built on mcp-einvoicing-core, the shared base library for e-invoicing MCP servers. It provides the InvoiceDocument model base, the TaxIdentifier.validate_mx_rfc RFC validator, and SelloDigitalSigner — the MX-specific concrete implementation of core's document-signing abstraction (SHA-256 digest of the cadena original, RSA-PKCS#1v1.5-signed with the emisor's CSD, per SAT's Anexo 20).

mcp-einvoicing-core is installed automatically as a dependency, no additional step is required.

CFDI is a clearance-model standard: a CFDI becomes legally valid only once a PAC (Proveedor Autorizado de Certificación) certifies it and returns a Timbre Fiscal Digital (TFD). This package does not submit to a PAC — it is PAC-agnostic, producing either a locally-sealed CFDI (ready to hand to any PAC that accepts pre-sealed documents) or an unsealed, schema-valid CFDI (for a PAC that seals on the emisor's behalf), selected via a sealing_mode parameter.

Installation

Via PyPI (recommended)

bash
pip install mcp-cfdi-mx

Or without prior installation using uvx:

bash
uvx mcp-cfdi-mx

From source

bash
git clone https://github.com/cmendezs/mcp-cfdi-mx.gitcd mcp-cfdi-mxuv sync --all-extras

Configuration (environment variables)

This package has no required environment variables. CSD certificate/key paths and passwords are passed as tool arguments (file paths or environment references — never plaintext key material embedded in a request), not read from a fixed environment variable name.

Claude Desktop integration

Add the following configuration to your claude_desktop_config.json file:

json
{  "mcpServers": {    "cfdi-mx": {      "command": "uvx",      "args": ["mcp-cfdi-mx"]    }  }}

Cursor integration

Cursor supports MCP servers via stdio. Add the configuration to:

  • Globally (all projects): ~/.cursor/mcp.json
  • Per project (this repository only): .cursor/mcp.json
json
{  "mcpServers": {    "cfdi-mx": {      "command": "uvx",      "args": ["mcp-cfdi-mx"]    }  }}

Reload the Cursor window (Ctrl+Shift+P → Reload Window) after saving changes.

Kiro integration

Kiro supports MCP servers through a dedicated configuration file:

  • Globally: ~/.kiro/settings/mcp.json
  • Workspace: .kiro/settings/mcp.json
json
{  "mcpServers": {    "cfdi-mx": {      "command": "uvx",      "args": ["mcp-cfdi-mx"],      "disabled": false,      "autoApprove": []    }  }}

Security tip: if a future tool version accepts credentials via environment reference, use the syntax "VAR_NAME": "${VAR_NAME}" so Kiro resolves it from the shell rather than storing it in plaintext.

Available tools

Build

ToolDescription
mx__build_cfdiBuild a well-formed, unsealed CFDI 4.0 Comprobante XML (Ingreso or Egreso) from structured input
mx__build_pagoBuild a Complemento de Pagos 2.0 CFDI (TipoDeComprobante="P"), composing the fixed single-Concepto wrapper SAT's guide mandates

Validate and seal

ToolDescription
mx__validate_cfdiFull XSD validation against cfdv40.xsd, plus TimbreFiscalDigitalv11.xsd.xml and/or Pagos20.xsd.xml when those complements are present
mx__seal_cfdiCompute the Sello Digital via SelloDigitalSigner, sealing_mode-aware ("local" | "pac")
mx__verify_tfdParse a PAC-returned Timbre Fiscal Digital 1.1 stamp, and cryptographically verify SelloSAT when the PAC's certificate is supplied

Scope

ToolDescription
mx__get_supported_scopeReturns the CFDI document types, complementos, and sealing modes this package currently supports

See docs/TOOLS.md for the full parameter reference of every tool, generated from the live tool registry.

Not yet implemented

PAC submission transport (this package is PAC-agnostic and does not submit to any specific PAC), and later-phase complementos (Carta Porte, Complemento de Nómina, Retenciones, Comercio Exterior).

Architecture

mcp_cfdi_mx.models.CFDIComprobante extends mcp_einvoicing_core.models.InvoiceDocument (the non-EN 16931 pathway — CFDI predates and has no lineage to CEN TC 434, the same determination as mcp-nfe-br). RFC validation for both Emisor and Receptor routes through TaxIdentifier.validate_mx_rfc (core). Sealing routes through mcp_einvoicing_core.digital_signature.SelloDigitalSigner, the MX-specific concrete implementation of core's BaseDocumentSigner — the same pattern ES (XAdES), BR (XML-DSig), and IT (CAdES) use for their own signature standards.

text
[ ERP System / Application ] <--> [ MCP Server ] <--> [ PAC (any, PAC-agnostic) / SAT ]          ^                           |          |                           v   [ AI Agent (Claude) ] <--- (CFDI 4.0 / Pagos 2.0)

Vendor neutrality

This server implements the standard itself: it builds, validates, and signs the document locally. It is not a client for a commercial invoicing platform, and your signing keys and credentials never leave your own infrastructure.

A PAC (Proveedor Autorizado de Certificación) must stamp the CFDI; this server seals it locally with your own CSD and hands any PAC an already-sealed document.

Supported standards

StandardVersionSource
CFDI (Comprobante Fiscal Digital por Internet)4.0SAT Anexo 20, DOF 2022-01-13
Timbre Fiscal Digital1.1SAT
Complemento de Pagos2.0SAT

See specs/README.md for the full source bundle and retrieval dates.

Tests

bash
uv run pytest tests/ -v

Contributing

Contributions are welcome — see CONTRIBUTING.md for guidelines.

Other e-invoicing MCP servers

CountryServer
🌍 Globalmcp-einvoicing-core
🇧🇪 Belgiummcp-einvoicing-be
🇧🇷 Brazilmcp-nfe-br
🇫🇷 Francemcp-facture-electronique-fr
🇩🇪 Germanymcp-einvoicing-de
🇮🇳 Indiamcp-einvoicing-in
🇮🇹 Italymcp-fattura-elettronica-it
🇲🇽 Mexicomcp-cfdi-mx
🇵🇱 Polandmcp-ksef-pl
🇸🇬 Singaporemcp-invoicenow-sg
🇪🇸 Spainmcp-facturacion-electronica-es
🇦🇪 United Arab Emiratesmcp-einvoicing-ae

License

This project is distributed under the Apache 2.0 license. See the LICENSE file for details. For the full version history, see CHANGELOG.md.

來源:README.md,提交 477ab53

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.4.1最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分