# Minas Gerais MCP

> Minas Gerais (Estado) MCP Server connects your AI client directly to the official Open Data Portal for Minas Gerais, Brazil. It lets you programmatically query, search, and retrieve metadata—not raw data—from state-level government records. Use it to list all available datasets (`list_packages`), map out organizational structures (`list_organizations`), or find specific files (CSV/PDF) across the entire portal without clicking through a single page.

## Overview
- **Category:** data-management
- **Price:** Free
- **Tags:** open-data, transparency, public-records, dataset-discovery, metadata-query, brazil-public-data

## Description

**Minas Gerais (Estado) MCP Server** connects your AI client straight into the official Open Data Portal for Minas Gerais. You're not dealing with raw data; you're querying the metadata—the structural blueprint of the state's government records. Forget web scraping or wrestling with complex session management. This server gives your agent direct access to underlying API endpoints, letting it programmatically query, search, and pull organizational details from the entire portal without clicking a single page.

The whole point here is treating the massive transparency database like a structured resource within your workflow. It's about indexing government data for machines, not humans. You run functions that do the heavy lifting, returning clean JSON objects you can pass to subsequent steps in your agent's process.

***

**Searching and Discovery:**

If you don’t know what you need, you start broad. To get a full inventory of everything available, run `list_packages` for an immediate list of every dataset name and its basic metadata in the entire Minas Gerais portal. You can narrow that scope down quickly by running **`search_packages`**; just feed it keywords—like 'health' or 'finance'—and you'll get package metadata that matches those specific terms across the whole catalog. For a more targeted search, use **`search_resources`**. If you know you’re looking for something like a 'CSV' file type or data related to 'budget,' this function searches all available resources and files inside the portal.

**Understanding Structure:**

You need to map out who owns what. Use **`list_organizations`** first; it provides a complete list of every department or state body that contributed data. Once you've identified an organization, run **`get_organization`** to grab its full details and see precisely which datasets that specific entity manages. To understand the thematic filing system—the official buckets used across the portal—you can call **`list_groups`**, which returns a list of all available thematic groups (categories). If you need more depth on those categories, use **`get_group`** to retrieve detailed metadata and associated datasets for any specific group. Similarly, to understand how data is tagged, run **`list_tags`** to get every standardized tag used for classification across multiple packages, which helps your agent filter down the search criteria.

**Drilling Down into Data Assets:**

When you've located a dataset or want deep details on a single file, these tools take over. If you have an exact package ID and need all associated metadata—the complete record for that data set—you execute **`get_package`**. That gives you the full picture of the dataset itself. To find specific files (resources) *within* a known package or across the whole system, use **`search_resources`** to locate content types like 'CSV' or 'PDF'. For an individual file asset, running **`get_resource`** retrieves specific metadata about that single resource within any given dataset.

***

**How It Works In Practice:**

Your agent runs these tools. It doesn't render a messy webpage; it receives structured JSON responses containing the precise metadata, identifiers, and links you need. You take those IDs—whether they’re package IDs or organization UUIDs—and pass them into other steps in your workflow. This lets your agent build complex data maps, allowing you to trace ownership from a specific file back through its resource container, up to the department that published it.

## Tools

### list_groups
Returns a list of all available thematic groups (categories) used to classify the datasets in the portal.

### get_group
Retrieves detailed metadata and associated datasets for a specific thematic group (category).

### list_organizations
Provides a complete listing of every organization or department that has contributed data to the portal.

### get_organization
Gets full details—including all managed datasets—for one specific state governmental organization.

### list_packages
Lists the names and basic metadata for all datasets currently available in the entire Minas Gerais portal.

### search_packages
Searches the entire dataset catalog using keywords or criteria to find relevant packages by name.

### get_package
Fetches the complete metadata record for a single, identified dataset (or 'package').

### search_resources
Searches for specific files or content types (like 'CSV' or 'budget') across all available resources in the portal.

### get_resource
Retrieves specific metadata about an individual file or data asset within a package.

### list_tags
Returns a comprehensive list of standardized tags used to classify data across multiple packages, helping with filtering.

## Prompt Examples

**Prompt:** 
```
Search for datasets related to 'educação' in the Minas Gerais portal.
```

**Response:** 
```
I found several datasets related to education, including 'Indicadores da Educação Básica' and 'Matrículas na Rede Estadual'. Which one would you like to explore in detail?
```

**Prompt:** 
```
List all organizations available in the portal.
```

**Response:** 
```
I've retrieved the list of organizations. There are over 50 entities, including 'Controladoria-Geral do Estado (CGE)' and 'Secretaria de Estado de Fazenda (SEF)'.
```

**Prompt:** 
```
Get the metadata for the dataset 'planejamento-e-monitoramento'.
```

**Response:** 
```
The dataset 'Planejamento e Monitoramento' contains 12 resources, including CSV files for budget execution and PDF reports. It is maintained by the SEPLAG organization.
```

## Capabilities

### Search for datasets by keyword
Run `search_packages` to find dataset metadata matching specific terms across the entire portal.

