# Brasil.io MCP

> Brasil.io provides direct access to structured public data from Brazil's government records. Your AI agent connects and lets you query datasets—including COVID-19 stats, corporate filings, and socio-economic reports—using plain language. This MCP turns massive amounts of raw Brazilian intelligence into usable facts for your report or research.

## Overview
- **Category:** data-analytics
- **Price:** Free
- **Tags:** brazil-data, public-datasets, open-data, transparency, statistics

## Description

Stop wrestling with confusing government transparency portals or manually downloading dozens of CSV files just to find one figure. This connection lets you talk directly to Brazil's public data records and get structured answers back. You can ask complex questions—like 'What were the confirmed cases in Curitiba, PR, during March 2023?'—and your agent handles the filtering and retrieval. It’s like having a dedicated data scientist who only knows Brazilian municipal codes, right inside your workflow. This capability is available through Vinkius's catalog, letting you access this power from any MCP-compatible client. Whether you need to check historical salary figures or track regional health trends, this MCP makes the process conversational and reliable.

## Tools

### list_datasets
Lists all available public datasets hosted on Brasil.io so you can see what kind of data is accessible.

### query_table_data
Queries and retrieves actual records from a specified table using structured filters like state or city name.

### get_table_metadata
Retrieves the column names and data types for a specific table, letting you know exactly how to filter your query.

## Prompt Examples

**Prompt:** 
```
List all available datasets on Brasil.io.
```

**Response:** 
```
I've retrieved the available datasets. You can access data on 'covid19', 'salarios-magistrados', 'socios-brasil', and more. Which one would you like to explore?
```

**Prompt:** 
```
Show me the metadata for the 'caso' table in the 'covid19' dataset.
```

**Response:** 
```
The 'caso' table in the 'covid19' dataset contains fields such as 'date', 'state', 'city', 'confirmed', 'deaths', and 'is_last'. It tracks daily COVID-19 reports by municipality.
```

**Prompt:** 
```
Query the 'caso' table in 'covid19' for the state of 'PR' and city 'Curitiba'.
```

**Response:** 
```
I found the latest records for Curitiba, PR. On 2023-03-20, there were X confirmed cases and Y deaths. Would you like to see previous dates?
```

## Capabilities

### Discover all public data sources
List every available dataset on the Brasil.io platform so you know exactly what records are out there.

### Inspect table schemas and columns
Fetch detailed metadata for any specific dataset to confirm which fields, dates, or states are tracked.

### Query data by filters (state, date)
Retrieve actual records from a specific table, applying complex filters like state codes or city names in one go.

## Use Cases

### Comparing regional health trends
A public health analyst needs to compare COVID-19 data between Rio de Janeiro and São Paulo. They ask the agent, which uses `query_table_data`, filtering by both states' codes and specifying date ranges. The result is a clean, comparative dataset ready for charting.

### Verifying corporate history
A journalist investigating market shifts needs to know if a company filed specific documents in the last five years. They first use `list_datasets` to find the correct record type and then query it using `query_table_data` filtered by date range.

### Academic research on demographics
A researcher is compiling a paper on salary disparities across Brazilian states. They use `list_datasets` to find the relevant payroll data, then run multiple calls with `query_table_data`, iterating through different states and using pagination to cover all available records.

### Quick fact-checking for a report
A business developer needs the confirmed case count in Curitiba on a specific date. They simply ask their agent, which uses `query_table_data` with precise filters, and get the exact number without needing to navigate complex web forms.

## Benefits

- Saves hours of manual work by eliminating the need to download and reconcile disparate CSV files from various government portals.
- Use `list_datasets` first. You can immediately see if a dataset you need—like 'covid19' or 'salarios-magistrados'—is available before writing a single query.
- The `get_table_metadata` tool lets you check the schema instantly. This means you know exactly what column name to filter on, avoiding guesswork when querying data.
- `query_table_data` handles complex filtering (by state, city, date) using simple JSON input, making your requests precise and repeatable.
- Pagination support ensures that even massive datasets are manageable; you can walk through millions of records without hitting a limit.

## How It Works

The bottom line is that your AI client handles all the API calls; you just ask questions like talking to a human analyst.

1. First, subscribe to this MCP and provide your Brasil.io API token.
2. Next, ask your AI agent a question—for example, 'Show me the metadata for the COVID-19 table' or 'What were the deaths in PR last month?'.
3. The agent uses the tools to fetch and filter the records, presenting you with clean data directly in the chat.

## Frequently Asked Questions

**How can I filter data for a specific state or city?**
Use the `query_table_data` tool and provide a JSON string in the `filters` parameter, such as `{"state": "SP", "city": "São Paulo"}`. The agent will apply these filters to the Brasil.io API request.

**How do I find out what columns are available in a dataset?**
First, use `list_datasets` to find the slug of the dataset. Then, use `get_table_metadata` with the dataset and table slugs to see the full list of available fields and their descriptions.

**Can I navigate through large amounts of data?**
Yes. Both `list_datasets` and `query_table_data` support `page` and `page_size` parameters, allowing you to iterate through results without overloading the response.

**How do I use `list_datasets` if I forget my Brasil.io API Token?**
You must provide your valid API token during initial setup. Without it, the agent can't authenticate or access any public datasets for listing or querying.

**What is the best workflow when I want to analyze complex socio-economic data using this MCP?**
Start by running `list_datasets` to identify the right domain. Next, use `get_table_metadata` on that dataset to confirm all available columns before you attempt any queries.

**What should I do if my JSON filter for `query_table_data` returns an error?**
The error usually means your filter syntax or data type is wrong. Run `get_table_metadata` first to check the exact column names and required formats.

**Does `query_table_data` handle high volumes of records efficiently?**
Yes, it includes pagination support built in. This lets you pull massive datasets in controlled chunks, keeping your queries stable and efficient.

**How do I verify if a specific dataset, like company records, is available?**
First, run `list_datasets` to see all hosted domains. If the topic appears, use `get_table_metadata` on that dataset's table name for specifics.