cat.idescat/mcp

Idescat MCP Server

Query official statistics of Catalonia (Idescat): tables, metadata and JSON-stat data via MCP.

1.0.0
Version
remote
Transport
7
Tools

Security review

Review passed

Reviewed Jan 1, 2000.

  • tools: 7 tools scanned
  • metadata: scanned

No findings.

Tools (7)

  • get_idescat_stats

    Obtains the complete list of Idescat statistics (all, normalized and non-normalized). It has no parameters. The response contains a 'statistics' array where each element has: 'acronym' (lowercase acronym, e.g., 'censph', to be used as the 'stat' argument of the other tools), 'name' (title), 'description' (summary), 'datasets' (boolean), 'geo' (array of available territorial disaggregations), and 'url' (initial web address, relative to https://www.idescat.cat). Use it when the user asks what statistics are available or when a statistic needs to be found by name or territorial disaggregation. THREE KEY FIELDS to decide the flow: (1) 'datasets' — if true, the statistic is normalized and you can use the rest of the tools (get_idescat_stat_tables, get_table_metadata, get_table_data, get_table_geo, render_table); if false, ONLY the information from this tool and get_idescat_stat is available. (2) 'geo' — available levels of geographical disaggregation (e.g., 'cat'=Catalonia, 'prov'=provinces

  • get_idescat_stat

    Obtains information about an Idescat (Statistical Institute of Catalonia) statistic given its acronym. Use it when the user asks about a specific statistic identified by its acronym (for example, CENSPH, EPA, PIBC, AFI, etc.). The 'datasets' field is a key boolean: if true, the statistic is normalized and therefore available in get_idescat_stat_tables and the rest of the table-level tools (metadata, data, divisions, etc.); if false, the statistic is NOT normalized and get_idescat_stat_tables will not recognize it (it would return an identifier error), so the only information available is what this same tool returns ('url', 'time_ref', 'update_date', 'update_title', 'update_text'). To know if a statistic has queryable tables, this tool is enough, without calling get_idescat_stat_tables. The 'url' field is a relative address to https://www.idescat.cat. The 'geo' field is an array with the available geographical disaggregation levels (e.g., 'cat', 'prov', 'at', 'com', 'mun', 'dis', 'sec')

  • get_idescat_stat_tables

    Obtains the list of tables for an Idescat statistic given its official acronym. Use it when the user asks what tables or information a statistic has. The response contains a 'tables' array where each element has 'id' (numerical identifier) and 'name' (table title). Present each table as: name (id). Inform the user that they can request more details about a table by indicating its identifier.

  • get_table_metadata

    Obtains the metadata for a specific Idescat table in JSON-stat format, given the statistic acronym (stat) and the table identifier (table). Use it when the user wants to know the details of a table: dimensions, categories available for each dimension (time periods, territorial scopes, sex, etc.), date of last update, units, etc. The acronym and identifier are previously obtained with get_idescat_stat_tables. At the end of the response, always include this Markdown link (substituting {stat} and {table} in lowercase): [See the results in this table](https://www.idescat.cat/pub/?id={stat}&n={table}). TERRITORIAL DIVISIONS: the response includes 'link.related', an array with other available territorial divisions (provinces, counties, municipalities, etc.); therefore it is often NOT necessary to call get_table_geo. If you pass the 'geo' parameter (for example geo='com' or geo='mun'), you get the metadata for that division, which includes the codes and labels (category.index / category.label

  • get_table_data

    Retrieves the data (values) of an Idescat table in JSON-stat format for a territorial division. You can retrieve the ENTIRE table (without filters) or only a SUBSET by passing the OPTIONAL parameters 'filters' (specific categories per dimension) and/or 'last' (number of last time periods); filtering returns smaller responses and allows querying tables that as a whole would exceed the limit. The filters use the dimension identifiers and category codes (category.index) returned by get_table_metadata (with the same 'geo'). IMPORTANT: the 20,000 cell limit is checked AFTER applying the filters; if it exceeds it, it returns a 'Dataset too large' error and you must add more filters (filters, last). You can call get_table_metadata beforehand to know the dimensions, periods, and category codes. The result contains: 'id' (dimension names in order), 'size' (number of categories per dimension), 'value' (flat array of values), 'dimension' (details per dimension: codes in category.index, labels in

  • get_table_geo

    Obtains the list of territorial divisions available for an Idescat table (for example: cat=Catalonia, com=counties and Aran, mun=municipalities, prov=provinces, at=territorial plan areas). The response contains a 'divisions' array where each element has 'id' (division code) and 'name' (label). Often it is NOT necessary to call it because get_table_metadata already returns these divisions in 'link.related'. Use it only if you need the list of divisions without having called the metadata. The 'id' code is the value to pass to the 'geo' parameter of get_table_metadata, get_table_data, or render_table. If not specified, these tools use the 'cat' division (Catalonia as a whole) by default.

  • render_table

    Returns a Markdown table already built with the filtered data from an Idescat table, ready to be shown to the user without having to interpret the JSON-stat. It includes the title, units, the table with category labels, status notes (e.g., provisional data), and ALWAYS a final link to the table on the Idescat website that must be kept in the response to the user. By default, it puts the time dimension in rows and the first dimension with more than one category in columns; this can be changed with the 'rows' and 'cols' parameters. All other dimensions with more than one category must be reduced to a single category with 'filters'. IMPORTANT (error self-correction): if the tool returns the error with 'pending_dimensions', DO NOT change tools: call render_table again adding the 'filters' parameter with a single category for each pending dimension (you can start from the 'suggested_filters' field that comes in the same error response, but choose the appropriate category for the user's ques