Back to the map · En español

Agents

An AI agent (Claude, ChatGPT or any MCP client) can use spainciv with tools of its own: read the map's data and cross it, play «Adivina el hexágono» (Guess the hex) and «Tres ciudades» (Three cities), and play a game of Unciv with the mod on the map of Spain. The server reads the same files as this website and does the sums with the same code.

Connect it

On your computer (every tool)

It needs Node 22 or newer. In Claude Code:

claude mcp add spainciv -- npx -y @djinnfoundry/spainciv-mcp

In Claude Desktop, in claude_desktop_config.json:

{
  "mcpServers": {
    "spainciv": { "command": "npx", "args": ["-y", "@djinnfoundry/spainciv-mcp"] }
  }
}

The data download from this website the first time and stay in ~/.cache/spainciv-mcp; after that only the files that changed download again.

By URL (claude.ai, ChatGPT)

Clients that only take an address use the remote server, which has 14 of the 20 tools (Unciv's need your computer): https://mcp.spainciv.djinnfoundry.com/mcp. It keeps nothing between calls: a game travels in a token the agent hands back with each move.

What it can do

Every figure comes with its source, date, licence and the caveats the website shows in the legend, and says how it was worked out: a hex's value, the sum of a province's hexes or their mean weighted by residents. The map's unit is a 10 km hex, so a municipality's figure is that of the hex holding its main town, except the Padrón's residents, which go by municipality. A figure the source gives by province or by community is not ranked or crossed by hex: the server refuses and says why.

Data

The website's games

Unciv, local only

Seeded games of «Adivina el hexágono» and the daily games of «Tres ciudades» are the same for every agent, so they work for a tournament, open book: the data tools can read the clues, as a person uses the lenses. A finished game of «Tres ciudades» opens on this website from its link.

Unciv

Unciv has no API. The server runs Unciv's own engine (version 5.0.4, pinned) without its interface, through a bridge in Java: it creates the game on the mod's España map, tells the agent what it can research, build and do with each unit, and ends its turn; then the AI civilizations play. Games are stored the way Unciv's multiplayer server stores them, and the MCP brings a local one: a person with Unciv and the mod can play the same game against the agent. It needs Java (JDK 17 or newer). The bridge calls internal classes of Unciv that change between versions, so the version is pinned.

A real session

These 15 calls were made on 2026-12-06 with the server on the published data; each answer is the one it gave, cut to the fields shown. Run it again with node mcp/scripts/demo.js.

What data is there about age?

list_datasets {"search": "edad"}

{
 "count": 6,
 "datasets.*.id": [
  "age",
  "bachelors",
  "escuela_infantil",
  "oldest_old",
  "centenarians",
  "longevity_zones"
 ],
 "datasets.*.name": [
  "Edad media",
  "Estudios superiores",
  "Escuela infantil, 0-2 años · curso 2025-26 (avance)",
  "Sobreenvejecimiento",
  "Centenarios",
  "Zonas de longevidad"
 ],
 "datasets.0.source": "ine_adrh_indicadores",
 "sources": {
  "ine_adrh_indicadores": {
   "title": "Atlas de Distribución de Renta de los Hogares (ADRH): indicadores demográficos (tabla 30832) y umbrales relativos de renta (tabla 30829)",
   "publisher": "Instituto Nacional de Estadística (INE)",
   "vintage": "INE Atlas de Distribución de Renta de los Hogares, 2024"
  },
  "ine_censo_formacion": {
   "title": "Censo anual de población: población de 15 años o más por sexo y nivel de estudios (agrupado), tabla 66592",
   "publisher": "Instituto Nacional de Estadística (INE)",
   "vintage": "INE Censo anual de población, 1 de enero de 2024"
  },
  "educabase_escolarizacion": {
   "title": "Tasa neta de escolaridad de menos de un año, de un año, a los 2 años y de 0 a 2 años, por sexo, comunidad autónoma y curso (Estadística de las Enseñanzas no universitarias)",
   "publisher": "Ministerio de Educación, Formación Profesional y Deportes, Subdirección General de Estadística y Estudios (EducaJaxiPx; indicador E2.1 del Sistema estatal de indicadores de la educación del INEE)",
   "vintage": "curso 2025-26 (avance)"
  },
  "ine_censo_edad": {
   "title": "Censo anual de población: población por sexo y edad (grupos quinquenales), tabla 65034, contrastada con la tabla 1488",
   "publisher": "Instituto Nacional de Estadística (INE)",
   "vintage": "INE Censo anual de población (Sexo y edad), 1 de enero de 2026 (datos provisionales)"
  }
 }
}
Soria against Spain

get_values {"places": ["Soria"], "datasets": ["age", "income", "residents"]}

{
 "spain.values.age": {
  "value": 44.034,
  "display": "44,0 años",
  "method": "resident_mean",
  "coverage": {
   "hexes_with_value": 5843,
   "hexes": 5843,
   "residents_share": 1
  }
 },
 "places.0.place": {
  "level": "province",
  "id": "42",
  "name": "Soria",
  "community": "Castilla y León",
  "hexes": 118
 },
 "places.0.values": {
  "age": {
   "value": 47.172,
   "display": "47,2 años",
   "method": "resident_mean",
   "coverage": {
    "hexes_with_value": 118,
    "hexes": 118,
    "residents_share": 1
   },
   "percentile_among_peers": 0.817,
   "peers": "52 provinces with a value",
   "ratio_to_spain": 1.07
  },
  "income": {
   "value": 16571,
   "display": "16,6 mil €",
   "method": "resident_mean",
   "coverage": {
    "hexes_with_value": 118,
    "hexes": 118,
    "residents_share": 1
   },
   "percentile_among_peers": 0.798,
   "peers": "52 provinces with a value",
   "ratio_to_spain": 1.04
  },
  "residents": {
   "value": 90234,
   "display": "90.234",
   "method": "municipal_sum",
   "coverage": {
    "municipalities_with_value": 183,
    "municipalities": 183
   },
   "percentile_among_peers": 0.0481,
   "peers": "52 provinces with a value"
  }
 },
 "datasets.age.method_text": "the mean of the hexes' values weighted by their residents (INE Padrón 1 January 2025 shared among the hexes as the population lens shares it); hexes without residents do not count",
 "datasets.age.source": {
  "id": "ine_adrh_indicadores",
  "title": "Atlas de Distribución de Renta de los Hogares (ADRH): indicadores demográficos (tabla 30832) y umbrales relativos de renta (tabla 30829)",
  "publisher": "Instituto Nacional de Estadística (INE)",
  "license": "CC BY 4.0 (aviso legal del INE): reutilización comercial y no comercial citando la fuente como «Elaboración propia con datos del INE»; el INE no avala este mapa",
  "vintage": "INE Atlas de Distribución de Renta de los Hogares, 2024",
  "homepage": "https://www.ine.es/dyngs/INEbase/es/operacion.htm?c=Estadistica_C&cid=1254736177088&menu=ultiDatos&idp=1254735976608"
 }
}
Hexes of Teruel province far from a hospital and with the oldest population

cross_datasets {"datasets": ["hospital", "age"], "level": "hex", "within": "provincia:Teruel", "directions": ["high", "high"], "limit": 3}

{
 "places_joined": 170,
 "correlation": {
  "hospital × age": {
   "pearson": 0.513,
   "spearman": 0.461
  }
 },
 "first_pair.quadrants": {
  "high_high": 55,
  "high_low": 30,
  "low_high": 32,
  "low_low": 53
 },
 "extremes.places": [
  {
   "place": {
    "level": "hex",
    "id": "7949",
    "name": "hex 7949",
    "lon": -0.9073,
    "lat": 41.0365,
    "province": "Teruel",
    "community": "Aragón",
    "municipality": "Huesa del Común",
    "main_towns": [
     "Blesa",
     "Huesa del Común"
    ],
    "residents": 76,
    "hexes": 1
   },
   "score": 0.99,
   "values": {
    "hospital": 110,
    "age": 62.5
   },
   "percentiles": {
    "hospital": 0.982,
    "age": 0.997
   }
  },
  {
   "place": {
    "level": "hex",
    "id": "8125",
    "name": "hex 8125",
    "lon": -0.732,
    "lat": 40.9543,
    "province": "Teruel",
    "community": "Aragón",
    "municipality": "Alcaine",
    "main_towns": [
     "Alcaine",
     "Josa"
    ],
    "residents": 70,
    "hexes": 1
   },
   "score": 0.984,
   "values": {
    "hospital": 110,
    "age": 60.1
   },
   "percentiles": {
    "hospital": 0.982,
    "age": 0.985
   }
  },
  {
   "place": {
    "level": "hex",
    "id": "8124",
    "name": "hex 8124",
    "lon": -0.8511,
    "lat": 40.9572,
    "province": "Teruel",
    "community": "Aragón",
    "municipality": "La Hoz de la Vieja",
    "main_towns": [
     "Cortes de Aragón",
     "La Hoz de la Vieja",
     "Maicas",
     "Plou"
    ],
    "residents": 186,
    "hexes": 1
   },
   "score": 0.982,
   "values": {
    "hospital": 118,
    "age": 57.1
   },
   "percentiles": {
    "hospital": 0.997,
    "age": 0.968
   }
  }
 ],
 "caveats": [
  "A correlation between places is not a relation between people (ecological fallacy), and neither is proof of cause.",
  "Neighbouring hexes share sources (a municipality's figure is spread over its hexes; a province's over all of them), so hex values are not independent and the correlations overstate the evidence."
 ],
 "datasets.hospital.source": {
  "id": "cnh_hospitales",
  "title": "Catálogo Nacional de Hospitales 2025 (hospitales en funcionamiento a 31 de diciembre de 2024)",
  "publisher": "Ministerio de Sanidad",
  "license": "Aviso legal del Ministerio de Sanidad: reutilización permitida, también comercial, citando la fuente y la fecha de su última actualización",
  "vintage": "Catálogo Nacional de Hospitales 2025 (31-12-2024) (actualizado 30-10-2025)",
  "homepage": "https://www.sanidad.gob.es/estadEstudios/estadisticas/sisInfSanSNS/ofertaRecursos/hospitales/home.htm"
 }
}
Provinces with high income and a young population

query_places {"level": "province", "datasets": ["income", "age"], "where": [{"dataset": "age", "op": "<", "value": 43}], "order_by": "income", "limit": 3}

{
 "matched": 11,
 "method": {
  "income": "resident_mean",
  "age": "resident_mean"
 },
 "rows.*.place.name": [
  "Madrid",
  "Illes Balears",
  "Girona"
 ],
 "rows.*.values": [
  {
   "income": {
    "value": 19267,
    "display": "19,3 mil €",
    "coverage": {
     "hexes_with_value": 93,
     "hexes": 93,
     "residents_share": 1
    }
   },
   "age": {
    "value": 42.876,
    "display": "42,9 años",
    "coverage": {
     "hexes_with_value": 93,
     "hexes": 93,
     "residents_share": 1
    }
   }
  },
  {
   "income": {
    "value": 17162,
    "display": "17,2 mil €",
    "coverage": {
     "hexes_with_value": 56,
     "hexes": 56,
     "residents_share": 1
    }
   },
   "age": {
    "value": 42.127,
    "display": "42,1 años",
    "coverage": {
     "hexes_with_value": 56,
     "hexes": 56,
     "residents_share": 1
    }
   }
  },
  {
   "income": {
    "value": 16021,
    "display": "16 mil €",
    "coverage": {
     "hexes_with_value": 69,
     "hexes": 69,
     "residents_share": 1
    }
   },
   "age": {
    "value": 42.674,
    "display": "42,7 años",
    "coverage": {
     "hexes_with_value": 69,
     "hexes": 69,
     "residents_share": 1
    }
   }
  }
 ]
}
Soria's residents by year

timeseries {"series": "residents", "place": "Soria"}

{
 "years": [
  2016,
  2017,
  2018,
  2019,
  2020,
  2021,
  2022,
  2023,
  2024,
  2025
 ],
 "values": [
  92683,
  91498,
  91176,
  91161,
  91403,
  91252,
  90870,
  91980,
  92662,
  92742
 ],
 "municipal_padron": {
  "year": 2025,
  "value": 90234,
  "hex_sum_differs_by": 0.0278,
  "why": "A hex belongs to the province holding most of its land, so hexes on a border carry residents of the neighbouring province's municipalities (and miss some of its own). The change from year to year is the reliable part."
 }
}
What the source does not publish

timeseries {"series": "gdp_per_capita", "place": "municipio:Soria"}

gdp_per_capita is published for province, community, spain; Soria is a municipality. El INE publica el PIB por provincia, no por debajo.
A seeded game for a tournament

hex_game_start {"seed": 2026}

{
 "token": "hx1.eyJ2IjoxLCJzZWVkIjoyMDI2LCJtb2RlIjoibm9ybWFsIiwiZ3Vlc3NlcyI6W10sImNsdWVzIjoxfQ",
 "clues": [
  {
   "title": "Dónde está",
   "facts": [
    {
     "label": "Zona",
     "value": "Oeste de la península"
    },
    {
     "label": "Mar",
     "value": "A entre 100 y 200 km del mar"
    },
    {
     "label": "Altitud media",
     "value": "265 m"
    }
   ]
  }
 ],
 "rules": "Find the 10 km hex the clues describe. 6 guesses; within 25 km wins. Points: 100 within 25 km, falling to 0 at 600 km, minus 10 per clue after the first or per missed guess, whichever are more; a lost game scores at most 49. A miss opens the next clue. Guess with a hex id, «lat,lon» or a municipality name."
}
First guess

hex_game_guess {"token": "hx1.eyJ2IjoxLCJzZWVkIjoyMDI2LCJtb2RlIjoibm9ybWFsIiwiZ3Vlc3NlcyI6W10sImNsdWVzIjoxfQ", "guess": "Madrid"}

{
 "guesses": [
  {
   "hex": 9492,
   "municipality": "Madrid",
   "province": "Madrid",
   "km": 338,
   "direction_to_answer": "sw",
   "square": "🟥"
  }
 ],
 "clues_shown": 2
}
«Tres ciudades», day 8's daily mode

tres_ciudades_start {"mode": "daily", "day": 8}

{
 "region": {
  "code": "12",
  "name": "Galicia"
 },
 "suggested_sites.economy": {
  "hex": 5101,
  "municipality": "Mos",
  "province": "Pontevedra",
  "residents": 57755
 }
}
Found where the Economy advisor says and let it govern

tres_ciudades_play {"token": "P6-qair8a-d8@0", "moves": [{"found": 5101}, {"end_turn": true}, {"govern": "economy"}]}

{
 "over": true,
 "score.total": 10242,
 "mark": {
  "versus_best_found": 0.882,
  "best_total": 11606,
  "sentence": "Tu partida suma casi el 90 % de los puntos de la mejor que encontró el juego."
 },
 "website.url": "https://spainciv.djinnfoundry.com/juego#juego=partida&partida=P6-qair8a-d8-f3xp.g001"
}
Unciv: set up the engine

unciv_setup {"mod_zip": "dist/spainciv/unciv/Spainciv-Unciv.zip"}

{
 "unciv.version": "5.0.4",
 "bridge": true,
 "mod": true
}
Unciv: a game on the España map

unciv_new_game {"civ": "Aragón", "ai": ["Navarra", "Cataluña (Catalunya)"]}

{
 "ok": true,
 "turn": 0,
 "currentPlayer": "Aragón",
 "mods": [
  "Spainciv Unciv"
 ]
}
Unciv: what Aragón can do

unciv_state {"game_id": "981ab09c-8d69-45c9-a8b4-bfb15e93a495"}

{
 "agents_turn": true,
 "can.researchable": [
  "Pottery",
  "Animal Husbandry",
  "Archery",
  "Mining"
 ],
 "can.units": [
  {
   "id": 2,
   "name": "Warrior",
   "at": [
    5,
    20
   ],
   "movement": 2,
   "health": 100,
   "actions": [
    "Pillage",
    "Automate",
    "Fortify",
    "Explore",
    "Skip",
    "EscortFormation"
   ]
  },
  {
   "id": 1,
   "name": "Settler",
   "at": [
    5,
    20
   ],
   "movement": 2,
   "health": 100,
   "actions": [
    "FoundCity",
    "Automate",
    "Sleep",
    "Explore",
    "Skip",
    "EscortFormation"
   ]
  }
 ]
}
Unciv: found Zaragoza and research

unciv_play_turn {"game_id": "981ab09c-8d69-45c9-a8b4-bfb15e93a495", "orders": [{"order": "research", "tech": "Pottery"}, {"order": "action", "unit": 1, "type": "FoundCity"}]}

{
 "applied": [
  "research",
  "action"
 ],
 "turn": 1,
 "currentPlayer": "Aragón"
}
Unciv: the city, now in the engine

unciv_state {"game_id": "981ab09c-8d69-45c9-a8b4-bfb15e93a495"}

{
 "turn": 1,
 "you.cities": [
  {
   "name": "Zaragoza",
   "at": [
    5,
    20
   ],
   "population": 1,
   "food_stored": 1,
   "queue": [],
   "in_progress": {},
   "buildings": [
    "Palace"
   ],
   "tiles": 7,
   "worked": [
    [
     6,
     21
    ]
   ]
  }
 ],
 "can.cities.0.yields": {
  "production": 5,
  "food": 1,
  "gold": 7,
  "science": 4,
  "culture": 1,
  "happiness": 1
 },
 "can.cities.0.can_build": [
  "Worker",
  "Scout",
  "Warrior",
  "Monument"
 ]
}

Code

The server is in the mcp/ folder of the repository, under the MIT licence, like the map.