Skip to content
Field Guide

Connect an AI assistant · 9 minutes

Let an AI assistant look the statistics up itself

The platform ships a Model Context Protocol endpoint. Point a compatible assistant at it and, instead of recalling a plausible-sounding figure, it will search the UN corpus, fetch the observation, and tell you the provenance. This is the difference between an assistant that sounds authoritative and one that is.

The endpoint

Streamable HTTP, no API key, no account. This is the address to give your client.
https://unsd-datacommons.gcp.un-icc.cloud/mcp

Other UN Data Commons addresses you may come across are older deployments and are not intended for external use. This is the one the platform's own documentation points at.

Set it up in the client you already use

All four are the same two facts — a name and a URL. Pick your client and paste.
Claude Code — one command
claude mcp add --transport http un-data https://unsd-datacommons.gcp.un-icc.cloud/mcp

# confirm it connected
claude mcp list
Claude Desktop — claude_desktop_config.json
{
  "mcpServers": {
    "un-data": {
      "type": "http",
      "url": "https://unsd-datacommons.gcp.un-icc.cloud/mcp"
    }
  }
}
VS Code — .vscode/mcp.json
{
  "servers": {
    "un-data": {
      "type": "http",
      "url": "https://unsd-datacommons.gcp.un-icc.cloud/mcp"
    }
  }
}
Cursor — .cursor/mcp.json
{
  "mcpServers": {
    "un-data": {
      "url": "https://unsd-datacommons.gcp.un-icc.cloud/mcp"
    }
  }
}

How to tell it worked

Ask it something only the platform knows, and watch for a tool call in the transcript: “Using un-data, what is South Sudan's conflict-related death rate per 100,000 in 2024, and where does that figure come from?” The right answer is 13.07, sourced to the UN Statistics Division SDG data portal. If you get a number with no tool call, the server is not connected and the model is recalling.

If your assistant has no MCP support

Most web chatbots do not. You are not stuck: fetch the numbers first and paste them in, which is what the Use AI with UN data page is about. Giving a model the statistic and asking what it means is safe; asking it what the statistic is, is not.

A second connector, for when you want the analysis too

The platform's endpoint searches and fetches. undata's connector adds the UN's country groups, the SDG progress method and charts. You can connect both.

What it adds

  • Places by name, including UN M49 regions and the current LDC, LLDC and SIDS lists, with official UN names in the answer.
  • Progress towards a 2030 target by the UN Statistics Division's published method, country profiles against region and world, and gaps between groups (women and men, rural and urban) compared in the same year.
  • Every answer carries the source, the year of each value and the countries with no data; analysis tools can return a chart as an image.

Fourteen read-only tools, no key. It runs on your machine and needs uv, which installs it on first use. Unofficial, by the author of this guide, and part of the undata Python package.

Claude Code — one command
claude mcp add undata -- uvx --from "undata[mcp]" undata-mcp
Claude Desktop — add to claude_desktop_config.json
{
  "mcpServers": {
    "undata": {
      "command": "uvx",
      "args": ["--from", "undata[mcp]", "undata-mcp"]
    }
  }
}

Then ask: “Which least developed countries are on track to bring maternal mortality below 70 by 2030? Show me a chart.” The full tool list is in the undata reference ↗.

What actually happens when you ask

One question, traced through the server. This is the sequence the playbooks tell the model to follow, and it is the same discipline the rest of this guide argues for by hand.

You type

“Using un-data, how has South Sudan's conflict-related death rate moved since 2015? Give me the source and tell me if any year is missing.”

  1. 01

    It reads the playbook first

    The tool descriptions instruct the client to read skill://data-commons-researcher/SKILL.md before the first call. That resource is 11,000 words of method — concept splitting, place qualification, how to read each response — and it is why a well-behaved client searches before it fetches.

  2. 02

    Discovery — it finds candidate variables

    It does not guess an identifier. It searches, and gets back topics and the variables inside them, including the dimension-sliced variants. Note what surfaces here: a rate per 100,000 as well as a raw count.

  3. 03

    Assessment — it qualifies before it fetches

    get_variable_metadata returns the facets: which provenance, what date range, which entities are covered. This is the step that catches a variable that looks right and has no data for your country.

  4. 04

    Retrieval — and only now the numbers

    The observation response carries sourceMetadata alongside the values, so the model has the provenance in the same payload as the figure. It has no excuse for an unattributed number.

