MCP Brasil: Connecting AI to 41 Brazilian Public APIs

MCP Brasil: Connecting AI to 41 Brazilian Public APIs

7 min de leitura

Imagine being able to ask an AI agent “What were the 10 largest federal government contracts in 2024?” or “What is the trend of the Selic rate over the last 12 months?” and receive precise answers based on official Brazilian government data. This is now possible with MCP Brasil, an open-source project that connects AI agents like Claude, GPT, and GitHub Copilot to 41 Brazilian public APIs.

What is MCP Brasil?

MCP Brasil is a MCP Server (Model Context Protocol) that offers structured access to Brazilian government data through 326 tools, covering 11 thematic areas:

  • 📊 Economy and Finance: Central Bank, BNDES
  • 🏛️ Legislature: Chamber of Deputies, Federal Senate
  • 💰 Transparency: Portal da Transparência, TCU, 10 state TCEs
  • ⚖️ Judiciary: DataJud/CNJ, STF, STJ, TST
  • 🗳️ Electoral: TSE, Electoral Announcements (Meta)
  • 🌳 Environment: INPE (fires/deforestation), ANA
  • 🏥 Health: DataSUS, ANVISA, CNES, vaccination, Farmácia Popular
  • 🚨 Public Safety: Atlas da Violência, SINESP
  • 🏢 Public Procurement: PNCP, ComprasNet, TransfereGov
  • 📍 Geography: IBGE (states, municipalities, statistics)
  • 🛠️ Utilities: BrasilAPI (ZIP codes, CNPJ, banks), Official Gazettes

The best part? 38 of the 41 APIs require no access keys. The three that do (Portal da Transparência, DataJud, and Meta Ads) offer free registration in under 1 minute.

Testing in Practice

Let’s see MCP Brasil in action. I ran a simple test: asking for information about Google Brazil’s CNPJ.

Test 1: CNPJ Lookup

Question: “Find all information about CNPJ 06.990.590/0001-23”

MCP Brasil automatically:

  1. Queried BrasilAPI for complete registration data
  2. Searched PNCP for public contracts
  3. Checked TCU for federal contracts and irregularities
  4. Looked in DOU for related official publications
  5. Checked sanctions and administrative restrictions

Result in seconds:

📊 Information about CNPJ 06.990.590/0001-23

🏢 Registration Data

Company Name: GOOGLE BRASIL INTERNET LTDA.
CNPJ: 06.990.590/0001-23
Status: ✅ ACTIVE
Size: OTHER
Legal Nature: Limited Liability Company
Capital: R$ 200,000,000.00

Address:
BRIG FARIA LIMA, 3477 - FLOOR 17A20 TSUL 2 17A20
ITAIM BIBI - SÃO PAULO/SP
ZIP: 04538-133
Phone: (11) 2395-8400


📊 Economic Activity (CNAE)

Primary CNAE: 6319400 - Portals, Content Providers and Other Internet Information Services

Hierarchy:

  • Section J: Information and Communication
    • Division 63: Information Service Activities
      • Group 631: Data Processing, Internet Hosting

Main Activities:

  • Operation of Internet content portals
  • Operation of online social network platforms
  • Web search portal
  • Digital traffic management and measurement on the Internet
  • Online content distribution
  • + 17 other related activities

📄 Contracts and Public Procurement

Federal Contracts (Compras.gov.br): Not found
PNCP Contracts: None in the period
TCU Contracts: No records


📰 Publications in DOU

20 publications found in the last year (period consulted)


✅ Registration Status

Sanctions: None recorded
Restrictions: None identified
Tax Status: Regular

In a single query, MCP Brasil aggregated data from 5 different official sources automatically and structurally — work that would take hours to do manually by visiting each portal individually.

💊 Example 2: Medication Database Query

Let’s make a more complex query.

Question: “I want to know about dipyrone medications available in Brazil, compare generics with the reference brand, and check if they’re available for free at Farmácia Popular”

MCP Brasil automatically accesses 3 different health databases:

💊 Query: Dipyrone Medications in Brazil

📋 Medications Registered with ANVISA

Reference Medication:

  • Trade Name: NOVALGINA
  • Manufacturer: Sanofi-Aventis Farmacêutica Ltda
  • Active Ingredient: Sodium Dipyrone
  • Category: New (Reference)
  • ANVISA Registration: 1.7817.0296
  • Validity: Active

Available Generic Medications:

  1. SODIUM DIPYRONE - EMS S/A

    • Category: Generic
    • Registration: 1.0117.0534
    • Presentations: 500mg tablet, 500mg/mL drops, 1g/2mL injectable
  2. SODIUM DIPYRONE - Medley Farmacêutica Ltda

    • Category: Generic
    • Registration: 1.0235.0891
    • Presentations: 500mg tablet, 500mg/mL oral solution
  3. SODIUM DIPYRONE - Eurofarma Laboratórios S.A

    • Category: Generic
    • Registration: 1.0443.0123
    • Presentations: 500mg tablet, 1g tablet, drops

Total: 47 medications found with dipyrone registered with ANVISA


🏥 SUS Availability

RENAME (National List of Essential Medicines):

Sodium Dipyrone is on RENAME

  • Pharmaceutical Form: 500 mg/mL oral solution
  • Pharmaceutical Form: 500 mg tablet
  • Pharmaceutical Form: 500 mg/mL injectable solution
  • Therapeutic Indication: Analgesic and antipyretic
  • Component: Basic Pharmaceutical Care

Status: Must be available at all basic health units in Brazil


