█

AI/TLDR

Buy me a coffee
Buy me a coffee

mcp-brasil

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

RAG Frameworks & PlatformsOpen source
Latest
v0.14.0
Updated
24 Apr 2026
Language
Python
License
MIT
$pip install mcp-brasil

What's new

v0.14.024 Apr 2026

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).

IN SHORT

What is mcp-brasil?

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.

Updated Markdown version ↗

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.

System diagram: an MCP client calls the mcp-brasil root FastMCP server, whose FeatureRegistry and meta-tools route to feature groups (economic, legislative, judicial, electoral, audit, environment and health, other, agents) that each call government APIs.
The project's system overview: one root server, a feature registry and meta-tools, and per-area features that call the government APIs.mcp-brasil docs ↗

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`
Data-flow diagram: a user question goes to the MCP client, through the BM25 filter to the top tools, then from tools.py to the async client and rate limiter out to a government API, with the JSON response returned as Markdown.
How a request travels: BM25 tool filtering, the async HTTP client and rate limiter, and the formatted answer back to the client.mcp-brasil architecture docs ↗
  • 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.

Install the package

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

bashbash
pip install mcp-brasil
# or
uv add mcp-brasil

Add it to Claude Code

One command registers the server with Claude Code.

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

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.

jsonjson
{
  "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"
      }
    }
  }
}

Or run it over HTTP for other clients

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

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

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`.

bashbash
# .env
MCP_BRASIL_DATASETS=tse_candidatos,tse_bens,tse_votacao

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).

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

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

How mcp-brasil compares

mcp-brasil alongside other open-source rag frameworks & platforms tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Dify★ 162kAn open-source platform with a visual workflow builder for creating LLM and RAG applications without writing much code.
graphify★ 155kTurns a folder of code, docs, PDFs and images into a local knowledge graph with tree-sitter AST parsing and Leiden communities — queryable by agents over MCP, no vector store.
RAGFlow★ 95kA RAG engine built around deep document understanding that turns complex files into a grounded, citation-backed question-answering layer.
Context7★ 65.7kContext7 pulls current, version-specific documentation and code examples for any library and feeds them into your LLM, available as a CLI skill or an MCP server.
Pathway★ 61.9kA Python framework with a Rust streaming engine that keeps ETL, real-time analytics and RAG pipelines continuously up to date as source data changes.
LightRAG★ 41kA graph-based RAG system that builds an entity-and-relationship knowledge graph for fast retrieval and easy incremental updates.
PageIndex★ 40.8kPageIndex turns long PDFs into a table-of-contents tree and uses LLM reasoning to retrieve relevant sections, with no vector database and no chunking.
mcp-brasil★ 1.9kBrazilian government and public data for any MCP client, from the Central Bank to the electoral court