what step 4 returns, trimmed — this is real
{
  "variable": {
    "dcid": "undata/sdg/VC_DTH_TOTR",
    "name": "Number of total conflict-related deaths per 100,000 population"
  },
  "sourceMetadata": {
    "provenanceUrl": "https://unstats.un.org/sdgs/dataportal",
    "observationPeriod": "P1Y",
    "unit": "undata/UNIT_MEASURE-RATIO_COUNT_PER_100000_COUNT_POP"
  },
  "entityMetadata": {
    "columns": ["dcid", "name", "typeOf"],
    "rows": [["country/SSD", "South Sudan", ["Country"]]]
  },
  "data": {
    "columns": ["observationAbout", "date", "value"],
    "rows": [
      ["country/SSD", "2015", 21.76896], ["country/SSD", "2016", 25.9185],
      ["country/SSD", "2017",  7.59322], ["country/SSD", "2018", 14.95607],
      ["country/SSD", "2019", 10.8506 ], ["country/SSD", "2020", 22.62941],
      ["country/SSD", "2021", 17.55051], ["country/SSD", "2022", 14.51751],
      ["country/SSD", "2023", 13.27136], ["country/SSD", "2024", 13.06997]
    ]
  }
}

Worth comparing with the REST shape: this is columns-and-rows with the provenance beside it, rather than a record keyed two levels deep with the facets held in a separate object. The MCP surface is the friendlier one to read — for a model and for you.

The six tools, with a real call for each

Five work against this deployment today. One does not, and it is marked. The two search tools work only if you hand them place names rather than dcids — the reverse of what the rest of the API teaches.
search_indicators

Find statistical variables matching a natural-language query. The discovery step, and the one the server insists you do first.

arguments
{"query":"maternal mortality","per_search_limit":10,"include_topics":false}

Search one concept at a time — the playbook is explicit that "health and unemployment" confuses the index. The optional places argument works, but only with plain names: places: ["Kenya"] succeeds where places: ["country/KEN"] returns 500 (trap 3).

search_child_indicators

The same, for variables available at the child-place level inside a parent — the sub-national equivalent.

arguments
{"query":"population","parent_place":"Africa","sample_child_places":["Kenya","Ethiopia"]}

Reachable, but only by name. sample_child_places must hold plain names — one dcid anywhere in that list returns 500. parent_place is relaxed and takes either "Africa" or africa. Note also that child_place_type is not a parameter here, unlike get_child_observations; passing it fails validation.

get_variable_metadata

Definitions, date ranges, provenances and entity coverage for a list of variables. Use it to qualify a series before pulling data.

arguments
{"variable_dcids":["undata/sdg/VC_DTH_TOTR"],"entity_dcids":["country/SSD"]}

Returns facets with dateRange and entityCoverage. This is where you learn a variable has ten observations, not forty.

get_observations

Time series for one variable at one place, with source metadata in the same payload.

arguments
{"variable_dcid":"undata/sdg/VC_DTH_TOTR","place_dcid":"country/SSD","date":"all"}

date defaults to "latest". Pass "all" for the history, or date_range_start and date_range_end for a window.

get_child_observations

The same across every child place of a type inside a parent — the one-request regional ranking.

arguments
{"variable_dcid":"undata/sdg/VC_DTH_TOTR","parent_place_dcid":"Earth","child_place_type":"Country","date":"latest"}

Returns 14 countries for this variable, and names them. The same 14 the REST containment query returns, which is a useful consistency check.

get_multi_entity_observationsNo data here

Relationship variables with more than one entity — aid flows, bilateral trade, migration corridors.

arguments
{"variable_dcid":"Amount_EconomicActivity_GrossODA","entities":{"donor":["country/ARE"],"recipient":["country/AFG"]}}

Returns HTTP 500 on this deployment: the SDMX backend rejects donor and recipient as filter components. Treat this tool as unavailable here.

