Skip to main content
Glama
rvibek

UNHCR Population Data MCP Server

get_demographics_data

Retrieve UNHCR demographic data for forcibly displaced populations, including age and sex breakdowns, filtered by country of origin, asylum, year, and population type.

Instructions

    Get forcibly displaced populations demographics data from UNHCR. It shows breakdown by age and sex when available.

    Args:
        coo: Country of origin (ISO3 code) - Use for questions about forcibly displaced populations FROM a specific country
        coa: Country of asylum (ISO3 code) - Use for questions about forcibly displaced populations IN a specific country
        year: Year to filter by (defaults to 2025)
        coo_all: Set to True when breaking down results by ORIGIN country
        coa_all: Set to True when breaking down results by ASYLUM country
        pop_type: Set to True when asked about specific population types (e.g., refugees, asylum seekers, stateless persons)

    Returns:
        Demographics data from UNHCR API
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cooNo
coaNo
yearNo
coo_allNo
coa_allNo
pop_typeNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool handler for 'get_demographics_data', decorated with @server.tool(). It invokes the UNHCRAPIClient to fetch demographics data from the UNHCR API.
    @server.tool()
    def get_demographics_data(
        coo: str | None = None,
        coa: str | None = None,
        year: str | int | None = None,
        coo_all: bool = False,
        coa_all: bool = False,
        pop_type: bool = False,
    ) -> dict[str, Any]:
        """
        Get forcibly displaced populations demographics data from UNHCR. It shows breakdown by age and sex when available.
    
        Args:
            coo: Country of origin (ISO3 code) - Use for questions about forcibly displaced populations FROM a specific country
            coa: Country of asylum (ISO3 code) - Use for questions about forcibly displaced populations IN a specific country
            year: Year to filter by (defaults to 2025)
            coo_all: Set to True when breaking down results by ORIGIN country
            coa_all: Set to True when breaking down results by ASYLUM country
            pop_type: Set to True when asked about specific population types (e.g., refugees, asylum seekers, stateless persons)
    
        Returns:
            Demographics data from UNHCR API
        """
        return api_client.get_demographics(
            coo=coo, coa=coa, year=year, coo_all=coo_all, coa_all=coa_all, pop_type=pop_type
        )
  • Helper method in the UNHCRAPIClient class that calls the generic _fetch method specifically for the 'demographics' endpoint.
    def get_demographics(self, coo: Optional[str] = None, coa: Optional[str] = None, 
                         year: Optional[Union[str, int]] = None, coo_all: bool = False, 
                         coa_all: bool = False, pop_type: bool = False) -> dict[str, Any]:
        return self._fetch("demographics", coo=coo, coa=coa, year=year, coo_all=coo_all, coa_all=coa_all, pop_type=pop_type)
  • Core helper function _fetch in UNHCRAPIClient that constructs API parameters and makes HTTP requests to UNHCR endpoints.
         pop_type: Optional[bool] = None) -> dict[str, Any]:
    """
    Generic function to fetch data from various UNHCR API endpoints.
    """
    params = {"cf_type": "ISO"}
    
    if coo:
        params["coo"] = coo
    if coa:
        params["coa"] = coa
    if coo_all:
        params["coo_all"] = "true"
    if coa_all:
        params["coa_all"] = "true"
    
    if pop_type is True:
        params["pop_type"] = "true"            
    
    if year is None:
        # Default to 2025 as per previous implementation logic
        params["year[]"] = "2025"
    else:
        year_str = str(year)
        if "," in year_str:
            years = [y.strip() for y in year_str.split(",")]
            params["year[]"] = years
        else:
            params["year[]"] = year_str
    
    url = f"{self.BASE_URL}/{endpoint}/"
    
    try:
        logger.info(f"Fetching UNHCR {endpoint} data with params: {params}")
        response = requests.get(url, params=params)
        response.raise_for_status()
        return response.json()
    except requests.RequestException as e:
        logger.error(f"Error fetching UNHCR {endpoint} data: {e}")
        return {"error": str(e), "status": "error"}
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the data source ('UNHCR API') and that breakdowns are available 'when available,' which adds some context. However, it lacks critical behavioral details such as rate limits, authentication requirements, error handling, or whether this is a read-only operation (implied by 'Get' but not explicit).

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

Conciseness4/5

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

The description is well-structured with a purpose statement followed by 'Args:' and 'Returns:' sections. It's appropriately sized with no redundant sentences, though the parameter explanations are detailed, which is necessary given the lack of schema descriptions. It could be slightly more front-loaded with a clearer distinction from siblings.

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

Completeness4/5

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

Given the complexity (6 parameters, no annotations, but with an output schema), the description is mostly complete. It covers all parameters thoroughly and mentions the data source. The output schema exists, so the description doesn't need to detail return values. However, it lacks some behavioral context like error cases or performance considerations.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by providing clear semantics for all 6 parameters. Each parameter is explained with purpose, format (e.g., 'ISO3 code'), default values (e.g., 'defaults to 2025'), and usage context (e.g., 'Set to True when breaking down results by ORIGIN country'). This adds significant value beyond the bare schema.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Get forcibly displaced populations demographics data from UNHCR' with specific mention of 'breakdown by age and sex when available.' This provides a specific verb ('Get') and resource ('demographics data'), though it doesn't explicitly differentiate from sibling tools like 'get_population_data' beyond mentioning demographics breakdown.

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 provides implied usage guidance through parameter explanations (e.g., 'Use for questions about forcibly displaced populations FROM a specific country'), but it doesn't explicitly state when to use this tool versus alternatives like 'get_population_data' or other siblings. The guidance is helpful but not comprehensive for tool selection.

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/rvibek/mcp_unhcr'

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