search_datasets_tool
Search World Bank Data360 for datasets to find indicator and database IDs needed for retrieving economic and social development data.
Instructions
[STEP 1/3] Search World Bank Data360 for datasets.
<purpose>
Search World Bank Data360 for datasets. This is STEP 1 of 3 in the data retrieval workflow.
Find indicator IDs and database IDs needed for subsequent data operations.
</purpose>
<workflow>
<step number="1">search_datasets (this tool) - Find indicator ID and database ID</step>
<step number="2">get_temporal_coverage - Check available years BEFORE retrieving data</step>
<step number="3">retrieve_data - Fetch actual data with proper year and limit parameters</step>
</workflow>
<optimization_tips>
<tip>Remove punctuation: "GDP, total" becomes "GDP total"</tip>
<tip>Expand abbreviations: "GDP" becomes "Gross Domestic Product"</tip>
<tip>Add "total" for aggregates: "population" becomes "population total"</tip>
<tip>Use lowercase for consistency</tip>
<tip>Remove filler words: "data", "statistics"</tip>
</optimization_tips>
<common_databases>
<database id="WB_WDI">World Development Indicators (most comprehensive)</database>
<database id="WB_HNP">Health, Nutrition and Population</database>
<database id="WB_GDF">Global Development Finance</database>
</common_databases>
<examples>
<example original="GDP">gross domestic product total</example>
<example original="population data">population total</example>
<example original="">poverty headcount ratio</example>
</examples>
<returns>
List of datasets with indicator IDs, names, database IDs, and search scores.
</returns>
<next_step>
Call get_temporal_coverage with the indicator and database from results.
</next_step>
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| search_query | Yes | ||
| top | No |
Implementation Reference
- src/world_bank_mcp/server.py:365-407 (handler)Handler function for the 'search_datasets_tool' tool. Registered with @server.tool() decorator. Includes detailed docstring serving as tool description/schema and calls the core search_datasets helper function.@server.tool() def search_datasets_tool(search_query: str, top: int = 20) -> dict[str, Any]: """[STEP 1/3] Search World Bank Data360 for datasets. <purpose> Search World Bank Data360 for datasets. This is STEP 1 of 3 in the data retrieval workflow. Find indicator IDs and database IDs needed for subsequent data operations. </purpose> <workflow> <step number="1">search_datasets (this tool) - Find indicator ID and database ID</step> <step number="2">get_temporal_coverage - Check available years BEFORE retrieving data</step> <step number="3">retrieve_data - Fetch actual data with proper year and limit parameters</step> </workflow> <optimization_tips> <tip>Remove punctuation: "GDP, total" becomes "GDP total"</tip> <tip>Expand abbreviations: "GDP" becomes "Gross Domestic Product"</tip> <tip>Add "total" for aggregates: "population" becomes "population total"</tip> <tip>Use lowercase for consistency</tip> <tip>Remove filler words: "data", "statistics"</tip> </optimization_tips> <common_databases> <database id="WB_WDI">World Development Indicators (most comprehensive)</database> <database id="WB_HNP">Health, Nutrition and Population</database> <database id="WB_GDF">Global Development Finance</database> </common_databases> <examples> <example original="GDP">gross domestic product total</example> <example original="population data">population total</example> <example original="">poverty headcount ratio</example> </examples> <returns> List of datasets with indicator IDs, names, database IDs, and search scores. </returns> <next_step> Call get_temporal_coverage with the indicator and database from results. </next_step>""" return search_datasets(search_query, top)
- src/world_bank_mcp/server.py:43-80 (helper)Core helper function implementing the dataset search logic by making a POST request to the World Bank Data360 search API endpoint, processing the response, and formatting results with indicator IDs, names, databases, and search scores.def search_datasets(search_query: str, top: int = 20) -> dict[str, Any]: """Search World Bank Data360 API""" payload = { "count": True, "select": "series_description/idno, series_description/name, series_description/database_id", "search": search_query, "top": top, } try: response = requests.post( SEARCH_ENDPOINT, json=payload, headers={"Content-Type": "application/json", "Accept": "application/json"}, timeout=30, ) response.raise_for_status() data = response.json() # Format results nicely results = [] for item in data.get("value", []): series = item.get("series_description", {}) results.append({ "indicator": series.get("idno"), "name": series.get("name"), "database": series.get("database_id"), "search_score": round(item.get("@search.score", 0), 2) }) return { "success": True, "total_count": data.get("@odata.count", 0), "results": results } except Exception as e: return {"success": False, "error": str(e)}