retrieve_data_tool
Retrieve World Bank economic and social indicator data for specific countries, years, and indicators with customizable filters and sorting options.
Instructions
[STEP 3/3] Retrieve actual data from World Bank Data360.
⚠️ PREREQUISITE: Call get_temporal_coverage first to get latest_year.
🚨 CRITICAL TYPE REQUIREMENTS 🚨
When calling this tool, you MUST pass parameters with the EXACT types shown below. Common mistakes that cause validation errors:
❌ INCORRECT: {"limit": "10"} ← limit as STRING (causes error!) ✅ CORRECT: {"limit": 10} ← limit as INTEGER
❌ INCORRECT: {"exclude_aggregates": "true"} ← boolean as STRING ✅ CORRECT: {"exclude_aggregates": true} ← boolean as BOOLEAN
❌ INCORRECT: {"year": 2023} ← year as NUMBER ✅ CORRECT: {"year": "2023"} ← year as STRING
📋 PARAMETER TYPES - MUST MATCH EXACTLY:
STRING parameters (use quotes in JSON): indicator: "WB_WDI_SP_POP_TOTL" database: "WB_WDI" year: "2023" countries: "USA,CHN,JPN" sex: "M" or "F" or "_T" age: "0-14" sort_order: "desc" or "asc"
INTEGER parameters (no quotes in JSON): limit: 10 (default: 20)
BOOLEAN parameters (no quotes in JSON): exclude_aggregates: true or false (default: true) compact_response: true or false (default: true)
🎯 CORRECT JSON EXAMPLES:
Example 1 - Top 10 countries by population: { "indicator": "WB_WDI_SP_POP_TOTL", "database": "WB_WDI", "year": "2023", "limit": 10, "sort_order": "desc", "exclude_aggregates": true }
Example 2 - Specific countries GDP: { "indicator": "WB_WDI_NY_GDP_MKTP_CD", "database": "WB_WDI", "year": "2023", "countries": "USA,CHN,JPN" }
Example 3 - All data with aggregates: { "indicator": "WB_WDI_SP_POP_TOTL", "database": "WB_WDI", "year": "2022", "exclude_aggregates": false }
⚡ HOW IT WORKS:
countries parameter: API fetches ONLY those countries (efficient)
exclude_aggregates: Filters out 47 regional/income codes (ARB, AFE, WLD, HIC, etc.) ⚠️ DEFAULT is TRUE - only individual countries returned Set to false to include aggregates like "World", "High income", "Arab World"
sort_order: Sorts by OBS_VALUE before limiting
limit parameter: Returns top N records to minimize tokens ⚠️ DEFAULT is 20 - provides reasonable default, override if you need more
compact_response: Returns only essential fields (country, country_name, year, value) ⚠️ DEFAULT is TRUE - minimizes token usage by ~75% Set to false if you need all fields (REF_AREA, TIME_PERIOD, OBS_VALUE, UNIT_MEASURE, etc.)
📊 AFTER RECEIVING DATA: Format results as markdown table:
Sort by value (highest to lowest)
Add rank numbers
Format with thousand separators
Include country names (not just codes)
Returns: Data records with summary statistics.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| indicator | Yes | ||
| database | Yes | ||
| year | No | ||
| countries | No | ||
| sex | No | ||
| age | No | ||
| limit | No | ||
| sort_order | No | desc | |
| exclude_aggregates | No | ||
| compact_response | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||