# Datos Abiertos MCP

> Datos Abiertos Castilla-La Mancha lets your AI agent access public data from the Spanish region. It helps you list all available datasets, find specific resources like CSVs or JSON files, and search records directly within a table without downloading massive files.

## Overview
- **Category:** knowledge-management
- **Price:** Free
- **Tags:** open-data, spain, castilla-la-mancha, ckan, public-records

## Description

Need to research regional trends in health, environment, or economy? Instead of navigating complex government portals with dozens of clicks, you talk to your AI agent. This MCP connects straight to the official Castilla-La Mancha Open Data repository. Your agent handles all the discovery work: listing every available dataset, checking details on specific reports, and finding exactly which file format (CSV, JSON) you need.

It’s better than manually browsing a portal. If you're working with Vinkius, your agent can query records directly inside a data table using natural language—you don't have to download the whole thing just to find five rows of information. This means you spend time analyzing data, not figuring out how the government website is organized.

## Tools

### get_dataset
Retrieves detailed information about a single, named dataset from the portal.

### get_resource
Gets metadata for a specific file or resource linked to a dataset.

### list_datasets
Lists all available datasets currently published on the portal in bulk.

### list_tags
Retrieves a list of organizational tags and categories used across the entire data catalog.

### search_datastore
Searches and filters records directly inside a structured database resource without downloading it.

## Prompt Examples

**Prompt:** 
```
List all available datasets from the Castilla-La Mancha Open Data portal.
```

**Response:** 
```
I have retrieved the list of datasets. There are numerous entries including 'Presupuesto 2024', 'Calidad del Aire', and 'Centros Educativos'. Which one would you like to explore in detail?
```

**Prompt:** 
```
Search for the first 5 records in the datastore resource 'd4e5f6a7-b8c9'.
```

**Response:** 
```
Querying the datastore... I found the first 5 rows for resource 'd4e5f6a7-b8c9'. The data includes fields such as 'Municipio', 'Población', and 'Año'. Would you like me to summarize these records?
```

**Prompt:** 
```
Get the metadata and resources for the dataset 'centros-sanitarios'.
```

**Response:** 
```
Fetching details for 'centros-sanitarios'... This dataset contains information about health centers in the region. It has 3 resources available: a CSV file (ID: res-123), an Excel file, and a GeoJSON map. Do you want to search inside the CSV data?
```

## Capabilities

### Discover all available datasets
See a full list of every dataset published on the portal using simple identifiers or topic tags.

### Check dataset metadata
Fetch detailed information about any dataset, including when it was last updated and who maintains it.

### Find specific data files
Locate the direct links or metadata for physical resources within a dataset (like CSVs or PDFs).

### Search records in a table
Filter and search through structured rows of data inside a resource without downloading the entire file.

### Browse by topic tag
Explore all available categories or tags (e.g., 'environment' or 'education') to narrow down your search results.

## Use Cases

### Comparing health center data across regions
A researcher needs to compare public records from different years. They ask the agent to `list_datasets` first, find all 'health' datasets, and then use `get_dataset` on each one to check for consistent fields before starting their analysis.

### Finding specific budget figures
A developer needs a figure from the 2024 budget report. They tell their agent to search the relevant datastore using `search_datastore`, filtering by 'Municipio' and 'Año', getting the exact number without needing to open an Excel file.

### Mapping out available research topics
A new team member wants to know what kind of public data exists. They ask the agent to use `list_tags` immediately, which provides a comprehensive list of all available organizational categories (e.g., 'environment', 'economy').

### Verifying resource accessibility
A user knows they need data on air quality but isn't sure if the file is JSON or CSV. They ask the agent to `get_resource` for the dataset, and it provides metadata confirming all available formats.

## Benefits

- Stop downloading massive files. You can use `search_datastore` to filter records inside a table, giving you only the specific rows you need.
- Instantly check dataset details using `get_dataset`. Know when a report was last updated and who maintains it before you start your analysis.
- You don't have to browse by category manually. Use `list_tags` to see every available topic tag, which helps narrow down complex research areas quickly.
- Get an overview of all data sources right away with the `list_datasets` tool. This tells you exactly what type of regional statistics are available.
- Find the exact file format you need (CSV, JSON) using `get_resource`. The agent gives you metadata for that specific resource link.

## How It Works

The bottom line is you ask a question, and the MCP gets the specific public record answer for you.

1. Subscribe to this MCP and enter the necessary API Key into your agent client.
2. Tell your AI agent what you need, for example: 'List all datasets related to water quality.'
3. The agent executes the query against the portal's data structure and returns actionable results directly in the chat interface.

## Frequently Asked Questions

**How do I find out what kind of data is available? (list_tags)**
You use `list_tags`. This tool pulls every active category and tag from the portal, giving you a quick map of all topics—from 'economy' to 'environment'—so you know where to focus your research.

**If I want to search for specific records, should I use `search_datastore`? (search_datastore)**
Yes. Using `search_datastore` is the most efficient way. It lets you filter and query rows directly inside a resource file without forcing you to download gigabytes of data.

**How do I check if a dataset is still current? (get_dataset)**
You use `get_dataset`. This tool retrieves the metadata, which includes details on the update frequency and who maintains it. It tells you if the data is trustworthy enough for your report.

**I need to find a specific file format like GeoJSON. What do I use? (get_resource)**
Use `get_resource`. This tool finds details about physical files within a dataset, confirming the exact resource ID and available formats you're looking for.

**What is the best way to start my research on regional data? (list_datasets)**
Start with `list_datasets`. This provides an immediate, comprehensive list of every dataset published. It gives you a high-level overview of all available topics and resources.

**What should I do if I hit rate limits when using list_datasets?**
The system will provide a clear error message indicating the limit has been reached. To continue querying, you must either wait for the allotted time or configure your API key with higher usage quotas through the official data portal.

**If I use get_dataset with an invalid ID, how does the agent handle it?**
The MCP will immediately return a specific error code and message instead of failing silently. Your AI client will receive this structured failure notification, letting you know exactly which dataset ID needs correction.

**Can I filter results using search_datastore beyond simple field names?**
Yes, the agent allows complex filtering logic. You can specify filters based on multiple fields and logical operators (like 'AND' or 'OR') to narrow down records in the datastore.

**Can I search for specific records inside a CSV file without downloading it?**
Yes! Use the `search_datastore` tool with the Resource ID. You can apply filters and limits to query the data rows directly from the portal's internal database.

**How do I find all available datasets in the portal?**
Simply run the `list_datasets` tool. It will return a comprehensive list of dataset identifiers that you can then inspect further using `get_dataset`.

**Can I see the categories or tags used to organize the data?**
Yes, use the `list_tags` tool to retrieve all the keywords and categories used by the Castilla-La Mancha portal to classify their information.