mcp-brazil-erp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-brazil-erp check if CNPJ 11.222.333/0001-81 is valid and look up the company"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-brazil-erp
An MCP server that gives an AI assistant the small Brazilian "plumbing" checks that ERP work runs into every day: is this CNPJ/CPF valid, what does this boleto say, which company issued this NF-e, where is this CEP. It is written in TypeScript on the official @modelcontextprotocol/sdk and uses the stdio transport.
Four of the six tools run fully offline and are pure functions. The other two make read-only calls to the public BrasilAPI.
Tools
Tool | Input | Output | Network |
|
| valid, normalized, formatted, reason. Also accepts the new alphanumeric CNPJ (IN RFB 2.229/2024) | no |
|
| valid, normalized, formatted, reason | no |
|
| legal name, trade name, status, opening date, main activity (CNAE), size, address. The CNPJ is validated locally first | BrasilAPI |
|
| 47 digits (bank): bank code, currency, due date, amount, per-field and general check digits. 48 digits starting with 8 (utilities/taxes): segment, effective/reference value, block check digits | no |
|
| UF, year-month, issuer CNPJ, model (NF-e/NFC-e/CT-e/MDF-e), series, number, emission type, random code, check digit | no |
|
| street, district, city, UF | BrasilAPI |
Boleto due dates after the 2025 reset. The due-date factor counts days from 1997-10-07. It reached 9999 on 2025-02-21 and restarted at 1000 on 2025-02-22, so every factor now maps to two dates about 27 years apart. parse_boleto takes the candidate closest to reference_date (default: today). The tests cover both cycles.
Related MCP server: mcp-fiscal-brasil
Install
npm install
npm run build
npm testClaude Code:
claude mcp add brazil-erp -- node /absolute/path/to/mcp-brazil-erp/dist/src/index.jsClaude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"brazil-erp": {
"command": "node",
"args": ["/absolute/path/to/mcp-brazil-erp/dist/src/index.js"]
}
}
}Safety notes
Read-only. No tool writes anything. All of them are annotated
readOnlyHint: trueanddestructiveHint: false, and only the two lookups areopenWorldHint: true.No credentials. BrasilAPI is public, so there are no keys or tokens to configure or leak.
Validated input. Every tool's input is described with zod schemas and length limits.
lookup_cnpjrejects an invalid CNPJ before any network call.Bounded network calls. Lookups have a timeout (15 s by default). Failures come back as tool errors with a
kind(not_found,invalid_input,rate_limited,timeout,upstream,network) and BrasilAPI's own message, so the model can explain the failure instead of retrying blindly.Mind the data.
lookup_cnpjreturns public company-registry data. Validating a CPF only checks the arithmetic of the number. It does not look up a person.stdout carries the MCP protocol, so the server logs to stderr only.
Tests
The tests cover check-digit validation (with valid and invalid examples), CNPJ/CPF, NF-e keys, both boleto layouts, both due-date cycles, typo detection, and the MCP server end to end through the SDK's in-memory transport. Network tools are tested against a fake fetch, so the test suite never touches the network.
The test values are either textbook test numbers (CNPJ 11.222.333/0001-81, CPF 111.444.777-35, and Receita's alphanumeric example 12.ABC.345/01DE-35) or synthetic numbers whose check digits are computed in the test. No real person's CPF is used.
Trade-offs
Two date candidates instead of one rule. Picking the due date closest to a reference date handles the 2025 factor reset without a hard cutover. It is wrong only for a boleto due more than about 13 years from the reference date, which is not a realistic case.
No due date for arrecadação. Utility and tax slips have no standard due-date field (when one exists, it is inside the free field and its layout varies by agreement), so the tool returns
nullrather than guessing.The alphanumeric CNPJ in NF-e keys is accepted using the same ASCII-48 rule as the CNPJ check digits. Confirm this against the latest technical note before relying on it for a SEFAZ submission.
Single upstream provider. BrasilAPI's CEP endpoint aggregates other providers and is sometimes unavailable. A production version would add a fallback provider and a cache.
Compact output.
lookup_cnpjreturns a stable subset of the BrasilAPI payload instead of the full JSON. That keeps the model's context small, but some fields are dropped.
AI-assisted development
This server was written with Claude Code (Anthropic) as a coding assistant. I chose the tools and the safety constraints from what my ERP work needs, and I reviewed and verified the output with the test suite and manual runs.
License
MIT, see LICENSE.
Available Tools
6 toolslookup_cepLook up CEPBRead-onlyIdempotent
Address for a Brazilian postal code (CEP) via BrasilAPI.
Inputs: cep (required).
lookup_cnpjLook up CNPJBRead-onlyIdempotent
Public registry data of a company (legal name, status, main activity, address) via BrasilAPI.
Inputs: cnpj (required).
parse_boletoParse boletoARead-onlyIdempotent
Decode a boleto linha digitável: 47 digits (bank) or 48 digits starting with 8 (utilities/taxes). Returns bank, amount, due date (handles the 2025 due-factor reset) and check-digit results.
Inputs: line (required), reference_date.
parse_nfe_keyParse NF-e access keyARead-onlyIdempotent
Decode a 44-position NF-e/NFC-e access key: UF, year/month, issuer CNPJ, model, series, number, emission type, check digit.
Inputs: key (required).
validate_cnpjValidate CNPJARead-onlyIdempotent
Check a CNPJ's check digits and format it (accepts masked, digits-only and the new alphanumeric format). Offline.
Inputs: cnpj (required).
validate_cpfValidate CPFARead-onlyIdempotent
Check a CPF's check digits and format it. Offline; does not query any registry.
Inputs: cpf (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool targets a distinct artifact and action: validate_* performs offline check-digit verification, lookup_* queries a remote registry, and parse_* decodes a fixed-length Brazilian payment/fiscal string. The validate_cnpj vs. lookup_cnpj pair is explicitly separated by the 'Offline'/'via BrasilAPI' language, and parse_boleto vs. parse_nfe_key differ by input format (47/48 vs. 44 digits).
All six tools follow a strict verb_noun snake_case pattern with a small, reused verb vocabulary (validate_, lookup_, parse_). No casing or style deviations.
Six tools is well within the ideal range and each one maps to a concrete Brazilian ERP validation/lookup/parsing need. Nothing looks redundant or filler.
CNPJ has both validation and registry lookup, CPF is validated, boletos and NF-e keys are decoded, and CEP resolves to an address — covering the common ERP intake paths. Gaps include no offline CEP format validation, no inscrição estadual (state registration) handling, and no boleto/NF-e emission or encoding counterparts, though agents can work around these.
Maintenance
Related MCP Connectors
Brazilian company data & sanctions screening for AI agents. Certified. Pay-per-call x402.
Brazil CNPJ KYB dossier, IBGE CEP lookup, CPF/CNPJ validator & PIX EMVCo CRC16 via x402 Base USDC.
Brazil CNPJ, CEP, Selic/IPCA/PTAX, holidays, banks/ISPB for agents. Pay per call in USDC (x402).
WhatsApp Business + CNPJ enrichment (71M RFB) for Brazilian AI workflows.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceValidates LatAm banking and tax IDs (Mexican CLABE, Brazilian CNPJ/CPF checksums) and performs BrasilAPI company, CEP, and bank lookups, enabling AI agents to verify financial and tax information in Latin America.94 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables AI assistants and business systems to query and validate Brazilian fiscal data and documents, including CNPJ/CPF, Simples Nacional/MEI, NF-e/NFS-e, SPED, eSocial, and supplier compliance, without mandatory API keys. It also supports offline reference tables, tax-regime comparison, due-diligence scoring, and 2026 IBS/CBS reform analysis through composable tools.MIT
- AlicenseAqualityBmaintenanceEnables AI assistants to query Brazilian public data through BrasilAPI, including company registry details and partners by CNPJ, addresses by CEP, and national holidays. It also performs offline CNPJ/CPF validation before any network request and does not store queried numbers.569 npmMIT
- AlicenseAqualityBmaintenanceEnables AI agents to query Brazilian public data such as CEP, CNPJ, banks, holidays, business days, FIPE vehicle prices, DDD, IBGE municipalities, .br domains, and ISBN, with read-only tools and offline document validation.1461 npmMIT