### Map government departments and ownership
Use `list_organizations` and `get_organization` to map out which state bodies (like SEF or CGE) are responsible for which data sets.

### Browse datasets by category or tag
Run `list_groups` or `list_tags` to understand the thematic structure of the available public records, helping you narrow down your search scope.

### Get full metadata for a specific dataset
Use `get_package` when you have an exact package ID and need all associated details about that data set.

### Find specific files (resources)
Execute `search_resources` if you know what type of file or content you're looking for within a dataset.

## Use Cases

### Mapping state accountability
A journalist needs to know which department owns all health-related data. They ask their agent to run `list_organizations`, filter for 'health,' and then use `get_organization` on the resulting ID. The agent returns a clean list of every contributing body, bypassing weeks of manual website searching.

### Building a dataset inventory
A developer needs to know if a specific resource (a budget spreadsheet) exists anywhere in the portal. Instead of guessing the package name, they run `search_resources` with criteria like 'budget' and 'CSV'. The tool returns metadata links for all matching files, allowing them to build an index.

### Finding relevant data on a topic
A researcher wants everything related to 'public school enrollment.' They ask the agent to first `list_groups` to find the 'Education' category. Then they run `search_packages` using that group context, quickly identifying all major datasets like 'Indicadores da Educação Básica'.

### Verifying data structure
A developer has a package ID but needs to confirm the exact file types available. They call `get_package` first to get general metadata, and then they use `search_resources` on that package's context. This confirms if CSV or PDF formats are actually present before writing any code.

## Benefits

- Mapping government structure: Instead of clicking through departmental menus, running `list_organizations` and then specific calls to `get_organization` instantly maps the entire contributing body. You get the full hierarchy in one automated step.
- Targeted dataset retrieval: When you know the topic but not the exact name, using `search_packages` saves hours of manual browsing. It filters thousands of records down to a manageable list based on keywords.
- Deep resource inspection: Once your agent finds a package ID via `get_package`, it can then use `get_resource`. This gives you metadata for individual files (CSV, PDF) without having to download anything or guess the file path. It's surgical.
- Structured browsing: Need to find all data related to 'Education'? Running `list_groups` first lets your agent understand the available categories. You then use that category name in a focused search, making sure you don't miss any major thematic area.
- Cross-system searching: If you are looking for a file type—say, every CSV record related to 'budget execution'—you can skip dataset names entirely and run `search_resources`. It pulls results from anywhere it finds the matching resource criteria.

## How It Works

The bottom line is, it makes querying complex government data portals as simple as calling a function name.

1. First, subscribe to the Minas Gerais server. You can optionally input an API Key for better rate limits.
2. Next, tell your AI client exactly what you need—for example, 'List all organizations' or 'Search for datasets about education.'
3. The agent runs the corresponding tool (e.g., `list_organizations`), and the response provides clean JSON metadata that you can use to build out a final answer or script.

## Frequently Asked Questions

**How do I find all datasets related to 'education' using search_packages?**
You run `search_packages` and pass the keyword 'educação'. The tool returns a list of matching dataset names (like 'Indicadores da Educação Básica'). You then use `get_package` on those results for full metadata.

**What is the difference between get_organization and list_organizations?**
`list_organizations` gives you a roster of every contributing department. `get_organization` requires a specific ID and returns all data—including datasets—for just that single entity.

**Can I use get_resource to find raw CSV files?**
No, it only provides the metadata for a resource (like its file type or size). The tool tells you *that* the file exists; it doesn't download the actual data content.

**How do I list all available dataset categories?**
Use `list_groups`. This function returns every thematic group used across the portal, giving you a structured view of how the state organizes its public records.

**When calling get_package, how do I manage rate limits or improve performance?**
You can use an optional Minas Gerais Portal API Key for higher rate limits. This key is entered into the server configuration and allows your AI client to make more frequent calls without hitting throttling restrictions.

**What's the difference between list_packages and get_package?**
The `list_packages` tool provides a simple, comprehensive list of all available dataset names in the portal. Conversely, `get_package` retrieves the full metadata record for one specific dataset name you provide.

**Can I refine my search using tags and then running search_packages?**
Yes. You first use `list_tags` to identify relevant criteria, and then pass those identified tag values directly into the `search_packages` function for highly specific results.

**What happens if I run get_resource with an incorrect file ID?**
The agent will receive a standardized API error code. Your AI client can interpret this failure and suggest alternative resource IDs or guide you to the relevant organizational department instead.

**How can I find datasets related to a specific topic like 'health'?**
You can use the `search_packages` tool with the query 'saude' or use `get_group` with the ID 'saude' to list all datasets categorized under that theme.

**Can I see the actual download links for the data files?**
Yes. By using `get_package` with a dataset ID, the AI will retrieve the metadata for all associated resources, which typically includes the URL, format (CSV, PDF), and description of each file.

**How do I list all government agencies that publish data on the portal?**
Use the `list_organizations` tool. It will return a list of all government bodies (like CGE, SEF, etc.) that have active datasets in the Minas Gerais portal.