# ANEEL Dados Abertos MCP

> ANEEL Dados Abertos connects your agent directly to the Brazilian National Electric Energy Agency's public data portal. Use it to list available energy datasets, inspect metadata for specific packages, get details on downloadable resources like CSV or PDF files, and query records across integrated electricity market datastores.

## Overview
- **Category:** data-analytics
- **Price:** Free
- **Tags:** electricity, brazil, energy-data, public-records, aneel

## Description

This MCP lets you programmatically interrogate the massive dataset of Brazil’s electricity sector. Instead of clicking through dozens of web forms and manual dashboards to find tariff schedules or generation metrics, your agent handles the navigation. You start by listing all available data packages in the ANEEL portal; once you pinpoint a dataset, you can fetch its full metadata to understand what's included. The system then allows you to drill down further, getting specific details about resources like download URLs for CSV files or PDFs. If you know the target resource and need an answer—say, 'How did tariffs change in São Paulo last quarter?'—the agent runs a direct query against the data records. You'll connect this whole workflow through Vinkius, routing complex queries to your preferred AI client.

## Tools

### get_package
Fetches full metadata for a single, specified ANEEL dataset package.

### get_resource
Gets file metadata (like format and download URL) for a specific resource within a dataset.

### list_packages
Retrieves the names of all datasets available across the entire ANEEL portal.

### search_datastore
Executes a targeted search for records within an integrated ANEEL data resource.

## Prompt Examples

**Prompt:** 
```
List all available datasets in the ANEEL portal.
```

**Response:** 
```
I've retrieved the list of packages. There are several datasets available, including 'tarifas-distribuidoras', 'geracao-distribuida', and 'interrupcoes-energia'. Which one would you like to explore?
```

**Prompt:** 
```
Show me the resources available for the 'tarifas-distribuidoras' package.
```

**Response:** 
```
The 'tarifas-distribuidoras' package contains 3 resources: a CSV file with current rates (ID: res-123), a PDF manual (ID: res-456), and a historical XLS file (ID: res-789).
```

**Prompt:** 
```
Search for records related to 'ENEL' in the resource with ID 'd345-f678'.
```

**Response:** 
```
Searching the datastore... I found 15 records for 'ENEL' in that resource. The most recent entries show tariff adjustments and operational metrics for the São Paulo region.
```

## Capabilities

### Inventory Data Packages
Lists every dataset available in the ANEEL portal so you know exactly what information is public.

### Inspect Dataset Metadata
Retrieves detailed structural and organizational tags for a specific data package.

### Locate Resource Files
Gets file-specific metadata, including the format (CSV, PDF, XLS) and download URL for any resource within a dataset.

### Query Datastore Records
Filters and searches record sets directly inside the integrated ANEEL data resources using natural language queries.

## Use Cases

### Comparing Regional Tariffs
An analyst needs to compare generation data across three different states. They first use `list_packages` to find the correct dataset, then use `get_package` to confirm it contains tariff information, and finally run a targeted query with `search_datastore` to filter by state code.

### Finding Source Documentation
A developer needs to know how the historical distribution metrics are formatted. They use `list_packages` to find the main dataset, then call `get_resource` on that package to identify both the primary CSV file and any associated PDF manuals.

### Auditing Operational Metrics
An energy consultant needs to see all records mentioning a specific substation ID. They use `search_datastore`, passing the resource ID and the target substation, getting an immediate list of relevant operational metrics.

## Benefits

- Instead of manually browsing for datasets, the `list_packages` tool gives you an immediate inventory of all available electricity data packages.
- You don't need to guess where a specific file is. Use `get_resource` to pinpoint download URLs and verify if the resource is CSV, PDF, or XLS.
- Forget clicking through filters for tariffs. You can use `search_datastore` to run complex queries against records directly in the data store.
- The `get_package` tool lets you inspect a dataset's full metadata—tags and organizational details—before committing to a large query.
- This MCP handles the tedious, multi-step process of finding, verifying, and querying structured energy records programmatically.

## How It Works

The bottom line is that you bypass manual web navigation by issuing specific commands through your AI client.

1. First, subscribe to this MCP. If your access requires it, you'll enter your specific ANEEL API Key.
2. Next, tell your AI client what data you need—for instance, 'List all available datasets.'
3. The agent executes the necessary tools to retrieve structured metadata or perform a record search, giving you actionable results.

## Frequently Asked Questions

**How do I find out what datasets are available using get_package?**
`get_package` doesn't list all packages. To start, you must first use `list_packages` to get the full inventory of dataset names.

**What is the difference between get_resource and search_datastore?**
`get_resource` tells you about a file (its format and URL). `search_datastore` actually runs a query against the data *inside* that resource.

**Can I use list_packages to find specific tariff data?**
No. You must run `list_packages` first, then select a promising package name, and finally use `get_package` or `search_datastore` to actually extract the data.

**Do I need an API key for search_datastore?**
Yes. If specific access is required by ANEEL, you must provide your API Key before attempting any resource query with `search_datastore`.

**If I use `get_package` with a package ID that doesn't exist, what kind of error should I expect?**
The tool returns a structured API error message. This message details the failure reason, confirming whether the issue is an invalid identifier or if specific access permissions are missing for the dataset.

**When running complex queries with `search_datastore`, how does it handle pagination to prevent massive data dumps?**
The search tool supports pagination using offset parameters. To pull all records, you must pass the next page token along with subsequent requests, ensuring you retrieve complete data sets without hitting size limits.

**To successfully use `get_resource`, what two identifiers are required to pinpoint a specific file's metadata?**
You must supply both the dataset package ID and the unique resource ID. The tool combines these inputs to locate the exact data asset, confirming its format (CSV, PDF, or XLS) and providing its download URL.

**What high-level context does `list_packages` provide beyond just listing dataset names?**
It returns key metadata for each listed package. You get the official description and the originating organization within ANEEL, helping you quickly assess relevance before running a deep query.

**How can I find the specific ID for a dataset like 'Tarifas das Distribuidoras'?**
You can use the `list_packages` tool to see all available names. Once you identify the name, use `get_package` with that ID to see all its internal resources and metadata.

**Can I search for a specific company name inside a CSV resource?**
Yes! If the resource is part of the DataStore, use the `search_datastore` tool. You can provide the `resource_id` and use the `q` parameter for a full-text search or `filters` for specific field matching.

**What information is included in the resource metadata?**
The `get_resource` tool returns the file format (CSV, PDF, etc.), the creation date, the last modification date, and the direct download URL for the data file.