I Extended the Trending mcp-brasil Project with AI Generation — Full Tutorial

Dev.to / 3/27/2026

💬 OpinionDeveloper Stack & InfrastructureTools & Practical UsageModels & Research

Key Points

  • The tutorial shows how to extend the popular mcp-brasil MCP server—connecting AI agents to 28 Brazilian public APIs—by adding AI-driven content generation on top of government and public datasets.
  • It explains what mcp-brasil covers (legislative, economic, transparency, judiciary, electoral, environmental, and health) and how many of its API tools can be used without an API key.
  • The guide integrates NexaAPI to generate images, videos, and Portuguese audio summaries using 56+ AI models, positioning the setup as a low-cost way to turn raw data into media.
  • It provides step-by-step Python installation and an example workflow (e.g., IBGE data converted into an AI infographic) to demonstrate end-to-end usage of mcp-brasil + NexaAPI.
  • The article is framed as a practical “how-to” for developers to operationalize AI visualization and narration from public Brazilian data via MCP-compatible agents.

Have you seen mcp-brasil? It just blew up on GitHub with 400+ stars in days! 🇧🇷

This incredible project by @jxnxts provides an MCP (Model Context Protocol) server that connects AI agents like Claude, GPT, and Copilot to 28 Brazilian public APIs — covering everything from legislative data to environmental monitoring.

But here's what I thought: what if we could take this Brazilian government data and generate AI visualizations, infographics, and Portuguese audio summaries from it?

That's exactly what I built using NexaAPI — the cheapest AI inference API at just $0.003/image.

What is mcp-brasil?

mcp-brasil is a Python MCP server that gives AI agents access to:

  • 🏛️ Legislative: Câmara dos Deputados (213 tools!), Senado Federal
  • 💰 Economic: IBGE statistics, Banco Central (Selic, IPCA, exchange rates)
  • 🔍 Transparency: Portal da Transparência, TCU, 8 state TCEs
  • ⚖️ Judiciary: DataJud/CNJ, STF, STJ, TST decisions
  • 🗳️ Electoral: TSE (candidates, donations, results)
  • 🌿 Environmental: INPE (fires, deforestation), ANA (hydrology)
  • 🏥 Health: CNES/DataSUS

26 APIs require no key. Just install and use:

pip install mcp-brasil

What I Added: AI Generation via NexaAPI

NexaAPI gives you access to 56+ AI models:

  • Image generation: Flux, DALL-E, Stable Diffusion, Gemini Image, GPT Image
  • Video generation: Kling, Veo, Runway, Sora alternatives
  • Audio/TTS: ElevenLabs-quality voices, including Portuguese
  • LLMs: Claude, GPT-4, Gemini, Qwen, and more

All at $0.003/image — 85% cheaper than OpenAI.

Python Tutorial: mcp-brasil + NexaAPI

Install

pip install nexaapi requests

Get your free API key at nexa-api.com — no credit card needed.

Example 1: IBGE Data → AI Infographic

from nexaapi import NexaAPI
import requests

client = NexaAPI(api_key='your_api_key_here')

# Fetch Brazilian states from IBGE
ibge_response = requests.get(
    'https://servicodados.ibge.gov.br/api/v1/localidades/estados'
)
states = ibge_response.json()
state_names = [s['nome'] for s in states[:5]]
print(f'Fetched {len(states)} Brazilian states from IBGE')

# Generate AI infographic with NexaAPI
prompt = f'Professional infographic map of Brazil highlighting states: {", ".join(state_names)}, modern data visualization, vibrant colors'

result = client.image.generate(
    model='flux-schnell',
    prompt=prompt,
    width=1024,
    height=768
)

print(f'AI infographic generated! Cost: ~$0.003')
print(f'Image URL: {result.image_url}')

Example 2: Banco Central → Economic Chart + Portuguese Audio

from nexaapi import NexaAPI
import requests

client = NexaAPI(api_key='your_api_key_here')

# Fetch Selic rate from Banco Central
selic_response = requests.get(
    'https://api.bcb.gov.br/dados/serie/bcdata.sgs.11/dados/ultimos/1?formato=json'
)
selic_data = selic_response.json()
latest_selic = selic_data[0]['valor']
print(f'Current Selic rate: {latest_selic}%')

# Generate economic visualization
image_result = client.image.generate(
    model='flux-schnell',
    prompt=f'Bloomberg-style economic dashboard showing Brazil Selic rate at {latest_selic}%, dark theme, professional financial chart',
    width=1280,
    height=720
)

# Generate Portuguese TTS audio summary
audio_result = client.audio.tts(
    text=f'Taxa Selic atual: {latest_selic} por cento ao ano. Dados do Banco Central do Brasil.',
    voice='nova',
    language='pt-BR'
)

print(f'Chart: {image_result.image_url}')
print('Portuguese audio summary generated!')

Example 3: Environmental Data → Alert Visualization

from nexaapi import NexaAPI
import requests

client = NexaAPI(api_key='your_api_key_here')

# Generate environmental monitoring visualization
alert_result = client.image.generate(
    model='flux-schnell',
    prompt='Satellite view of Amazon rainforest with fire alert hotspots, environmental monitoring dashboard, Brazil, aerial photography',
    width=1024,
    height=768
)

print(f'Environmental alert: {alert_result.image_url}')
print('Cost: $0.003 — cheaper than any other AI API!')

JavaScript Tutorial

// npm install nexaapi axios
import NexaAPI from 'nexaapi';
import axios from 'axios';

const client = new NexaAPI({ apiKey: 'your_api_key_here' });

async function brazilAIIntegration() {
  // Fetch cities from BrasilAPI
  const response = await axios.get('https://brasilapi.com.br/api/ibge/municipios/v1/SP');
  const cities = response.data.slice(0, 5).map(c => c.nome);

  // Generate AI visualization
  const imageResult = await client.image.generate({
    model: 'flux-schnell',
    prompt: `Beautiful aerial view of São Paulo cities: ${cities.join(', ')}, Brazil, photorealistic`,
    width: 1024,
    height: 768
  });

  console.log('Image URL:', imageResult.imageUrl);
  console.log('Cost: $0.003');

  // Generate Portuguese TTS
  const audioResult = await client.audio.tts({
    text: `Cidades de São Paulo: ${cities.join(', ')}. Explore o Brasil com inteligência artificial.`,
    voice: 'nova',
    language: 'pt-BR'
  });

  console.log('Portuguese audio:', audioResult.audioUrl);
}

brazilAIIntegration();

Pricing Comparison

Provider Price/Image Free Tier Models
NexaAPI $0.003 ✅ Yes 56+
OpenAI DALL-E $0.020 ❌ No 3
Replicate $0.008-0.05 ❌ No Many
FAL.ai $0.005-0.02 ❌ No Many

NexaAPI is 85% cheaper than OpenAI and supports the most models.

The Power of Combining mcp-brasil + NexaAPI

With mcp-brasil's 213 tools and NexaAPI's 56+ AI models, you can build:

  • 📊 Automated infographics from Brazilian government data
  • 🎙️ Portuguese audio reports from economic statistics
  • 🗺️ AI-generated maps from geographic data
  • 📹 Video summaries of legislative sessions
  • 🔔 Visual alerts from environmental monitoring data

The possibilities are endless — and at $0.003/image, the cost is negligible.

Get Started

  1. Star mcp-brasil
  2. Get your free NexaAPI key at nexa-api.com
  3. Install: pip install nexaapi requests
  4. Check out the full code examples on GitHub

Links

Which Brazilian API integration would you build first? Drop your ideas in the comments! 👇

Try NexaAPI free — no credit card needed: nexa-api.com