Skip to main content
ClaudeWave

Model Context Protocol (MCP) server for Brazilian Electronic Invoicing (NF-e / NFC-e, modelo 55/65, schema 4.00). Provides CPF/CNPJ validation tools, with NF-e/NFC-e generation and SEFAZ integration planned.

MCP ServersOfficial Registry0 stars0 forksPythonApache-2.0Updated today
ClaudeWave Trust Score
95/100
Verified
Passed
  • Open-source license (Apache-2.0)
  • Actively maintained (<30d)
  • Clear description
  • Topics declared
  • Documented (README)
Last scanned: 8/27/2026
Install in Claude Code / Claude Desktop
Method: pip / Python · mcp-nfe-br
Claude Code CLI
claude mcp add mcp-nfe-br -- python -m mcp-nfe-br
claude_desktop_config.json (Claude Desktop)
{
  "mcpServers": {
    "mcp-nfe-br": {
      "command": "python",
      "args": ["-m", "mcp-nfe-br"]
    }
  }
}
1. Run the command above in your terminal (Claude Code), or paste the JSON config into claude_desktop_config.json (Claude Desktop).
2. Replace any <placeholder> values with your API keys or paths.
3. Restart Claude. The MCP server and its tools appear automatically.
💡 Install first: pip install mcp-nfe-br
Use cases

MCP Servers overview

# mcp-nfe-br 🇧🇷

[English](README.md) | [Portugues (Brasil)](README.pt-BR.md)

<!-- mcp-name: io.github.cmendezs/mcp-nfe-br -->