The playbooks, which matter more than they sound

The server publishes its own instructions to the model. Reading them is the fastest way to understand what good use of this data looks like.

Three resources — skill://data-commons-researcher/SKILL.md for single-place work, …child-places-researcher… for sub-national breakdowns, and …multi-entity-researcher… for bilateral flows. Each has a JSON manifest beside it, so resources/list returns six entries rather than three.

The researcher playbook is about 11,000 words and its spine is a three-step pipeline: discovery with search_indicators, assessment with get_variable_metadata, then retrieval. It is the same sequence this guide recommends for a human, written for a machine.

It is also where the hard rules live: never guess a dcid, search one concept at a time, keep per_search_limit at ten, and check country-level coverage before assuming a sub-national series exists.

read one yourself
curl -s -X POST 'https://unsd-datacommons.gcp.un-icc.cloud/mcp' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"resources/read","params":{"uri":"skill://data-commons-researcher/SKILL.md"}}' \
  | sed -n 's/^data: //p' | tail -1 \
  | python3 -c 'import json,sys; print(json.load(sys.stdin)["result"]["contents"][0]["text"])'

# swap resources/read for resources/list to see all six,
# or initialize to read the server's own instructions to the model.

Four things that will bite you

Each was found by calling the server, and none of them is in any documentation.
  1. 1

    A guessed dcid returns success with no data

    Ask get_observations for undata/sdg/SH_STA_MORT — the bare maternal mortality code, which does not exist as a fetchable variable — and you get isError: false and "data": {}. No error, no explanation. A model handed that can reasonably narrate "no data is available", which is a different and much stronger claim than "that identifier is wrong". This is precisely why the server forbids guessing.

  2. 2

    The Accept header is mandatory

    Send Accept: application/json, or no Accept header at all, and every request returns 406 Not Acceptable. The transport is streamable HTTP, so the header must be Accept: application/json, text/event-stream. Real clients set it for you; anything hand-rolled, including curl, does not.

  3. 3

    A place argument must be a name, never a dcid

    The search tools look a place up in a name index first, and a miss falls through to a geocoder — a Google Maps legacy API that is not enabled on this project. So a value the index does not recognise comes back as HTTP 500 rather than as an empty result — a server error standing in for "no match". Plain names work: places: ["Kenya"] and sample_child_places: ["Kenya","Ethiopia"] both return SUCCESS. Dcids do not: country/KEN and wikidataId/Q114 both 500, and a single dcid anywhere in the list fails the whole call. This inverts the rule the REST surface teaches, where the dcid is always the safe form. The same fallback sits behind /core/api/v2/resolve, where one typo — Kenyaa — also answers 500 instead of returning no candidates.

  4. 4

    A line break in the body returns 403

    Like every other POST route on this deployment, /mcp rejects any body containing a newline with 403 Forbidden. Pretty-print a JSON-RPC message to read it and it stops working. Real MCP clients send compact JSON, so this only affects you when testing by hand.

Steer it around the broken paths

The server's own instructions push a model towards the two tools that do not work here. One paragraph in your project instructions fixes it permanently.

This is worth doing rather than repeating yourself. The playbook tells the model that a question about “countries in Africa” must route to search_child_indicators, and that searches should be scoped to places to verify coverage. Both instructions lead straight into the 500.

Left alone, a model that hits it will usually retry, fail again, and then either give up or — much worse — answer from its own recall without saying it stopped using the tools. The paragraph opposite removes the ambiguity.

Put it wherever your client keeps standing instructions: CLAUDE.md for Claude Code, project instructions in Claude Desktop, a rules file in Cursor or VS Code. It costs nothing per turn and it converts two dead ends into two working routes.

paste into your project instructions
When using the un-data MCP server:

- Call search_indicators WITHOUT the "places" argument.
  Passing places returns HTTP 500 on this deployment.
- Never call search_child_indicators. It is unreachable
  here — both of its place arguments are required and both
  fail. For anything across a region, use search_indicators
  (no places) to get the variable, then get_child_observations
  with parent_place_dcid and child_place_type.
