Skip to main content
Glama
GusMesquita

brasilapi-mcp-server

by GusMesquita

brasilapi-mcp-server

Servidor MCP que expõe a BrasilAPI (pública, sem autenticação) como ferramentas para LLMs: consulta de CNPJ, CEP, bancos e feriados nacionais.

Serve dois papéis:

  1. Standalone: conectado ao Claude Desktop/Claude Code via stdio, permite que o modelo consulte dados públicos brasileiros durante uma conversa.

  2. Serviço de enriquecimento: usado por outros projetos deste portfólio (lead-router) para enriquecer leads com dados de CNPJ/CEP.

Ferramentas expostas

Tool

Descrição

lookup_cnpj(cnpj)

Razão social, endereço, situação cadastral e CNAE de uma empresa

lookup_cep(cep)

Endereço e coordenadas de um CEP

list_banks()

Lista de bancos registrados no Banco Central (códigos COMPE/ISPB)

get_holidays(year)

Feriados nacionais de um ano

Related MCP server: mcp-brasil

Rodando localmente

uv sync
uv run brasilapi-mcp-server

Conectando no Claude Desktop

Adicione em claude_desktop_config.json:

{
  "mcpServers": {
    "brasilapi": {
      "command": "uv",
      "args": ["--directory", "/caminho/para/brasilapi-mcp-server", "run", "brasilapi-mcp-server"]
    }
  }
}

Rodando como serviço HTTP (streamable-http)

Para ser chamado por outros serviços deste portfólio (lead-router) sem um processo MCP dedicado por cliente:

MCP_TRANSPORT=streamable-http MCP_HTTP_PORT=8001 uv run brasilapi-mcp-server

Ou via Docker:

docker build -t brasilapi-mcp-server .
docker run -p 8001:8001 brasilapi-mcp-server

Resiliência

  • Cache em memória (1h de TTL) para respostas de sucesso — ver cache.py.

  • Retry com backoff exponencial (2 tentativas) em 429/5xx; um 404 nunca é re-tentado — ver client.py.

  • Erros tipados: NotFoundError, RateLimitedError, BrasilAPIError — ver AGENTS.md para o contrato completo de comportamento.

  • Logs estruturados (JSON-lines em stderr) — logging_config.py.

Testes

uv sync --group dev
uv run pytest
uv run ruff check .

Roadmap

  • Cobertura de mais endpoints da BrasilAPI (DDD, tabela FIPE, câmbio)

  • Cache compartilhado (Redis) se rodar com mais de uma réplica

Available Tools

4 tools
get_holidaysA
Read-onlyIdempotent

List Brazilian national holidays for a given year.

Args: year: Four-digit year (e.g. 2026).

ParametersJSON Schema
NameRequiredDescriptionDefault
yearYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.6/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already establish read-only, idempotent, non-destructive behavior. The description adds the useful boundary that only Brazilian national holidays are returned and requires a four-digit year, going slightly beyond the structured hints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two compact, front-loaded sentences plus an Args listing. Every sentence earns its place with no filler or repetition of schema details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter read-only tool with annotations and an output schema, this is complete. It covers input format, scope, and safety implications without missing anything critical.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema only defines year as an integer, so the description's 'Four-digit year (e.g. 2026)' adds essential format and semantic meaning. It fully compensates for the 0% schema description coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence names a precise verb and resource ('List Brazilian national holidays') and scopes it to a year. It is clearly distinct from sibling tools that look up CNPJ, CEP, or banks.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives clear invocation context: use this when you need Brazilian national holidays for a given year. It implies the exclusivity to national holidays, though it does not explicitly name alternative tools or negative cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_banksA
Read-onlyIdempotent

List all Brazilian banks registered with the Central Bank, with their codes (COMPE/ISPB).

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.3/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint, openWorldHint, idempotentHint, and destructiveHint=false, so the safety profile is fully covered. The description adds context about the data source and output codes but does not disclose additional behavioral traits such as pagination, freshness, or rate limits. With strong annotations, this is acceptable but not exceptional.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that front-loads the verb, resource, and scope, then adds the relevant output fields. There is no wasted wording.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter read-only list tool with comprehensive annotations and an output schema, the description is sufficient. It states the authoritative source, the scope, and the codes returned, leaving no critical gap for an agent to call it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, so there is no parameter detail for the description to add. The schema coverage is effectively complete, and the description reinforces the unbounded 'all banks' scope. Baseline for zero parameters is 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('List') and a precise resource ('Brazilian banks registered with the Central Bank'), and it specifies the key output fields (COMPE/ISPB codes). It is clearly distinguishable from sibling lookup tools such as lookup_cnpj and lookup_cep.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description makes the tool's scope obvious: it is for listing all Brazilian banks, not for looking up specific entities or dates. It does not explicitly name alternatives or exclusions, but the sibling names make the intended use clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