[![PyPI version](https://badge.fury.io/py/mcp-nfe-br.svg)](https://badge.fury.io/py/mcp-nfe-br)
[![Python](https://img.shields.io/pypi/pyversions/mcp-nfe-br.svg)](https://pypi.org/project/mcp-nfe-br/)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

---

## Introduction

`mcp-nfe-br` is an [MCP (Model Context Protocol)](https://modelcontextprotocol.io) 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`](https://github.com/cmendezs/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) 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 and `context-library/countries/br.md` (in the source repo) for the full field-level reference.

---

## Installation

### Requirements

- Python ≥ 3.11
- [`mcp-einvoicing-core`](https://github.com/cmendezs/mcp-einvoicing-core) (installed automatically as a dependency)

### Using `uv` (recommended)

```bash
uv add mcp-nfe-br
```

### Using `pip`

```bash
pip install mcp-nfe-br
```

### From source

```bash
git clone https://github.com/cmendezs/mcp-nfe-br.git
cd mcp-nfe-br
uv sync --all-extras
```

---

## Configuration

Add the server to your MCP client configuration. For Claude Desktop, edit `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "nfe-br": {
      "command": "uvx",
      "args": ["mcp-nfe-br"]
    }
  }
}
```

For a local development installation:

```json
{
  "mcpServers": {
    "nfe-br": {
      "command": "uv",
      "args": ["run", "mcp-nfe-br"],
      "cwd": "/path/to/mcp-nfe-br"
    }
  }
}
```

### Environment variables

| Variable | Description | Default |
|---|---|---|
| `BR_READ_ONLY` | Master switch. Set to `1` to disable write tools across **all** sub-formats: NF-e/NFC-e (`br__submit_nfe`, `br__distribute_dfe`), NFS-e (`br__submit_nfse`, `br__cancel_nfse`), and CT-e (`br__submit_cte`, `br__cancel_cte`, `br__correct_cte`). Safe mode for exploration. The SEFAZ environment (production/homologation) is selected per call via the `tp_amb` argument. | — |
| `BR_CTE_READ_ONLY` | Set to `1` to disable *only* the CT-e write tools (`br__submit_cte`, `br__cancel_cte`, `br__correct_cte`), leaving NF-e/NFS-e writes enabled. Independent of `BR_READ_ONLY` — either variable set to `1` is sufficient to block CT-e writes; you do not need both. | — |
| `LOG_LEVEL` | Log level: `DEBUG`, `INFO`, `WARNING`, `ERROR` | `INFO` |

---

## 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.

| Parameter | Type | Required | Description |
|---|---|---|---|
| `cpf` | `string` | yes | CPF with or without `.`/`-` separators |

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.

| Parameter | Type | Required | Description |
|---|---|---|---|
| `cnpj` | `string` | yes | CNPJ with or without `.`/`/`/`-` separators |

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. See `context-library/countries/br.md` for details.

---

### `br__generate_nfe`

Generates an **unsigned** NF-e/NFC-e 4.00 document (`<NFe><infNFe>…</infNFe></NFe>`) from a `BRInvoice` object.

| Parameter | Type | Required | Description |
|---|---|---|---|
| `invoice` | `object` | yes | `BRInvoice` document (modelo 55 or 65, groups `ide`/`emit`/`dest`/`det`/`total`/`transp`/`pag`) |

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:

| Tax | Supported codes | Behavior |
|---|---|---|
| ICMS | CST `00` (normal regime) or CSOSN `102` (Simples Nacional) | other codes raise `DocumentGenerationError` |
| PIS/COFINS | CST `01`/`02` (rate-based) or `04`-`09` (non-taxed) | group omitted if `pis_cst`/`cofins_cst` are `None` |
| IPI | CST `00`/`49`/`50`/`99` (taxed) or other (non-taxed) | group omitted if `ipi_cst` is `None` |

`[NEED: IBS/CBS/Imposto Seletivo — Grupo UB/W03 (NT 2025.002-RTC) not yet modeled, see context-library/countries/br.md "Known gaps"]`.

---

### `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` delta (local "unsigned" variant, see note below).

| Parameter | Type | Required | Description |
|---|---|---|---|
| `xml_content` | `string` | no* | XML as a string |
| `xml_base64` | `string` | no* | Base64-encoded XML |

\* 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.

| Parameter | Type | Required | Description |
|---|---|---|---|
| `c_uf` | `string` | yes | IBGE state code (2 digits) |
| `dh_emi` | `string` | yes | Issue date/time (ISO 8601) |
| `cnpj` | `string` | yes | Issuer CNPJ (numeric or alphanumeric PL_010d) |
| `modelo` | `string` | yes | `55` (NF-e) or `65` (NFC-e) |
| `serie` | `string` | yes | Document series |
| `nnf` | `string` | yes | Document number |
| `tp_emis` | `string` | no | Issuance type (default `"1"`) |
| `c_nf` | `string` | no | Random numeric code (cNF, 8 digits); auto-generated if omitted |

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.

| Parameter | Type | Required | Description |
|---|---|---|---|
| `cte` | `object` | yes | `BRCTeDocument` (modelo 57, modal rodoviário, ICMS CST 00) |

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).

| Parameter | Type | Required | Description |
|---|---|---|---|
| `xml_content` | `string` | no* | XML as a string |
| `xml_base64` | `string` | no* | Base64-encoded XML |

\* 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
brazile-invoicingmcpmcp-servernfcenfe

What people ask about mcp-nfe-br

What is cmendezs/mcp-nfe-br?

+

cmendezs/mcp-nfe-br is mcp servers for the Claude AI ecosystem. Model Context Protocol (MCP) server for Brazilian Electronic Invoicing (NF-e / NFC-e, modelo 55/65, schema 4.00). Provides CPF/CNPJ validation tools, with NF-e/NFC-e generation and SEFAZ integration planned. It has 0 GitHub stars and its last recorded update is dated 2026-08-26.

How do I install mcp-nfe-br?

+

You can install mcp-nfe-br by cloning the repository (https://github.com/cmendezs/mcp-nfe-br) or following the README instructions on GitHub. ClaudeWave also provides quick install blocks on this page.

Is cmendezs/mcp-nfe-br safe to use?

+

Our security agent has analyzed cmendezs/mcp-nfe-br and assigned a Trust Score of 95/100 (tier: Verified). See the full breakdown of passed checks and flags on this page.

Who maintains cmendezs/mcp-nfe-br?

+

cmendezs/mcp-nfe-br is maintained by cmendezs. The last recorded GitHub activity is dated 2026-08-26, with 0 open issues.

Are there alternatives to mcp-nfe-br?

+

Yes. On ClaudeWave you can browse similar mcp servers at /categories/mcp, sorted by popularity or recent activity.

Deploy mcp-nfe-br to your cloud

Ship this repo to production in minutes. Each platform spins up its own environment with editable env vars.

Maintain this repo? Add a badge to your README

Drop the badge into your GitHub README to show it's tracked on ClaudeWave. Each badge links back to this page and reflects the live Trust Score.

Featured on ClaudeWave: cmendezs/mcp-nfe-br
[![Featured on ClaudeWave](https://claudewave.com/api/badge/cmendezs-mcp-nfe-br)](https://claudewave.com/repo/cmendezs-mcp-nfe-br)
<a href="https://claudewave.com/repo/cmendezs-mcp-nfe-br"><img src="https://claudewave.com/api/badge/cmendezs-mcp-nfe-br" alt="Featured on ClaudeWave: cmendezs/mcp-nfe-br" width="320" height="64" /></a>

More MCP Servers

mcp-nfe-br alternatives