Let an AI assistant look the statistics up itself
The endpoint
https://unsd-datacommons.gcp.un-icc.cloud/mcpOther 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
claude mcp add --transport http un-data https://unsd-datacommons.gcp.un-icc.cloud/mcp
# confirm it connected
claude mcp list{
"mcpServers": {
"un-data": {
"type": "http",
"url": "https://unsd-datacommons.gcp.un-icc.cloud/mcp"
}
}
}{
"servers": {
"un-data": {
"type": "http",
"url": "https://unsd-datacommons.gcp.un-icc.cloud/mcp"
}
}
}{
"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
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 mcp add undata -- uvx --from "undata[mcp]" undata-mcp{
"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
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.”
- 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.
- 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.
- 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.
- 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.
{
"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
search_indicatorsFind statistical variables matching a natural-language query. The discovery step, and the one the server insists you do first.
{"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_indicatorsThe same, for variables available at the child-place level inside a parent — the sub-national equivalent.
{"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_metadataDefinitions, date ranges, provenances and entity coverage for a list of variables. Use it to qualify a series before pulling data.
{"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_observationsTime series for one variable at one place, with source metadata in the same payload.
{"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_observationsThe same across every child place of a type inside a parent — the one-request regional ranking.
{"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 hereRelationship variables with more than one entity — aid flows, bilateral trade, migration corridors.
{"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
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.
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
- 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
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
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
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
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.
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
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
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
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.
<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.