Skip to main content
Glama
Hug0x0

mcp-reunion

reunion_get_commune_population

Retrieve INSEE population counts for La Réunion communes: municipal, counted-apart, and total figures. Filter by commune name or census year.

Instructions

INSEE official millésimé population counts for La Réunion communes. INSEE provides three population figures: municipal (people legally living in the commune), counted apart (e.g. students living elsewhere but counted at parents' home), and total (sum). Each row is one commune × one census year. Returns INSEE code, commune name, census year (the year the data was collected), use year (the year the figures officially apply), municipal/counted-apart/total populations, surface area, EPCI. Sorted by census year descending then total population descending.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
communeNoCommune name prefix match (e.g. "Saint-Denis")
yearNoCensus reference year (4 digits, INSEE publishes a "millésime" each year)
limitNoMax rows to return (1-500, default 100)

Implementation Reference

  • The tool 'reunion_get_commune_population' is registered as an MCP tool on lines 66-103. The handler (async function on line 74) queries the 'population-francaise-communespublic' dataset with optional filters for commune name and census year, then returns structured population data including INSEE code, commune name, census year, use year, municipal/counted-apart/total populations, area, and EPCI information.
    server.tool(
      'reunion_get_commune_population',
      'INSEE official millésimé population counts for La Réunion communes. INSEE provides three population figures: municipal (people legally living in the commune), counted apart (e.g. students living elsewhere but counted at parents\' home), and total (sum). Each row is one commune × one census year. Returns INSEE code, commune name, census year (the year the data was collected), use year (the year the figures officially apply), municipal/counted-apart/total populations, surface area, EPCI. Sorted by census year descending then total population descending.',
      {
        commune: z.string().optional().describe('Commune name prefix match (e.g. "Saint-Denis")'),
        year: z.number().int().optional().describe('Census reference year (4 digits, INSEE publishes a "millésime" each year)'),
        limit: z.number().int().min(1).max(500).default(100).describe('Max rows to return (1-500, default 100)'),
      },
      async ({ commune, year, limit }) => {
        try {
          const data = await client.getRecords<RecordObject>(DATASET_POPULATION, {
            where: buildWhere([
              commune ? `nom_de_la_commune LIKE ${quote(`${commune}%`)}` : undefined,
              year !== undefined ? `annee_recensement = ${year}` : undefined,
            ]),
            order_by: 'annee_recensement DESC, population_totale DESC',
            limit,
          });
          return jsonResult({
            total_rows: data.total_count,
            populations: data.results.map((row) => ({
              insee_code: pickString(row, ['code_insee']),
              commune: pickString(row, ['nom_de_la_commune']),
              census_year: pickNumber(row, ['annee_recensement']),
              use_year: pickNumber(row, ['annee_utilisation']),
              municipal_population: pickNumber(row, ['population_municipale']),
              counted_apart: pickNumber(row, ['population_comptee_a_part']),
              total_population: pickNumber(row, ['population_totale']),
              area: pickNumber(row, ['superficie']),
              epci: pickString(row, ['libepci']),
              epci_code: pickString(row, ['code_epci']),
            })),
          });
        } catch (error) {
          return errorResult(error instanceof Error ? error.message : 'Failed to fetch population');
        }
      }
    );
  • Input schema for 'reunion_get_commune_population' defines three optional parameters: 'commune' (string, name prefix match), 'year' (integer, census reference year), and 'limit' (integer, 1-500, default 100).
    {
      commune: z.string().optional().describe('Commune name prefix match (e.g. "Saint-Denis")'),
      year: z.number().int().optional().describe('Census reference year (4 digits, INSEE publishes a "millésime" each year)'),
      limit: z.number().int().min(1).max(500).default(100).describe('Max rows to return (1-500, default 100)'),
    },
  • The tool is registered via server.tool('reunion_get_commune_population', ...) inside registerTerritoryTools(), which is called from registerAllTools() in src/modules/index.ts (line 51).
    server.tool(
      'reunion_get_commune_population',
      'INSEE official millésimé population counts for La Réunion communes. INSEE provides three population figures: municipal (people legally living in the commune), counted apart (e.g. students living elsewhere but counted at parents\' home), and total (sum). Each row is one commune × one census year. Returns INSEE code, commune name, census year (the year the data was collected), use year (the year the figures officially apply), municipal/counted-apart/total populations, surface area, EPCI. Sorted by census year descending then total population descending.',
      {
        commune: z.string().optional().describe('Commune name prefix match (e.g. "Saint-Denis")'),
        year: z.number().int().optional().describe('Census reference year (4 digits, INSEE publishes a "millésime" each year)'),
        limit: z.number().int().min(1).max(500).default(100).describe('Max rows to return (1-500, default 100)'),
      },
      async ({ commune, year, limit }) => {
        try {
          const data = await client.getRecords<RecordObject>(DATASET_POPULATION, {
            where: buildWhere([
              commune ? `nom_de_la_commune LIKE ${quote(`${commune}%`)}` : undefined,
              year !== undefined ? `annee_recensement = ${year}` : undefined,
            ]),
            order_by: 'annee_recensement DESC, population_totale DESC',
            limit,
          });
          return jsonResult({
            total_rows: data.total_count,
            populations: data.results.map((row) => ({
              insee_code: pickString(row, ['code_insee']),
              commune: pickString(row, ['nom_de_la_commune']),
              census_year: pickNumber(row, ['annee_recensement']),
              use_year: pickNumber(row, ['annee_utilisation']),
              municipal_population: pickNumber(row, ['population_municipale']),
              counted_apart: pickNumber(row, ['population_comptee_a_part']),
              total_population: pickNumber(row, ['population_totale']),
              area: pickNumber(row, ['superficie']),
              epci: pickString(row, ['libepci']),
              epci_code: pickString(row, ['code_epci']),
            })),
          });
        } catch (error) {
          return errorResult(error instanceof Error ? error.message : 'Failed to fetch population');
        }
      }
    );
  • The buildWhere helper function is used to construct the ODSQL WHERE clause from optional filter conditions. It joins non-empty conditions with ' AND '.
    export function buildWhere(
      conditions: Array<string | undefined | null | false>
    ): string | undefined {
      const valid = conditions.filter((condition): condition is string => Boolean(condition));
      return valid.length > 0 ? valid.join(' AND ') : undefined;
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description compensates by detailing the output structure (one row per commune per census year, columns including INSEE code, names, populations, surface area, EPCI) and the sorting order. It does not discuss rate limits or caching, but the core behavioral aspects are well covered.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is brief (4 sentences) and front-loaded, with each sentence adding unique information: source, population figures, row structure, and sorting. No redundant or unclear language.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema, the description fully describes the return data (columns, sorting) and the data source. It covers all necessary context for an agent to understand what the tool does and what to expect.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Although schema description coverage is 100%, the description adds value by explaining the meaning of 'year' as census reference year (millésime) and describing the three population types, enhancing understanding of the parameters' purpose and the data they retrieve.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it returns INSEE official millésimé population counts for La Réunion communes, with specific definitions of three population figures. It distinguishes this from sibling population-related tools like reunion_commune_profile by focusing on multiple census years and detailed breakdowns.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for population data queries but provides no explicit guidance on when to use this tool versus alternatives like reunion_commune_profile or reunion_compare_communes. No exclusions or context for when not to use are given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Hug0x0/mcp-reunion'

If you have feedback or need assistance with the MCP directory API, please join our Discord server