# IBESTAT MCP

> IBESTAT connects your AI agent directly to the official statistical catalog of the Balearic Islands government. You can query available studies, identify specific data tables, and retrieve raw figures—in JSON, CSV, or XML format—for regional metrics ranging from population demographics to economic activity.

## Overview
- **Category:** data-analytics
- **Price:** Free
- **Tags:** statistics, regional-data, public-records, demographics, economic-data, spain

## Description

This MCP gives you direct access to the full statistical record of the Balearic Islands. Instead of navigating complex government portals, your AI agent handles it all. You can ask for data on anything covered by the official institute's catalog, whether it’s historical trends or current metrics. It makes retrieving public regional statistics as simple as asking a question in natural language. If you're working with Vinkius, this MCP slots right into your existing flow, letting you query operations and datasets without ever leaving your favorite AI client. You get the structured output you need—the raw figures for deep analysis or clean metadata to validate definitions.

## Tools

### get_data
Retrieves the actual statistical figures for a specific resource table.

### get_metadata
Gathers definitions and context about an entire data operation or study.

### list_operations
Returns a list of all major statistical operations available from the institute.

### list_resources
Identifies specific tables and datasets associated with a given study ID.

## Prompt Examples

**Prompt:** 
```
List all available statistical operations from IBESTAT.
```

**Response:** 
```
I have retrieved the list of statistical operations. There are several categories available, including 'Population' (ID: 01), 'Tourism' (ID: 05), and 'Economy' (ID: 10). Which area would you like to explore further?
```

**Prompt:** 
```
Show me the resources available for the statistical operation with ID '0201'.
```

**Response:** 
```
For operation '0201', I found the following resources: 'Table 1: Annual Growth', 'Table 2: Regional Distribution', and 'Table 3: Historical Series'. Would you like to fetch the data for one of these?
```

**Prompt:** 
```
Get the data for operation '0201' and resource 'T1' in English and JSON format.
```

**Response:** 
```
I've fetched the data for resource 'T1'. It contains the annual growth metrics for the requested period. [JSON Data Displayed]. Would you like me to analyze these numbers for you?
```

## Capabilities

### List all available statistical studies
You can ask what major topics are covered by the institute, getting a list of all possible operations.

### Identify specific datasets
Using an operation ID, you pinpoint which exact tables or resources exist for that topic.

### Retrieve raw statistical figures
You pull the actual numbers—the metrics and data points—in structured formats like JSON or CSV.

### Access context and definitions
You retrieve the underlying metadata, ensuring you understand what each metric means before using it in a report.

## Use Cases

### Analyzing population trends for a quarterly report
A data analyst asks their agent to pull the latest demographic figures. The agent first uses `list_operations` to confirm 'Population' is available, then uses `list_resources` to find the annual growth table, and finally calls `get_data` to get the numbers in JSON format for the report.

### Checking definitions before coding a feature
A developer needs to know how 'regional distribution' is defined. They run `get_metadata` on the relevant operation ID, which returns the official context and data structure requirements, preventing them from using an incorrect metric.

### Comparing two different economic sectors
A researcher wants to compare 'Tourism' vs. 'Economy'. They use `list_operations` to confirm both exist, then repeatedly call `get_data` for the required resource IDs to pull structured data from multiple sources.

### Building a live dashboard feed
A developer integrates this MCP by having their agent first list all available operations. The system can then automatically target and retrieve key resources using `list_resources` and `get_data` for continuous updates.

## Benefits

- Stop manual downloads. You can use `list_operations` to see every major statistical category (like Population or Tourism) and zero in on the topic you need.
- Context is key. Before fetching numbers, run `get_metadata` to understand exactly what a metric measures. This prevents bad assumptions in your reports.
- No more messy data cleanup. When you use `get_data`, you get raw figures directly in structured formats (JSON or CSV), ready for immediate ingestion into an application.
- Pinpointing sources is fast. If you know the study ID, running `list_resources` immediately shows every available table within that specific operation.
- It handles complexity. You don't need to write complicated API calls; your agent just needs to ask what it wants, and this MCP translates it using all its tools.

## How It Works

The bottom line is that your AI client translates complex data requests into structured calls and gets you clean figures back.

1. Subscribe to this MCP on Vinkius. This gives your AI client permission to run data queries.
2. Provide an identifier for API requests (the User Agent). The system needs to know who's running the query.
3. Start asking questions using natural language through Claude, Cursor, or any compatible agent.

## Frequently Asked Questions

**How can I find out which statistical tables are available for a specific study?**
Use the `list_resources` tool with the specific `operationId`. It will return a list of all available resources (tables) associated with that statistical operation.

**Can I retrieve the statistical data in different languages?**
Yes. When using the `get_data` tool, you can specify the `lang` parameter. Supported languages typically include Catalan ('ca'), Spanish ('es'), and English ('en').

**What formats are available for downloading data?**
The `get_data` tool allows you to choose between 'json', 'xml', and 'csv' formats via the `format` parameter, making it easy to integrate with different analysis tools.

**Before I run `get_data`, how do I use `get_metadata` to verify what a specific data variable means?**
The tool returns comprehensive context, definitions, and structural information for any given operation. This lets you confirm the exact meaning of metrics—like ensuring 'Year' refers to the fiscal year versus calendar year—before fetching figures.

**What should I do if I use `list_resources` with an Operation ID that doesn't exist in IBESTAT?**
The agent will return a structured error message, pointing out the invalid Operation ID. You just need to check your inputs and try running `list_operations` first to confirm you have the correct starting ID.

**How do I use `list_operations` effectively if I'm looking for a specific topic like 'Tourism'?**
It outputs a comprehensive list of all available statistical operations. You can then filter that output using your natural language prompt to narrow down the list and find the relevant ID, like 'Population' or 'Economy'.

**Are there limits on how many times I can call `get_data` in one session?**
Vinkius manages connection stability, but we recommend chunking your requests. If you run too many calls too fast, the system may temporarily throttle you to protect the underlying data source.

**If I need historical context for a resource, can I use `list_resources` or do I need another step?**
You first use `list_operations` to find the right study. Then, running `list_resources` identifies the tables, and finally, using `get_data` allows you to pull historical figures for those specific resources.