Skip to main content
Glama

mcp-brasil

CI

Servidor MCP para dados públicos brasileiros: CNPJ, CEP, IBGE e busca no Diário Oficial da União.

An MCP server that gives AI assistants access to Brazilian public data, with no API keys.

Other Brazilian-data MCP servers cover CNPJ, CEP and IBGE. None of them search the Diário Oficial da União (DOU), the federal official gazette where laws, procurement notices, appointments and public contracts are published. This one does. CNPJ, CEP and IBGE are here too, built to keep working when a provider is down.

Tools

Tool

What it does

Source

cnpj_lookup

Company registration data for a CNPJ (numeric or alphanumeric, check digits verified locally)

BrasilAPI, fallback OpenCNPJ

cep_lookup

Address for a postal code

BrasilAPI v2, fallback ViaCEP

ibge_municipios

Municipalities of a state (name + IBGE code)

IBGE localities API

dou_search

Search DOU acts. section: do1, do2, do3, doe, todos; period: dia, semana, mes, ano

in.gov.br

dou_article

Full text of one DOU act, by the slug from a search result

in.gov.br

Every tool returns compact JSON with the same shape whichever provider answered, plus a source field. Missing fields are null; keys are always present. An unknown CNPJ or CEP returns {"found": false, "query": "..."}, not an error.

Examples

Real output, trimmed. Call: cnpj_lookup {"cnpj": "33000167000101"}

{
  "found": true,
  "cnpj": "33000167000101",
  "razao_social": "PETROLEO BRASILEIRO S A PETROBRAS",
  "situacao": "ATIVA",
  "data_abertura": "1966-09-28",
  "cnae_principal": { "codigo": "0600001", "descricao": "Extração de petróleo e gás natural" },
  "natureza_juridica": "Sociedade de Economia Mista",
  "endereco": { "logradouro": "REPUBLICA DO CHILE", "numero": "65", "municipio": "RIO DE JANEIRO", "uf": "RJ", "cep": "20031170" },
  "socios": [{ "nome": "...", "qualificacao": "..." }],
  "source": "brasilapi"
}

cep_lookup {"cep": "01310-100"}

{ "found": true, "cep": "01310100", "logradouro": "Avenida Paulista", "bairro": "Bela Vista",
  "cidade": "São Paulo", "uf": "SP", "ibge": "3550308", "source": "brasilapi" }

ibge_municipios {"uf": "RJ"}

{ "uf": "RJ", "total": 92, "municipios": [ { "codigo": "3300100", "nome": "Angra dos Reis" }, { "codigo": "3300159", "nome": "Aperibé" } ] }

dou_search {"query": "licitação", "period": "semana"} (first of 20 results)

{
  "query": "licitação", "section": "todos", "period": "semana", "total": 3527,
  "results": [{
    "title": "PORTARIA MRE Nº 707, DE 18 DE NOVEMBRO DE 2026",
    "date": "19/11/2026", "section": "DO1_EXTRA_C", "edition": "218-C", "page": "39", "type": "Portaria",
    "organ": "Ministério das Relações Exteriores/Gabinete do Ministro",
    "excerpt": "... A possibilidade de prorrogação deve estar prevista no ato convocatório de licitação ...",
    "slug": "portaria-mre-n-707-de-18-de-novembro-de-2026-745538851",
    "url": "https://www.in.gov.br/web/dou/-/portaria-mre-n-707-de-18-de-novembro-de-2026-745538851"
  }]
}

dou_article {"slug": "portaria-mre-n-707-de-18-de-novembro-de-2026-745538851"}

{
  "slug": "portaria-mre-n-707-de-18-de-novembro-de-2026-745538851",
  "url": "https://www.in.gov.br/web/dou/-/portaria-mre-n-707-de-18-de-novembro-de-2026-745538851",
  "title": "PORTARIA MRE Nº 707, DE 18 DE NOVEMBRO DE 2026",
  "text": "PORTARIA MRE Nº 707, DE 18 DE NOVEMBRO DE 2026 Aprova o novo Regulamento Consular Brasileiro (RCB) ...",
  "truncated": true
}

text is capped at 20,000 characters; truncated says when that happened.

Related MCP server: MCP Brazil Public Data

Install

Requires Node.js 22 or newer.

Claude Code:

claude mcp add mcp-brasil -- npx -y @vinicius-carv/mcp-brasil

Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "mcp-brasil": {
      "command": "npx",
      "args": ["-y", "@vinicius-carv/mcp-brasil"]
    }
  }
}

From source:

git clone https://github.com/vinicius-carv/mcp-brasil && cd mcp-brasil
npm ci && npm run build
node dist/index.js   # stdio server; point your MCP client at this command

Robustness

  • Fallback only when it makes sense. A provider is skipped on network error, timeout, HTTP 429, HTTP 5xx or invalid JSON. A 404 (or ViaCEP's erro) means "does not exist" and returns found: false without trying the next provider.

  • Errors say what happened. A failed call lists every provider tried and why each failed, as a one-line tool error.

  • Retries: up to 2, with 500 ms x 2^n backoff; Retry-After is honored up to 5 s.

  • Throttling: requests to the same host are serialized, with a minimum interval of 250 ms (1 s for in.gov.br). No parallel fan-out.

  • Timeouts: 10 s (20 s for in.gov.br).

  • In-memory cache (max 500 entries, oldest dropped first). Errors are never cached.

Data

Cache TTL

CNPJ

24 h

CEP

7 days

IBGE municipalities

7 days

DOU search

10 min

DOU article

24 h

Not found (404)

1 h

ViaCEP {"erro":true} (unknown CEP)

7 days (normal CEP TTL)

Inputs are validated before any network call (CNPJ check digits, 8-digit CEP, the 27 UF codes, DOU enums).

DOU caveats

  • in.gov.br refuses connections from outside Brazil. dou_search and dou_article need a Brazilian IP; from elsewhere they fail with an error that says so. The other tools work anywhere.

  • First page only: a search returns the first 20 results (total shows the full count). Narrow with period and section instead of paging.

  • It is scraping. in.gov.br has no public search API, so the parser reads the search page's embedded JSON and the article HTML. If the site changes, the tool fails with "DOU page format changed". Run npm run test:live and open an issue.

Development

npm ci
npm test            # build + offline tests (recorded fixtures, no network)
npm run test:live   # one real call per tool; DOU needs a Brazilian IP

CI runs the offline suite on Node 22 and 24, Linux and Windows. It never runs the live tests.

Data sources and terms

Data comes from public services; check their terms before heavy use. This project sends a User-Agent identifying itself and keeps request volume low.

Not affiliated with any of these services or with the Brazilian government.

License

MIT

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Brazilian company-registry lookup via Receita Federal, allowing AI agents to query CNPJ data.
      59 npm
      MIT
    • 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
      Enables LLM clients to query public Brazilian data through tools for CEP addresses, CNPJ registrations, banks, FIPE vehicle prices, national holidays, and DDD area codes, with no API key required.
      8
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables 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.
      5
      60 npm
      MIT