Skip to main content
Glama

mcp-brasil-data

An MCP server that gives AI assistants (Claude Desktop, Claude Code, Cursor and any MCP client) access to Brazilian public data: postal codes, company registry, national holidays, business-day math and official exchange rates.

Tools

Tool

What it does

Source

lookup_cep

Address for a CEP (postal code)

ViaCEP

validate_cnpj

Offline check-digit validation, including the new alphanumeric CNPJ format

—

lookup_cnpj

Public company data: legal name, status, main activity (CNAE), location

BrasilAPI

list_holidays

National holidays for a year

BrasilAPI

business_days_between

Business days between two dates, excluding weekends and national holidays

BrasilAPI

get_ptax_rate

Official PTAX rate (BRL per unit) for USD, EUR, GBP and others; falls back to the latest previous quote on weekends and holidays

Banco Central do Brasil (Olinda OData)

Example prompts once it is connected:

  • "Which city is CEP 01310-100 in?"

  • "How many business days are there between 2026-11-01 and 2026-12-31?"

  • "Convert US$ 2,500 to BRL using today's PTAX selling rate."

  • "Is 11.222.333/0001-81 a valid CNPJ? Who owns it?"

Related MCP server: MCP Brazil Public Data

Install

Requires Node.js 20+.

git clone <this repo>
cd mcp-brasil-data
npm install
npm run build

Claude Code

claude mcp add brasil-data -- node /absolute/path/to/mcp-brasil-data/dist/index.js

Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "brasil-data": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-brasil-data/dist/index.js"]
    }
  }
}

Development

Command

What it does

npm run build

Compile TypeScript to dist/

npm run typecheck

Type-check without emitting

npm test

Unit + integration tests (Vitest)

src/
  index.ts           stdio entry point
  server.ts          tool registration, input schemas, error mapping
  http.ts            fetch wrapper with timeout and typed errors
  validation.ts      CEP / CNPJ / date parsing and validation
  services/          one module per upstream API
test/
  server.test.ts     end-to-end through an in-memory MCP client
  services.test.ts   upstream mapping with a fake fetch
  validation.test.ts pure validation rules

Design decisions

  • Dependency injection for I/O. Every service receives a fetch function, and the server receives fetch and a clock. Tests never hit the network and the date defaults are deterministic.

  • End-to-end tests through the protocol. server.test.ts connects a real MCP Client to the server over an in-memory transport and calls tools exactly like Claude would.

  • Errors are tool results, not crashes. Validation and upstream failures come back as isError: true with a readable message, so the model can recover or explain the problem.

  • Validate before calling out. Malformed CEPs and CNPJs with wrong check digits are rejected locally, saving a network round trip.

  • Dates are calendar dates. All date math runs in UTC on YYYY-MM-DD values; "today" is resolved in the America/Sao_Paulo time zone.

  • Holidays follow BrasilAPI. Its national list includes Carnival and Corpus Christi, which are optional days off for many employers. Business-day counts treat every listed date as a holiday, and the response says which ones were excluded.

Limitations

  • lookup_cnpj accepts numeric CNPJs only. The alphanumeric format validates offline, but public lookup APIs do not serve it yet.

  • State and municipal holidays are not included.

  • PTAX quotes are published on business days. Before the closing bulletin (around 1 p.m. Brasília time) the tool returns the latest intermediate bulletin and labels it.

License

MIT

Available Tools

6 tools
business_days_betweenCount business daysA
Read-only

Counts business days between two dates (inclusive), excluding weekends and Brazilian national holidays.

Inputs: end (required), start (required).

get_ptax_rateGet the PTAX exchange rateA
Read-only

Returns the official PTAX closing rate (BRL per unit of foreign currency) published by Banco Central do Brasil. If the date has no quote (weekend or holiday), returns the latest previous quote.

Inputs: date, currency.

list_holidaysList Brazilian national holidaysA
Read-only

Lists national holidays in Brazil for a given year, using BrasilAPI.

Inputs: year (required).

lookup_cepLook up a Brazilian postal codeA
Read-only

Returns street, neighborhood, city and state for a Brazilian CEP (postal code), using ViaCEP.

Inputs: cep (required).

lookup_cnpjLook up a company by CNPJB
Read-only

Returns public registration data for a Brazilian company (legal name, status, main activity, location) using BrasilAPI.

Inputs: cnpj (required).

validate_cnpjValidate a CNPJA
Read-only

Checks the CNPJ check digits offline. Supports both the classic numeric format and the alphanumeric format introduced by Receita Federal.

Inputs: cnpj (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool targets a clearly distinct resource and action: postal code lookup, CNPJ validation (offline check digits), CNPJ registry lookup, holiday listing, business-day counting, and PTAX rate retrieval. The only near-pair, validate_cnpj vs lookup_cnpj, is explicitly differentiated in their descriptions as offline checksum vs online registration data.

    Naming Consistency4/5

    Most names follow a clean verb_noun convention (lookup_cep, validate_cnpj, lookup_cnpj, list_holidays, get_ptax_rate) with consistent snake_case. business_days_between breaks the pattern by using a noun phrase with no leading verb, a minor but noticeable deviation.

    Tool Count5/5

    Six tools is a tight, well-scoped set for a Brazilian data utility server, with no filler entries. Every tool covers a distinct data source or computation and earns its place.

    Completeness4/5

    Coverage spans postal codes, company validation and lookup, holidays, business-day math, and exchange rates, forming a coherent utility surface. However, CPF validation/lookup is a glaring omission for a Brazilian data toolkit, and there is no direct 'is this date a holiday' check to complement the range-based tools.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Exposes the BrasilAPI as MCP tools, enabling AI agents to query Brazilian public data such as CEP, CNPJ, DDD, IBGE, banks, PIX, FIPE, NCM, exchange rates, taxes, weather, CVM information, holidays, ISBN, domains, stock tickers, and TUSS.
      41
      Apache 2.0
    • A
      license
      A
      quality
      C
      maintenance
      Enables lookup of Brazilian public data including companies (CNPJ), postal codes (CEP), banking, economy, geography, and more through 15 tools and 2 guided prompts, powered by BrasilAPI with no API key required.
      15
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Exposes Brazilian public data — postal codes (CEP), company registrations (CNPJ), CPF/CNPJ validation, banks, national holidays, municipalities, and DDD area codes — as MCP tools and resources, backed by BrasilAPI, ViaCEP, and IBGE with caching, fallback, and rate limiting. Any MCP client such as Claude Desktop or Claude Code can query and validate this reference and registration data through natural language or programmatic calls.
      1
      MIT