
Mcp Nfe Br
io.github.cmendezs由 GitHub 账号 cmendezs 发布v0.9.1更新于 Oct 24, 2026
MCP server for Brazilian e-invoicing: NF-e and NFC-e (modelo 55/65), schema 4.00, SEFAZ.
概览
面向巴西电子发票的本地 MCP 服务器,让助手生成、校验并提交 NF-e、NFC-e、NFS-e 和 CT-e 税务单据。
- 可以做什么
- 校验 CPF 和 CNPJ 纳税人识别号,包括字母数字格式的 CNPJ,并根据各组成部分生成 44 位 NF-e 访问密钥。从发票对象生成未签名的 NF-e/NFC-e 4.00 XML,并按内置模式校验 NF-e/NFC-e XML。生成未签名的 CT-e 4.00 XML,并按内置模式校验 CT-e XML。查询 SEFAZ CT-e 网络服务状态,并按访问密钥查询单张 CT-e。通过带确认门控的 SEFAZ 调用提交、取消或更正 CT-e,以及提交或取消 NF-e/NFC-e 和 NFS-e 单据。
- 适用场景
- 适合需要处理巴西税务单据的场景:起草或检查 NF-e/NFC-e/CT-e XML、校验纳税人号码和访问密钥,或在本地环境中驱动 SEFAZ 的提交与取消。面向构建或测试电子发票流程的开发者和财务团队,而非通用办公用途。
- 运行要求
- 以 Python 包形式在本地运行(Python 3.11 或更高版本),可通过 uvx 或 pip 安装,mcp-einvoicing-core 依赖会自动安装。运行本身不需要凭据。可选环境变量 BR_READ_ONLY、BR_CTE_READ_ONLY 和 LOG_LEVEL 用于控制写入工具和日志。向 SEFAZ 提交需要数字证书和网络访问;CT-e 调用需要显式指定 endpoint override。
安装
在 SourceWeft 中
- 打开 控制台中的 Mcp Nfe Br,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
mcp-nfe-br 🇧🇷
[PyPI version] [Python] [License]
Introduction
mcp-nfe-br is an MCP (Model Context Protocol) server providing tools for issuing and validating Brazilian electronic fiscal documents: NF-e (modelo 55), NFC-e (modelo 65), NFS-e Nacional (ADN), and CT-e (modelo 57). This server is part of the mcp-einvoicing-* / mcp-*-* family, built on mcp-einvoicing-core, which provides the base data model, HTTP/OAuth2 utilities, and shared MCP server infrastructure.
Current status (v0.6.5): NF-e/NFC-e (modelo 55/65, schema 4.00) and NFS-e Nacional (ADN, schema v1.01) generation, ICP-Brasil signing, XSD validation, and gated SEFAZ/ADN submission are implemented. NF-e/NFC-e now also covers the 010e_v.1.02 schema delta (DANFE Simplificado Tipo 2 — tpImp=6, cIndOp, ISUFEmit, and the SEFAZ alert-message response group) and the 010f_v.1.04 delta (NT 2026.007 — emit/IE optional for taxpayers exclusively subject to IBS/CBS, produção 2026-11-03) on top of the PL_010d base. CT-e (modelo 57) generation/signing/validation and SEFAZ event submission (cancelamento, Carta de Correção) were added starting v0.6.0 — v1 scope is intentionally narrow: modal rodoviário only, ICMS CST 00 only, and no bundled/verified CT-e webservice endpoint table (every SEFAZ CT-e call requires an explicit endpoint_override). See the "CT-e (modelo 57)" tools section below for the full field-level reference.
Installation
Requirements
- Python ≥ 3.11
mcp-einvoicing-core(installed automatically as a dependency)
Using uv (recommended)
Using pip
From source
Configuration
This server needs no credentials to run. The environment variables below are optional safety/logging toggles:
Environment variables
Claude Desktop integration
To use this server with Claude, add this configuration to your claude_desktop_config.json file:
For a local development install:
Cursor integration
Cursor supports MCP servers via stdio. Add the configuration in:
- Global (all projects):
~/.cursor/mcp.json - Project (this repository only):
.cursor/mcp.json
Reload the Cursor window (Ctrl+Shift+P then Reload Window) to apply the changes.
Kiro integration
Kiro supports MCP servers via its dedicated configuration file. Two levels are available:
- Global (all projects):
~/.kiro/settings/mcp.json - Workspace (this repository only):
.kiro/settings/mcp.json
The file is automatically reloaded on save. You can also open the config via the command palette (Cmd+Shift+P / Ctrl+Shift+P) then MCP.
Available tools
br__validate_cpf
Validates a CPF (Cadastro de Pessoas Físicas), the individual taxpayer identification number, using the Receita Federal modulo 11 algorithm.
Returns a TaxIdValidationResult with valid=True and the cleaned value (11 digits) on success, or valid=False with an error message in Portuguese.
br__validate_cnpj
Validates a CNPJ (Cadastro Nacional da Pessoa Jurídica), the business taxpayer identification number. Accepts both the traditional numeric format (14 digits) and the alphanumeric format introduced by NT 2026.004 (PL_010d), effective in homologation from 2026-06-01 and in production from 2026-07-01.
Returns a TaxIdValidationResult with valid=True and the cleaned value (14 characters) on success, or valid=False with an error message in Portuguese.
⚠️ [Unverified]: the check-digit algorithm for the alphanumeric CNPJ format was implemented based on secondary sources, as the primary source ("NT Conjunta DFe 2025.001") is not yet available locally.
br__generate_nfe
Generates an unsigned NF-e/NFC-e 4.00 document (<NFe><infNFe>…</infNFe></NFe>) from a BRInvoice object.
Returns {"xml": ..., "chave_acesso": ..., "warnings": [...]}. The warnings in Portuguese remind that the document is not signed (ICP-Brasil) and was not transmitted to SEFAZ. Both steps are the responsibility of a separate process.
Phase 1 coverage for per-item tax groups:
[NEED: IBS/CBS/Imposto Seletivo — Grupo UB/W03 (NT 2025.002-RTC) not yet modeled].
br__validate_nfe_xml
Validates an NF-e/NFC-e 4.00 XML document against the official PL_010d XSD, patched with the PL_010e_v.1.02 and PL_010f_v.1.04 deltas (local "unsigned" variant, see note below).
* Exactly one of xml_content/xml_base64 must be provided.
Returns {"valid": bool, "errors": [...], "metadata": {"schema_version": ...}}.
[Inference]: the official XSD (
nfe_v4.00.xsd/leiauteNFe_v4.00.xsd, PL_010d) requires<ds:Signature>as a mandatory child of<NFe>. Since Phase 1 generates unsigned documents, this tool validates against a local derived copy (nfe_v4.00_unsigned.xsd) where<ds:Signature>has been made optional (minOccurs="0"). Validation of signed documents (future phase) should use the official XSD without modifications.
br__build_access_key
Builds an access key (chNFe, 44 characters) with a modulo 11 check digit, from the components cUF, dhEmi, issuer CNPJ, model, series, and document number.
Returns {"chave_acesso": ..., "cnf": ...}.
CT-e (modelo 57) tools
CT-e (Conhecimento de Transporte Eletrônico) coverage started at v0.6.0. v1 scope is intentionally narrow: modal rodoviário only (other modais raise an error), ICMS CST 00 (tributação normal) only, and no bundled/verified SEFAZ CT-e endpoint table — every SEFAZ call below requires an explicit endpoint_override. Since v0.7.0, br__generate_cte also accepts the Reforma Tributária do Consumo (IBS/CBS) fields introduced by NT 2026.002 — imp/IBSCBS, emit/ISUFEmit, and ide/tpPagAnt+gPagAntecipado — with the NT's self-contained business rules enforced at the model layer; rules that require a live SEFAZ database lookup are not checked.
br__generate_cte
Generates an unsigned CT-e 4.00 document (<CTe><infCte>…</infCte></CTe>) from a BRCTeDocument object.
Returns {"xml": ..., "chave_acesso": ..., "warnings": [...]}.
br__validate_cte_xml
Validates a CT-e 4.00 XML document against the bundled PL_CTe_400 XSD (auto-selects the unsigned or official signed schema based on <ds:Signature> presence).
* Exactly one of xml_content/xml_base64 must be provided.
br__consult_cte_sefaz_status
Checks SEFAZ CT-e webservice availability (CTeStatusServicoV4). Read-only, no confirmation required.
br__consult_cte
Queries a CT-e's status by access key (CTeConsultaV4). Read-only, no confirmation required — it queries one already-known document, not a bulk data pull.
br__submit_cte
Submits a signed CT-e to SEFAZ authorization (CTeRecepcaoSincV4, synchronous). The payload is automatically GZip-compressed and Base64-encoded before transmission, per the CT-e MOC. Gated with a two-step confirmation (ConfirmationGate) and BR_CTE_READ_ONLY.
br__cancel_cte
Requests cancellation of an authorized CT-e (event 110111, CTeRecepcaoEventoV4). cStat=135 indicates the cancellation was homologated. Gated.
br__correct_cte
Issues a Carta de Correção Eletrônica (event 110110, CTeRecepcaoEventoV4). Per Art. 58-B of CONVÊNIO/SINIEF 06/89, a CC-e cannot alter tax values, party registration data, or the issue/departure date. Gated.
Not yet implemented: br__distribute_cte_dfe (CTeDistribuicaoDFe) — the bundled specification confirms the request payload shape but not the webservice's method name, WSDL namespace, or message-wrapper element.
Architecture
Relationship with mcp-einvoicing-core
mcp-einvoicing-core provides:
- Base Pydantic models for invoices, parties, line items, and validation results (
InvoiceDocument,InvoiceLineItem,TaxIdValidationResult) - Shared MCP server infrastructure (
EInvoicingMCPServer) - HTTP/OAuth2 client, token cache, structured logging, exception hierarchy
mcp-nfe-br adds Brazil-specific logic:
BRInvoice(extendsInvoiceDocument, as NF-e/NFC-e has no EN 16931 lineage)- Group I fields (NCM, CFOP, ICMS/IPI/PIS/COFINS) in
BRInvoiceLine - CPF/CNPJ validation (including the alphanumeric CNPJ from NT 2026.004)
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.
Invoices go directly to SEFAZ (NF-e/NFC-e) and the CT-e SEFAZ endpoint with your own digital certificate; no intermediary is involved.
Contributing
Contributions are welcome. Please open an issue to discuss significant changes before submitting a pull request.
Other e-invoicing MCP servers
License
This project is licensed under Apache 2.0. See LICENSE for details. For the full version history, see CHANGELOG.md.
来源:README.md,提交 fc55114
工具
0版本历史
1- v0.9.1最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分