• DATA
  • STATS
  • QUERY
  • HUMAN

How to query Barcelona city data with your AI

Connect your AI to the Ayuntamiento de Barcelona CKAN instance. Once connected, you can use natural language to run SQL queries against live city datasets.

Ask AI about this page

Short answer

How can I query Barcelona city data with my AI?

Your AI client writes and executes SQL queries against the Barcelona Open Data datastore. You'll get specific counts, filtered lists, and data summaries directly in your chat. Here is how the process works.

Data outcomes

What you get from your queries

The AI handles the technical data retrieval so you can focus on the results.

DATA

Filtered record sets

The AI pulls specific rows from city datasets based on your criteria. You get clean, structured data instead of massive CSV files.

STATS

Instant counts and sums

Ask for totals, averages, or specific counts. The AI calculates these values using the underlying datastore.

QUERY

SQL-based extraction

Your agent translates your questions into valid SQL. It executes these against the CKAN datastore to find exactly what you need.

HUMAN

Data interpretation

The AI provides the raw numbers and filtered lists. You decide how to use these insights for your reports or projects.

The workflow

What your AI does when the request arrives.

The AI acts as a bridge between your conversation and the Barcelona city database.

  1. Translate intent

    Your agent takes your plain English question and determines which dataset and columns are required to answer it.

    bcn_datastore_search_sql
  2. Construct SQL

    The AI builds a precise SQL query designed to work with the CKAN datastore structure.

    bcn_datastore_search_sql
  3. Execute query

    The agent sends the command to the Ayuntamiento de Barcelona API to fetch the requested records.

    bcn_datastore_search_sql
  4. Format results

    The AI receives the raw data and presents it to you in a readable format like a table or a summary.

    bcn_datastore_search_sql

Try it

Copy these to start.

Use these prompts to begin interacting with the city's data.

Starting points

Swap out the dataset names and column filters for the specific Barcelona data you want to analyze.

Open Data BCN Connector

You're all set. Choose your MCP client and follow the setup instructions.

Connector linkhttps://edge.vinkius.com/vk_preview_iv5GYpi3FqmjfmjJOIvg9apgeu4Cf7aNs3ZIC6cs/mcp

Claude Desktop

Follow the steps below to connect in seconds.

  1. 1In Claude Desktop, open Settings → Connectors.
  2. 2Click “Add custom connector” and paste the connector link above as the remote MCP server URL.
  3. 3Click Add and start a new chat — Open Data BCN capabilities are ready to use.
Configuration · claude_desktop_config.jsonCopy
{
  "mcpServers": {
    "ayuntamiento-de-barcelona-ckan-mcp": {
      "url": "https://edge.vinkius.com/vk_preview_iv5GYpi3FqmjfmjJOIvg9apgeu4Cf7aNs3ZIC6cs/mcp"
    }
  }
}
Copy into chat04
  • Show me the total count of bike stations in Barcelona from the city datasets.

  • List the top 10 most populated districts using the census data.

  • Find all public transport routes that pass through Eixample.

  • How many trees were planted in the last year according to the urban green space dataset?

  • Claude
  • ChatGPT
  • Cursor
  • VS Code
  • Windsurf
  • Claude Code
  • JetBrains
  • Cline

Start here

Connect Ayuntamiento de Barcelona (CKAN) once, then ask.

Click the link to connect the MCP to your client. Your credentials stay encrypted and the setup is handled on our side.

Connect Ayuntamiento de Barcelona (CKAN) to your AI

FAQ

How this task behaves.

  • 01

    Can the AI change or delete data in the Barcelona database?

    No. The tool only allows for querying and reading data. It cannot modify, add, or delete any records in the city's system.

  • 02

    Do I need to know SQL to use this?

    No. You can ask questions in plain English, and the AI will write the SQL for you.

  • 03

    Can the AI download the entire dataset as a file?

    No. The AI uses the tool to fetch specific subsets of data. It does not have a tool for bulk file downloads.

  • 04

    Is the data real-time?

    The AI accesses the data currently available in the Ayuntamiento de Barcelona CKAN datastore.

  • 05

    Can the AI create new datasets?

    No. The capability is strictly limited to searching and querying existing public datasets.

  • More questions about Ayuntamiento de Barcelona (CKAN)? The Connector page answers them. See everything the Ayuntamiento de Barcelona (CKAN) Connector can do

Connect Open Data BCN to Claude, Cursor, ChatGPT & more