DEV Community

diwushennian4955
diwushennian4955

Posted on • Originally published at nexa-api.com

I Extended the Trending mcp-brasil Project with AI Generation β€” Full Tutorial

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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}')
Enter fullscreen mode Exit fullscreen mode

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!')
Enter fullscreen mode Exit fullscreen mode

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!')
Enter fullscreen mode Exit fullscreen mode

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();
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)