lookup_cepA
Read-onlyIdempotent

Look up a Brazilian postal code (CEP) — street, neighborhood, city, state, and coordinates.

Args: cep: CEP number, with or without formatting (e.g. "01310930" or "01310-930").

ParametersJSON Schema
NameRequiredDescriptionDefault
cepYes

TDQS

A4.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false, so the agent knows this is a safe, non-mutating lookup. The description adds the specific return fields (street, neighborhood, city, state, coordinates), which is useful behavioral context beyond the annotations. However, it doesn't disclose potential error behavior (e.g., invalid CEP, not found) or rate limits, which would be valuable for a lookup tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and front-loaded. The first sentence states the purpose and return data, and the Args section provides parameter guidance. Every sentence earns its place; there is no fluff or repetition of schema information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple, single-parameter lookup tool with annotations covering the safety profile, the description is nearly complete. It covers what the tool does, what it returns, and how to format the parameter. The only gap is error handling behavior (e.g., what happens with an invalid or nonexistent CEP), but this is a minor omission for a read-only lookup tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It does: it explains the cep parameter accepts a CEP number with or without formatting, providing examples ('01310930' or '01310-930'). This adds meaning beyond the schema, which only says the parameter is a string. The description could mention validation rules (e.g., 8 digits) but the format guidance is solid.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: looking up a Brazilian postal code (CEP) and lists the specific data returned (street, neighborhood, city, state, coordinates). This is a specific verb+resource combination that distinguishes it from siblings like lookup_cnpj, which looks up a different Brazilian identifier.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies when to use this tool: when you need to look up a Brazilian postal code. It doesn't explicitly state when not to use it or name alternatives, but the sibling tools (lookup_cnpj, list_banks, get_holidays) are clearly different in purpose, so the usage context is reasonably clear. The description could be stronger with an explicit exclusion, but the context is sufficient.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

lookup_cnpjA
Read-onlyIdempotent

Look up a Brazilian company (CNPJ) — legal name, address, status, and business activity.

Args: cnpj: CNPJ number, with or without formatting (e.g. "19131243000197" or "19.131.243/0001-97").

ParametersJSON Schema
NameRequiredDescriptionDefault
cnpjYes

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false, so the safety profile is clear. The description adds the expected data categories returned, but does not disclose behavior around invalid CNPJs, response structure, or external data source variability. This is adequate but not especially rich.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and well-structured: the first sentence states purpose and output, and the Args section precisely documents the sole input. There is no filler or redundant restatement of the tool name.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description compensates by listing the key returned fields and fully documenting the one required parameter. Annotations cover side effects and idempotency. Missing details like error behavior or exact response envelope are minor for a simple read-only lookup.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema property has 0% description coverage, so the description carries the full documentation burden. It does so well by specifying that the CNPJ may be formatted or unformatted and providing two concrete examples. This is nearly all an agent needs for a single string parameter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: 'Look up a Brazilian company (CNPJ)' and names the data returned (legal name, address, status, business activity). This clearly distinguishes it from siblings like lookup_cep, list_banks, and get_holidays without needing to open their schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The use case is implied strongly by 'Brazilian company (CNPJ)', but there is no explicit guidance about when to choose this tool over alternatives or when not to use it. Sibling tools exist, yet the description does not acknowledge them or provide selection criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 4 tool updatesv0.1.0
    • First observedget_holidays
    • First observedlist_banks
    • First observedlookup_cep
    • First observedlookup_cnpj

TDQS

A4/5.0

Scored across 4 tools

Disambiguation5/5

Each tool targets a completely distinct resource: companies (CNPJ), postal codes (CEP), banks, and holidays. There is no overlap in purpose or potential for misselection.

Naming Consistency3/5

Naming is readable and noun-focused, but verbs are inconsistent: 'lookup_' for two tools, then 'list_', and 'get_'. The pattern is not uniform, though the differences are minor and contextually acceptable.

Tool Count4/5

Four tools is slightly thin for a general Brazil data API but reasonable for a focused utility server. Each tool covers a meaningful public data lookup without redundancy.

Completeness2/5

The server covers a few common lookups but lacks many obvious BrasilAPI endpoints such as CPF (individual taxpayer), state/IBGE data, FIPE vehicle pricing, or DDD area codes. Agents needing these will hit dead ends.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables LLMs to query Brazilian public data such as CEP, CNPJ, DDD, exchange rates, banks, and holidays via the Model Context Protocol.
    12
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    MCP Server for accessing 36 Brazilian public data sources and 1 agent, enabling AI agents to query government data on economy, legislation, transparency, judiciary, elections, environment, health, and more.
    6
    MIT
  • A
    license
    A
    quality
    C
    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
    B
    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