# mcp-brasil

> Brazilian government and public data for any MCP client, from the Central Bank to the electoral court

- Category: Retrieval & Knowledge (RAG) / RAG Frameworks & Platforms
- Language: Python
- Licence: MIT
- Repository: https://github.com/Mcp-Brasil/mcp-brasil
- Canonical page: https://ai-tldr.dev/tools/mcp-brasil/
- Updated: 2026-04-24

## In short

mcp-brasil is an open-source MCP server, written in Python, that connects AI agents such as Claude, GPT and Copilot to Brazilian government and public data. It sits in the RAG Frameworks & Platforms category of the Retrieval & Knowledge (RAG) tools and is open-source, written in Python and licensed MIT.

## Overview

mcp-brasil is an open-source MCP server, written in Python, that connects AI agents such as Claude, GPT and Copilot to Brazilian government and public data. Its README counts 70 data sources across 15 thematic areas, exposed as 533 tools plus resources and prompts: economy and finance, legislation, transparency and audit courts, the judiciary, elections, environment, health, education, public security, public procurement, subnational public finance, aviation and energy. Most of the APIs need no key; a handful (Portal da Transparência, DataJud/CNJ, the Meta Ad Library and brapi.dev for B3 quotes) take free keys or tokens and are skipped when no key is set.

Each data source is a self-contained "feature" folder that the server discovers on start-up, so adding an API means adding a folder. Three kinds of feature sit side by side: REST passthroughs that call a government API over async httpx and return Pydantic-validated, formatted answers; opt-in local datasets that download large CSV or ZIP files (TSE elections 2014-2024, ANP fuel prices, INEP school census and ENEM microdata, SPU federal property, ANAC aircraft and flights, CVM investment funds) into an embedded DuckDB and query them with SQL; and agent features such as an official-writing assistant. The root server adds meta-tools to list features, recommend tools, plan cross-source queries and run calls in parallel, and by default a BM25 search filter shows the model only the tools relevant to the question instead of all of them.

The project is independent and states plainly that it is not an official service of the Brazilian government or of any institution whose data it reaches. The MIT licence covers the code only; each source keeps its own licence, listed in the repository's SOURCES.md, and use of the server is subject to its Acceptable Use Policy. The README also warns that models consuming the server can still misread or distort answers, so results should be checked against the official source before journalistic, legal, medical or decision-making use.

## What it does

- Coverage of Brazilian public data sources including Banco Central (Selic, IPCA, PTAX, Focus expectations), IBGE, IPEADATA, BNDES, the Câmara and Senado, Portal da Transparência, TCU and state audit courts (TCEs), SICONFI, DataJud and STF/STJ/TST case law, TSE, INPE, ANA, IBAMA, ANEEL, ANTT, DataSUS, ANVISA, INEP, FNDE, PNCP/ComprasNet, BrasilAPI, dados.gov.br and official gazettes
- Opt-in local datasets, enabled through `MCP_BRASIL_DATASETS`, that cache large public files in an embedded DuckDB and answer with SQL: TSE candidates, declared assets, votes and campaign funds, ANP fuel prices, INEP school census and ENEM, ISP-RJ crime statistics, ANAC aircraft registry and CVM funds
- Cross-source planning with `planejar_consulta` (for example a deputy's expenses plus votes plus bills) and parallel batch execution with `executar_lote`
- Smart tool discovery: a BM25 search transform (the default `MCP_BRASIL_TOOL_SEARCH` mode) narrows the large tool list to the ones relevant to the context, with `code_mode` and `none` as alternatives
- Auto-registry architecture where each feature is a folder with its own server, tools, async client and Pydantic schemas, with retry, backoff and rate limiting shared across features
- Runs over stdio in Claude Desktop, Claude Code, VS Code, Cursor and Google Antigravity, or as an HTTP server through FastMCP for other clients

## Getting started

mcp-brasil is published on PyPI. Most clients launch it with `uvx`, so you only need to add a config block; API keys are optional and only unlock the few sources that require them.

1. Install the package

   Install with pip, or add it to a uv-managed project.

```bash
pip install mcp-brasil
# or
uv add mcp-brasil
```

2. Add it to Claude Code

   One command registers the server with Claude Code.

```bash
claude mcp add mcp-brasil -- uvx --from mcp-brasil python -m mcp_brasil.server
```

3. Or add it to Claude Desktop, VS Code or Cursor

   Put this block in `claude_desktop_config.json` (Claude Desktop) or Antigravity's `mcp_config.json`. For VS Code and Cursor, create `.vscode/mcp.json` with the same entry under a `servers` key instead of `mcpServers`. The `env` keys are optional; without them the keyless sources still work.

```json
{
  "mcpServers": {
    "mcp-brasil": {
      "command": "uvx",
      "args": ["--from", "mcp-brasil", "python", "-m", "mcp_brasil.server"],
      "env": {
        "TRANSPARENCIA_API_KEY": "your-key",
        "DATAJUD_API_KEY": "your-key",
        "META_ACCESS_TOKEN": "your-token"
      }
    }
  }
}
```

4. Or run it over HTTP for other clients

   FastMCP serves the same server over HTTP; it is then available at http://localhost:8000/mcp.

```bash
fastmcp run mcp_brasil.server:mcp --transport http --port 8000
```

5. Optionally enable the local datasets

   Large datasets are off by default. List the ones you want in `MCP_BRASIL_DATASETS` (in the environment or a `.env` file). The first load downloads and ingests the files into DuckDB and can take minutes; later queries hit the local cache, by default under `~/.cache/mcp-brasil`.

```bash
# .env
MCP_BRASIL_DATASETS=tse_candidatos,tse_bens,tse_votacao
```

6. Ask questions in plain language

   Once connected, ask the client things like: "What has the trend of the Selic rate been over the last 12 months? Compare it with IPCA inflation over the same period", or "What are the 10 largest federal government contracts in 2024, and who are the suppliers?" (the README's examples are in Portuguese).

## When to use it

- Let an assistant answer questions about Brazilian macroeconomics, legislation or public spending from the official APIs instead of from memory
- Cross-reference sources in one request, such as a deputy's expenses with their votes and bills, or state health spending with IBGE population data
- Run SQL over large electoral, education, fuel-price or federal-property datasets locally for data journalism and civic research
- Give a government-transparency or public-procurement analysis workflow a single MCP endpoint for contracts, tenders, sanctions and audit-court records

## Version history

- 2026-04-24 v0.14.0: Added the local DuckDB dataset cache infrastructure, with the SPU SIAPA federal-property dataset and multi-year TSE electoral datasets (candidates, declared assets, social networks and campaign funds).
