MCP server

Give an assistant the dataset, to look up any place by name or by point.

Server

URL
https://communes.pages.dev/mcp

Streamable HTTP, with no sign-in. Every tool only reads.

Connect

In a chat app, it answers questions about places. In an editor, the assistant reads real codes and figures while it writes the seed file, form or test that needs them.

Let the assistant do it

If you don't know where your app keeps its settings, paste this to the assistant itself.

prompt
Add this MCP server to your own configuration, then use it.

  name       morocco-communes
  url        https://communes.pages.dev/mcp
  transport  Streamable HTTP
  auth       none. It's a public, read-only dataset server, so no key,
             token or OAuth step is needed.

1. Find where this app keeps its MCP servers, and use its own command
   if it has one, such as `claude mcp add`, rather than editing a file
   by hand.
2. Add the server under that name. If this app speaks only stdio, run
   it through a bridge instead: npx mcp-remote https://communes.pages.dev/mcp
3. Tell me what you wrote and where, and whether I need to restart for
   it to load.
4. Call the server once and tell me which province Tafraout is in. If
   its tools aren't loaded yet, say so rather than answering from
   memory.

Claude Code

Add --scope project to share it with a repository through its .mcp.json.

shell
claude mcp add --transport http morocco-communes https://communes.pages.dev/mcp

Claude and Claude Desktop

In Customize › Connectors, choose + then Add custom connector, and paste the URL above. Any plan can add it; the free plan allows one. On Team and Enterprise, an owner adds it under Organization settings › Connectors.

ChatGPT

Turn on Developer mode in Settings › Security and login, then add the URL above at chatgpt.com/plugins. It’s on the Plus, Pro, Business, Enterprise and Education plans, on the web. On Business and Enterprise, an admin has to allow it.

Cursor

In .cursor/mcp.json for one project, or ~/.cursor/mcp.json for all of them.

.cursor/mcp.json
{
  "mcpServers": {
    "morocco-communes": {
      "url": "https://communes.pages.dev/mcp"
    }
  }
}

VS Code

In .vscode/mcp.json. The top-level key is servers, and type is required.

.vscode/mcp.json
{
  "servers": {
    "morocco-communes": {
      "type": "http",
      "url": "https://communes.pages.dev/mcp"
    }
  }
}

Claude API

The MCP connector is in beta, behind the header below.

shell
curl https://api.anthropic.com/v1/messages \
  -H "content-type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "anthropic-beta: mcp-client-2025-11-20" \
  -d '{
    "model": "claude-opus-5",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": "Which province is Tafraout in?"
      }
    ],
    "mcp_servers": [
      {
        "type": "url",
        "url": "https://communes.pages.dev/mcp",
        "name": "morocco-communes"
      }
    ],
    "tools": [
      {
        "type": "mcp_toolset",
        "mcp_server_name": "morocco-communes"
      }
    ]
  }'

OpenAI API

A remote MCP tool in the Responses API. Every tool here only reads, so approvals can be skipped.

shell
curl https://api.openai.com/v1/responses \
  -H "content-type: application/json" \
  -H "authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-6-astra",
    "tools": [
      {
        "type": "mcp",
        "server_label": "morocco-communes",
        "server_url": "https://communes.pages.dev/mcp",
        "require_approval": "never"
      }
    ],
    "input": "Which province is Tafraout in?"
  }'

Tools

The descriptions are the ones the model reads.

get_commune Get one commune

One commune's names, type, région, province and cercle, 2024 and 2014 population, the change between them, a point inside it, the communes it borders and how much boundary it shares with each, and in the 6 cities divided into them, its arrondissements with their population. Identify it by HCP code (01.511.01.0), the code as digits, or a slug (tanger).

idrequired
stringAn HCP code, the code as digits, or a slug.

communes_near Communes near a point

Communes within a radius of a point, nearest first. Distance is measured to each commune's centroid, so the nearest commune isn't always the one that contains the point: commune_at gives that one.