- get_multi_entity_observations has no data on this
  deployment. Do not attempt bilateral flows, trade or
  aid-corridor questions with it.
- An empty "data": {} is a wrong identifier, not an absence
  of data. Re-run search_indicators rather than reporting
  "no data available".
- Cite the provenanceUrl from sourceMetadata with every
  figure, and state the reference year.

Four prompts worth keeping

Written to exploit what the tools are actually good at, rather than asking the model to be clever.
  • Sourced retrieval

    “Using un-data, get total conflict-related deaths for South Sudan and DR Congo, under-18 and 18-plus, for every year available. Give me the provenance and observation period for each series, and tell me explicitly if a requested slice has no data.”

    Asking for the provenance and for explicit gaps is what stops the model filling silence with plausible numbers.

  • Indicator triage

    “Using un-data, I need maternal mortality for Bangladesh. Before fetching anything, run search_indicators, then get_variable_metadata on the candidates, and show me the definitions and coverage. Recommend one for an SDG-aligned report and say why you rejected the others.”

    Names the two tools in the order the playbook wants them. This is the case where the bare identifier returns an empty success, and the metadata step catches it.

  • Regional scan

    “Using un-data, use get_child_observations for the intentional homicide rate across all countries in Africa. Report the reference year per country, and tell me the range of years — I need to know whether this is a cross-section or a ranking.”

    The years are the story. Asking for the range makes the mixed-vintage problem the model’s job rather than something you discover after publishing.

  • Coverage check before committing

    “Using un-data, I want to plot conflict-related deaths per 100,000 against GDP per capita for as many countries as possible. Before doing anything else, tell me how many countries have each indicator and how many have both. Then tell me whether that sample can support the comparison.”

    The answer is 14, and they are all countries at war — which is the finding that stops the chart. Asking for the counts first is the single highest-value habit on this platform, and it is the same discipline the scenarios page works through by hand.

The last one is worked end to end, without an agent, on the scenarios page.

Verify any of this yourself

The live server is the source of truth for what it offers — not this page, and not any documentation. Ask it.
list the tools, then call one
MCP='https://unsd-datacommons.gcp.un-icc.cloud/mcp'
mcp () {
  curl -s -X POST "$MCP" \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/json, text/event-stream' \
    -d "$1" | sed -n 's/^data: //p' | tail -1 | python3 -m json.tool
}

mcp '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
mcp '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"get_observations","arguments":{"variable_dcid":"undata/sdg/VC_DTH_TOTR","place_dcid":"country/SSD","date":"all"}}}'

The response is a server-sent event stream, which is why the data: prefix is stripped before parsing. Keep each body on one line — see trap 4.

What this page leaves you with

Takeaway

MCP changes what the model can be held to. Every observation arrives with its provenance in the same payload, so an unattributed number is now a choice the assistant made rather than a limitation it had.

Takeaway

Search, qualify, then fetch. The server's own playbook enforces the three-step pipeline. Naming the tools in your prompt is the easiest way to make a model follow it.

Takeaway

An empty success is the dangerous case. A wrong identifier does not error here. Ask for coverage and for explicit gaps, every time, and you convert a silent emptiness into a stated one.

Takeaway

Five tools, not six — and name your places. get_multi_entity_observations has no data behind it. The other five work, but the two search tools take place names and answer 500 to a dcid, which is the opposite of the rule everywhere else. Knowing that now is cheaper than discovering it mid-conversation with a colleague watching.

Embedding a chart without writing any chart code

If you only need the platform's own visualisation on a page, the deployment ships Data Commons web components. Two lines and you have an attributed, interactive chart — no build step, no framework.

HTML
<script src="https://unsd-datacommons.gcp.un-icc.cloud/datacommons.js"></script>

<datacommons-line
  header="Total conflict-related deaths"
  variables="undata/sdg/VC_DTH_TOTN"
  places="country/SSD country/COD"
></datacommons-line>

The charts on this site are hand-built instead, because the guide needed control over the accessibility and colour behaviour. For most internal pages, the web component is the right trade and a tenth of the work.

↑ ↓ to move · Enter to open · A match inside a video opens the lesson at the moment the words are said.