# Ayuntamiento de Barcelona (CKAN) MCP for AI Agents AI Agent Connect

> Ayuntamiento de Barcelona (CKAN) MCP lets you query Barcelona's official open data portal through your AI client. Get urban stats, environmental records, and transportation data without manual CSV downloads. It pulls directly from the city's CKAN API, making it easy to filter records or run SQL queries on public datasets.

## Overview
- **Category:** data-analytics
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_iv5GYpi3FqmjfmjJOIvg9apgeu4Cf7aNs3ZIC6cs/ai-agent-connect
- **Tags:** open-data, urban-planning, public-statistics, ckan-api, city-data, data-discovery

## Description

Stop jumping between tabs and downloading messy CSV files just to find out how many bike lanes exist in a specific neighborhood or where the nearest public WiFi hotspots are. This Connector connects your AI client directly to the Ayuntamiento de Barcelona (Open Data BCN) portal. Instead of hunting through folders, you just ask for the data and let the agent do the heavy lifting. You can search for specific datasets, inspect metadata to see how often records are updated, or even run SQL queries to pull exactly what you need. It turns the city's massive public repository into a searchable knowledge base. It's a huge time saver if you're tired of the manual find, download, clean, and analyze loop. You can find this in the Vinkius catalog to get connected quickly. It handles the API handshake so you can focus on the actual analysis.

## Tools

### bcn_datastore_search_sql
Execute SQL queries directly against a specific resource. You just need to wrap the resource ID in double quotes as the table name.

### bcn_datastore_search
Search and filter records within a specific CSV resource. Use this to narrow down data without downloading the entire file.

### bcn_package_list
List all dataset names in the Open Data BCN catalogue. It's the fastest way to see the full scope of available public data.

### bcn_current_packages
Lists all available datasets including their resources. This helps you see what's available in the portal at a glance.

### bcn_package_search
Search for datasets matching specific criteria like topic or location. It makes finding relevant information much faster.

### bcn_package_show
Get metadata for a specific dataset. This lets you check update frequencies and data structures.

### bcn_resource_show
Get metadata for a specific resource. Use this to see download links and format specifications.

## Prompt Examples

**Prompt:** 
```
What are the most recent datasets about air quality in Barcelona?
```

**Response:** 
```
I've found the following recent datasets related to air quality:

* **Qualitat_aire_barcelona**: Contains real-time data from various monitoring stations.
* **Estacions_meteorologiques**: Includes environmental metrics including air quality.

Would you like me to pull the specific metadata for one of these?
```

**Prompt:** 
```
Show me the locations of all public municipal markets.
```

**Response:** 
```
I've retrieved the records for municipal markets. Here are a few examples:

| Market Name | District | Location Type |
| :--- | :--- | :--- |
| Mercat de la Boqueria | Ciutat Vella | Indoor |
| Mercat de Santa Caterina | Ciutat Vella | Indoor |

I can provide the full list of coordinates if you'd like.
```

**Prompt:** 
```
How many traffic accidents were recorded in 2023?
```

**Response:** 
```
I ran a SQL query on the 2023 accidents dataset. 

**Total accidents recorded in 2023:** 8,452

Would you like me to break this down by district or type of accident?
```

## Capabilities

### Search urban datasets
Find specific city data on topics like transportation or demographics.

### Run SQL queries
Execute precise SQL commands against specific city resources.

### List city datasets
Get a full list of all available datasets in the Barcelona portal.

### Inspect metadata
Check update frequencies and data structures for any resource.

### Filter records
Narrow down records within a CSV resource without downloading it.

### View resource details
Get download links and format specifications for specific data points.

## Use Cases

### Finding WiFi hotspots
A developer asks where public WiFi is located and gets a list of coordinates from the punts-wifi dataset.

### Traffic accident counts
A researcher uses bcn_datastore_search_sql to count accidents in a specific district for 2023.

### Environmental planning
A planner searches for tree zones and weather stations to map out new green spaces.

### Quick data audit
A user lists all packages to see what new datasets the city has released this month.

## Benefits

- Skip the manual download loop. Use bcn_package_search to find datasets instantly instead of browsing folders.
- Run precise queries. Use bcn_datastore_search_sql to pull specific rows from large CSVs without downloading the whole file.
- Get metadata on the fly. Use bcn_package_show to check update frequencies and data structures in seconds.
- Analyze urban trends faster. Quickly find transportation or environmental data to build reports.
- Save time on data cleaning. Your agent can filter records using bcn_datastore_search so you don't have to do it in Excel.

## How It Works

The bottom line is you get direct, conversational access to official Barcelona city data without ever touching a spreadsheet.

1. Subscribe to this Connector in the Vinkius catalog.
2. Enter your optional Open Data BCN API Token in the settings.
3. Ask your AI client to find or query specific Barcelona city data.

## Frequently Asked Questions

**What kind of data can I get from the Ayuntamiento de Barcelona (CKAN) MCP?**
You can access a wide range of official city data, including transportation stats, environmental records, urban planning datasets, and public demographics.

**Do I need a special account to use the Ayuntamiento de Barcelona (CKAN) MCP?**
No, you can access public data without an account. However, providing an API token is recommended if you need to perform high-volume queries.

**Can I use SQL to query the Barcelona city data?**
Yes, the Connector allows your AI agent to execute SQL queries directly against specific city resources, making it easy to filter and aggregate data.

**How does the Ayuntamiento de Barcelona (CKAN) MCP help with urban planning?**
It allows planners to quickly find and analyze infrastructure data, such as bike lanes or green spaces, without manually downloading and cleaning spreadsheets.

**Is the data provided by the Ayuntamiento de Barcelona (CKAN) MCP up to date?**
The Connector pulls directly from the official city portal, so you get the most current information available in the public repository.

**Can I use this Connector to find public WiFi hotspots?**
Yes, you can ask your agent to search for datasets like 'punts-wifi' to find all public WiFi locations across the city.

**Can I perform SQL queries on Barcelona's public datasets?**
Yes, you can use the `bcn_datastore_search_sql` tool to execute SELECT statements directly against any resource that is stored in the portal's datastore.

**How do I find datasets related to a specific topic like 'transport'?**
Use the `bcn_package_search` tool with the query parameter `q` set to your topic. You can also limit the number of results for faster browsing.

**Is it possible to see the actual rows of a CSV file without downloading it?**
Absolutely. The `bcn_datastore_search` tool allows you to query and preview the contents of a resource directly, including filtering and sorting options.