latrequired
number [−90, 90]Latitude, in degrees.
lngrequired
number [−180, 180]Longitude, in degrees.
radius_km
number (0, 100]Radius in km. 10 when left out, at most 100.
limit
integer [1, 50]How many results. 10 when left out, at most 50.

commune_at Commune at a point

The commune whose boundary contains a point, with its names, type, parents and population, and in Casablanca, Rabat, Fès, Marrakech, Salé and Tanger the arrondissement too. Use it to turn coordinates, from a map or a device, into a commune. Sidi Mohamed Benmansour has no boundary, and neither do about 88 km² between Ifrane and Boulemane.

latrequired
number [−90, 90]Latitude, in degrees.
lngrequired
number [−180, 180]Longitude, in degrees.

list_communes List communes

Communes filtered by région, province or préfecture, cercle, type or population, 50 to a page, in code order or sorted by name, population, change since 2014, density, area, any census indicator or any establishment count. Filters combine; each unit can be given by code or slug. With no filter it lists every commune, so sort: "-population" alone gives the largest in the country.

region
stringA région, by code or slug.
province
stringA province or préfecture, by code or slug.
cercle
stringA cercle, by code or slug.
type
urban | ruralUrban or rural communes only.
sort
stringA field to order by: code, name, population, change, density, area, or a census indicator by its path, such as labour.unemploymentRate or amenities.runningWater, as get_indicators names them. Put 2014. before the path for the 2014 figure, or change. for how far it moved since, as in change.illiteracy.rate10Plus. An establishment count goes under economy., as in economy.establishments.jobs or economy.sector.commerce, as get_economy names them. A count on its own ranks the biggest places first, so 3 figures worked out from 2 counts rank by size of place rather than size: economy.per1000.establishments, economy.per1000.jobs and economy.perBusiness.jobs. A leading minus puts the largest first. Code order when left out.
min_population
integer [0, 10 000 000]Only communes with at least this many people in 2024.
max_population
integer [0, 10 000 000]Only communes with at most this many people in 2024.
page
integer [1, 10 000]Page number, from 1.

get_unit A région, province or cercle

One région, province, préfecture or cercle: its name in French and Arabic, its 2024 population and households, the units above it, how many units it holds, and the ones directly under it, named: a région's provinces, a province's cercles. This is the tool for a question about a unit above the commune, such as how many cercles a province has. For a commune or an arrondissement, call get_commune; to list a unit's communes, call list_communes with that unit.

unitrequired
stringA région, province, préfecture or cercle, by code or slug.
level
region | province | cercleThe level, where a name is shared: Tiznit is a commune and a province, and a name alone means the commune.

get_indicators Census indicators

HCP's census figures for Morocco or any région, province or préfecture, cercle, commune or arrondissement: age, marital status, fertility, disability, schooling, illiteracy, the languages people read and write and the local languages they use, education, work, employment status and how people get to work, and for households their size, dwelling, occupancy, amenities, wastewater, waste and cooking fuel.

Reading them: shares and rates are percentages from 0 to 100. Null means HCP publishes no figure there. Most come from the long questionnaire, which went to a random 20% of households in communes of 2,000 households or more, so there they're estimates.

Ranking and comparing: to order communes by one figure, call list_communes with sort set to its path. To compare the régions, the provinces or the arrondissements, give level without a unit and get them all in one call.

The 2014 census is here too, under census. Age, education, local languages, illiteracy, fertility, disability, work, the ways of getting to work, dwellings, amenities, wastewater and waste ask what 2024 asks and can be read against it. Where people work and how children get to school are 2014 only. Five topics changed and can't be subtracted: marital status covered everyone rather than people aged 15 and over, schooling ages 7 to 12 rather than 6 to 11, reading and writing was asked as combinations of languages rather than one at a time, a household counted under every cooking fuel it used, and the employment shares took in unemployed people who had worked before. A unit the 2014 census didn't count has null there, Casablanca and the 5 other cities with arrondissements among them, since 2014 published those by arrondissement.

