Skip to main content

Model Context Protocol server for Base dos Dados (Brazilian open data platform)

Project description

Base dos Dados MCP Server

Smithery

A Model Context Protocol (MCP) server that provides AI-optimized access to Base dos Dados, Brazil's largest open data platform. Features intelligent search, Portuguese language support, and comprehensive dataset exploration capabilities.

✨ Features

  • 🔍 Smart Search: Portuguese language support with accent normalization
  • 🤖 AI-Optimized: Single-call comprehensive data retrieval
  • 📊 BigQuery Integration: Ready-to-use SQL generation with table references
  • 🇧🇷 Brazilian Data Focus: Specialized for Brazilian public datasets (IBGE, RAIS, TSE, etc.)
  • ⚡ Efficient: Intelligent ranking and acronym prioritization
  • 📖 Comprehensive: Dataset overviews, table details, and usage guidance

🚀 Installation

Via PyPI (Recommended)

Install directly from PyPI:

# Install with pip
pip install basedosdados-mcp

# Or with uv (faster)
uv add basedosdados-mcp

Claude Desktop Configuration:

{
  "mcpServers": {
    "basedosdados": {
      "command": "basedosdados-mcp"
    }
  }
}

Via Smithery (Alternative)

Install from Smithery MCP Registry:

# Using Smithery CLI
npx @smithery/cli install basedosdados-mcp

Manual Installation (Development)

  1. Clone and install:

    git clone https://github.com/joaoc/basedosdados_mcp
    cd basedosdados_mcp
    uv sync
    
  2. Run the server:

    # Production mode
    uv run basedosdados-mcp
    
    # Development mode (with debug logging)
    uv run basedosdados-mcp-dev
    
    # Using the wrapper script
    ./run_server.sh
    
  3. Configure Claude Desktop:

    {
      "mcpServers": {
        "basedosdados": {
          "command": "/path/to/basedosdados_mcp/run_server.sh"
        }
      }
    }
    

Docker

# Pull from Docker Hub
docker pull joaoc/basedosdados-mcp

# Or build locally
docker build -t basedosdados-mcp .

# Run the container
docker run --rm basedosdados-mcp

🛠️ Available Tools

Core Tools

Tool Description Example
search_datasets Smart search with Portuguese accent normalization search_datasets(query="população", limit=10)
get_dataset_overview Complete dataset view with all tables get_dataset_overview(dataset_id="DatasetNode:abc123")
get_table_details Comprehensive table info with SQL samples get_table_details(table_id="TableNode:xyz789")

💡 Usage Examples

Search for Brazilian Demographics Data

# Search with Portuguese (works with/without accents)
search_datasets(query="população brasileira")
search_datasets(query="IBGE demografico")

Explore Dataset Structure

# Get complete overview of a dataset (use dataset ID from search results)
get_dataset_overview(dataset_id="DatasetNode:br_ibge_populacao_id")

# Get detailed table information with sample SQL (use table ID from overview)
get_table_details(table_id="TableNode:municipio_id")

🧠 Key Features

Portuguese Language Intelligence

  • Accent Normalization: populacaopopulação, educacaoeducação
  • Acronym Recognition: IBGE, RAIS, TSE, INEP get priority ranking
  • Smart Fallbacks: Multiple search strategies for robust results

AI-Optimized Design

  • Single-Call Efficiency: Comprehensive information without multiple API calls
  • Structured Responses: Consistent formatting for LLM consumption
  • Ready-to-Use SQL: Direct BigQuery paths like basedosdados.br_ibge_populacao.municipio
  • Context-Aware Guidance: Next-step instructions included in responses

Brazilian Data Expertise

  • Government Sources: IBGE (Census), TSE (Elections), RAIS (Employment)
  • Education Data: INEP, higher education, school census
  • Economic Indicators: Central Bank, ministries, regional data
  • Health & Demographics: SUS, population statistics, vital records

🔧 Local Development & Testing

Setup

# Clone and install
git clone https://github.com/joaoc/basedosdados_mcp
cd basedosdados_mcp
uv sync

Testing with Claude Desktop

1. Quick Test (Recommended)

Use the wrapper script for easy Claude Desktop integration:

// Add to your claude_desktop_config.json
{
  "mcpServers": {
    "basedosdados": {
      "command": "/path/to/basedosdados_mcp/run_server.sh"
    }
  }
}

2. Direct Command (Alternative)

// Add to your claude_desktop_config.json
{
  "mcpServers": {
    "basedosdados": {
      "command": "uv",
      "args": ["run", "basedosdados-mcp-dev"],
      "cwd": "/path/to/basedosdados_mcp"
    }
  }
}

3. Testing the Server

# Test server startup (development mode)
uv run basedosdados-mcp-dev

# Test server startup (production mode)  
uv run basedosdados-mcp

# Test with wrapper script
./run_server.sh

Troubleshooting Claude Desktop Integration

Common Issues:

  • Server won't start: Check that uv sync completed successfully
  • Tools not available: Verify the cwd path in your config is correct
  • Connection errors: Check Claude Desktop logs at ~/Library/Logs/Claude/

Debug Logging: The wrapper script (run_server.sh) includes debug output to stderr. Check Claude Desktop logs for startup messages.

Manual Testing

# Test tool functionality directly
uv run python -c "
import asyncio
from src.basedosdados_mcp.server import search_datasets
async def test():
    result = await search_datasets('ibge', limit=2)
    print('✅ Search works!')
    print(result[:200] + '...')
asyncio.run(test())
"

Docker Support

# Build container
docker build -t basedosdados-mcp .

# Run container
docker run --rm basedosdados-mcp

📚 About Base dos Dados

Base dos Dados is Brazil's largest open data platform, providing standardized access to Brazilian public datasets through BigQuery. This MCP server bridges the gap between AI assistants and Brazil's rich public data ecosystem.

Data Coverage

  • Demographics: Population, census, vital statistics
  • Economics: GDP, employment, trade, inflation
  • Education: School performance, enrollment, infrastructure
  • Politics: Elections, candidates, campaign finance
  • Health: Hospital data, epidemiology, healthcare infrastructure
  • Environment: Climate, deforestation, water resources

📄 License

MIT License - see LICENSE for details.

🤝 Contributing

Contributions welcome! Please see our contributing guidelines for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

basedosdados_mcp-0.1.0.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

basedosdados_mcp-0.1.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file basedosdados_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: basedosdados_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.14

File hashes

Hashes for basedosdados_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 84bfbe2fad0380574ef517aad7118dfa73a4da36e7adec1cbff05c409ceaa0be
MD5 1b9b3082971ccc17669e0f65a21a9df1
BLAKE2b-256 cd624d01af9dac516df5b35807c1112a664d78d073f3232f0689999cb84ce2bb

See more details on using hashes here.

File details

Details for the file basedosdados_mcp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for basedosdados_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46437f60c4f23e2f72d7016805411723bd8cc90ed2956d1f1f308e64b8993980
MD5 2c7e80d1a0bcd62e1bb8d76985df7564
BLAKE2b-256 977e5d9b858373c9b043d31d53142405cb43ffc08a07ab286459dde94d0fd607

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page