Available FREE through the Farmácia Popular Program

  • Medication: Sodium Dipyrone 500mg
  • Free Presentations:
    • 500mg tablet (box of 10 tablets)
    • 500mg/mL oral drops solution (10mL or 20mL bottle)
  • Cost: R$ 0.00 (100% free since February 2023)
  • Indication: Fever and pain

How to Get It:

  1. Present photo ID
  2. Present valid medical prescription (up to 120 days)
  3. Find a pharmacy accredited to the program

More than 30,000 accredited pharmacies throughout Brazil


📊 Analysis Summary

Aspect Information
Registered medications 47 options available
Generics available Yes (various laboratories)
Price difference Generics cost 40-60% less than reference
Available in SUS ✅ Yes (RENAME)
Farmácia Popular ✅ Free
Package insert available Yes (query via process number)

In this second example, MCP Brasil crossed 3 different databases:

  • ANVISA (Electronic Package Insert): Sanitary registrations and categories
  • RENAME: Official list of essential SUS medications
  • Farmácia Popular: Free availability and accredited pharmacies

This ability to cross-reference information from multiple specialized sources makes complex analyses trivial.


Cross-Reference Capabilities

What makes MCP Brasil especially powerful is its query planning capability with the plan_query tool. It analyzes complex questions and creates an execution plan combining multiple APIs.

Examples of questions MCP Brasil can answer:

  1. Legislature + Transparency:
    “Which deputies voted in favor of Bill X and what are their office expenses in 2024?”

  2. Economy + Comparison:
    “Compare the Selic rate with IPCA over the last 24 months”

  3. Health + Geography:
    “How many ICU beds are there per 100,000 inhabitants in each northeastern capital?”

  4. Transparency + Electoral:
    “Which companies received the most federal contracts and what is their campaign donation history?”

  5. Environment + Temporal:
    “Show the evolution of deforestation in the Amazon over the last 5 years using PRODES/INPE data”

Smart Architecture

MCP Brasil uses a Package by Feature architecture with auto-registration. Each API is a self-contained feature:

src/mcp_brasil/
├── data/
│   ├── ibge/           # 9 tools
│   ├── bacen/          # 9 tools  
│   ├── camara/         # 11 tools
│   ├── anvisa/         # 10 tools
│   └── ...             # 37 other features
└── agents/
    └── writer/         # Document generation

Advanced features:

  • Smart Discovery: BM25 search automatically filters the 326 tools to show only those relevant to the context
  • Batch Execution: run_batch fires queries in parallel in a single call
  • Async Everywhere: httpx async + rate limiting with exponential backoff
  • Zero Config: adding a feature is just creating a folder — no manual configuration

How to Use

Installation

1
2
3
pip install mcp-brasil
# or
uv add mcp-brasil

Configuration in VS Code/Cursor

Create .vscode/mcp.json in your project root:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
{
    "servers": {
        "mcp-brasil": {
            "command": "python",
            "args": ["-m", "mcp_brasil.server"],
            "env": {
                "TRANSPARENCIA_API_KEY": "your-key-here",
                "DATAJUD_API_KEY": "your-key-here",
                "META_ACCESS_TOKEN": "your-token-here"
            }
        }
    }
}

Note: The keys are optional. Without them, 38 APIs still work normally.

Configuration in Claude Desktop

Add to claude_desktop_config.json:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
{
    "mcpServers": {
        "mcp-brasil": {
            "command": "uvx",
            "args": ["--from", "mcp-brasil", "python", "-m", "mcp_brasil.server"],
            "env": {
                "TRANSPARENCIA_API_KEY": "your-key-here",
                "DATAJUD_API_KEY": "your-key-here",
                "META_ACCESS_TOKEN": "your-token-here"
            }
        }
    }
}

HTTP Mode (other clients)

1
2
fastmcp run mcp_brasil.server:mcp --transport http --port 8000
# Server available at http://localhost:8000/mcp

Real Use Cases

1. Data Journalism

Cross-referencing Portal da Transparência data with TSE campaign finance reports to investigate relationships between public contracts and campaign funding.

2. Academic Research

Analyzing vaccination trends (SI-PNI) correlated with IBGE socioeconomic data.

3. Market Analysis

Tracking Central Bank time series (Selic, exchange rate, GDP) for financial modeling.

4. Compliance and Due Diligence

Automatically checking whether suppliers have TCU sanctions, are on CEIS lists, or are in restrictive registers.

5. Legislative Monitoring

Tracking specific bills through the Chamber and Senate with automatic alerts.

6. Public Health Auditing

Cross-referencing health facility data (CNES) with medication registrations (ANVISA) and audits (DENASUS).

Performance and Limitations

During my tests, MCP Brasil demonstrated:

✅ Strengths:

  • Responses in seconds for simple queries
  • Excellent rate limit handling with automatic backoff
  • Intelligent aggregation of multiple sources
  • Graceful fallback when APIs are unavailable

⚠️ Considerations:

  • Some government APIs have inconsistent documentation
  • Rate limits vary by API (generally 60-100 req/min)
  • Data may have update delays (varies by source)
  • 3 APIs require free registration (but very simple)

Conclusion

MCP Brasil represents a significant advance in democratizing access to Brazilian public data. By connecting AI agents to 41 government APIs, it transforms complex queries that would take hours into instant answers.

If you work with data analysis, investigative journalism, academic research, or simply want to explore Brazilian public data more efficiently, MCP Brasil is an essential tool.

The project is constantly evolving, and the open-source community continues adding new features. It’s well worth experimenting with — and perhaps contributing new integrations.