unit
stringA région, province or préfecture, cercle, commune or arrondissement, by code or slug. Morocco as a whole when left out.
level
commune | arrondissement | province | region | cercleWith a unit, the level it's at, where a name is shared: Tiznit is a commune and a province, and a name alone means the commune. Without a unit, region, province or arrondissement gives every one of that level in one call.
topics
(population | sex | age | maritalStatus | fertility | disability | schooling | illiteracy | languagesReadAndWritten | education | localLanguages | labour | employmentStatus | commute | households | dwellingType | occupancy | dwellingAge | amenities | wastewater | householdWaste | cookingFuel)[]Only these topics. Every topic when left out. Two are easy to confuse: labour holds the labour force, the activity rate and the unemployment rate, while employmentStatus is how the people in work are employed, as employees, self-employed or apprentices.
area
total | urban | rural | eachThe whole unit (total), its urban or rural part, or each of the three. total when left out.
sex
all | male | female | eachEveryone (all), men, women, or each of the three. all when left out. Household figures have no sex.
census
2014 | 2024 | bothWhich census. 2024 when left out. both gives the two together, to see what changed.

get_economy Economic establishments

HCP's 2024 count of economic establishments for Morocco or any région, province or préfecture, cercle, commune or arrondissement: how many establishments were mapped, how many are public services, how many are associations in premises of their own, how many are businesses, and how many permanent jobs those businesses hold. The businesses are split three ways, each covering all of them: by sector (industry, construction, commerce, services), by how many people work there (1, 2-3, 4-9, 10-49, 50 and over), and by when they were founded (before 1956 through 2020 and later). The weekly souks in use are counted beside them and are not part of the total.

Reading them: every figure is a count, taken during the census by field teams who mapped each establishment. Farming is out, the workbook counts every sector but agriculture, and the jobs are the permanent ones.

Ranking and comparing: to order communes by one of these, call list_communes with sort set to its path, such as economy.establishments.jobs, or by one of the 3 it works out from them: economy.per1000.establishments, economy.per1000.jobs, economy.perBusiness.jobs. To compare the régions, the provinces or the arrondissements, give level without a unit and get them all in one call.

Casablanca and the 5 other cities divided into arrondissements are counted by arrondissement, so their figures are the sum of those, marked basis: arrondissement_sum. Say so when you report one.

unit
stringA région, province or préfecture, cercle, commune or arrondissement, by code or slug. Morocco as a whole when left out.
level
commune | arrondissement | province | region | cercleWith a unit, the level it's at, where a name is shared: Tiznit is a commune and a province, and a name alone means the commune. Without a unit, region, province or arrondissement gives every one of that level in one call.
topics
(establishments | sector | size | founded)[]Only these topics. Every topic when left out.

get_housing Urban housing stock

HCP's 2024 count of urban dwellings for Morocco or any unit that has an urban area: how many there are, how many are occupied, vacant or second homes, what kind they are (villa, apartment, traditional or modern Moroccan house, slum, rural-type), how old they are, what their walls and roofs are made of, how many are on the public electricity, water and sewerage networks, and HCP's housing shortfall. Every figure but the count is a percentage of that unit's urban dwellings. This counts dwellings, not households: a vacant flat is here and in nobody's census record, and get_indicators describes the dwelling each household lives in, for the whole country rather than the towns. A unit with no urban area has nothing here.

unit
stringA unit by code or slug. Morocco as a whole when left out.
level
commune | arrondissement | province | region | cercleWith a unit, the level it's at. Without one, region, province or arrondissement gives every one of that level.
topics
(dwellings | occupancy | type | age | ageByType | walls | roofs | networks)[]Only these topics. Every topic when left out.

Things to ask

The model calls the tools on its own. For example:

  • Which province is Tafraout in, and how many people live there?
  • Which rural communes of Chefchaouen province lost people between 2014 and 2024?
  • Which commune is 30.42, −9.60 in?
  • Where is unemployment highest among communes of more than 50,000 people?
  • How many women in Tafraout can’t read or write, compared with men?
  • Where did illiteracy fall the most between the 2014 and 2024 censuses?