Very very very simple MCP server to provide AI apps w access to real economic data from World Bank Indicators API.
- Search economic indicators by name
- Retrieve country-level economic time series
- Compare economic indicators across multiple countries
- Return structured data with country and indicator metadata
- Handle missing observations and API errors
- Support local AI integration using Ollama
- Python 3.12+
- Official MCP Python SDK
- httpx
- pytest
- Astral uv
- Ollama (optional), I used
qwen3:1.7b
This MCP seperates economic data retrieval from interacting w an AI model
world_bank.pyhandles HTTP requests, validation, JSON parsing and data transformation.main.pyregisters the economic-data functions as MCP tools.mcp_client_test.pydemonstrates how a Python MCP client connects the tools to a local Ollama model.
- A user asks the local AI assistant a question
- Qwen3 selects an appropriate tool
- The MCP client invokes the tool
- MacroData MCP server
- retrieves data from the World Bank API
- then returns the structured economic data
- Qwen 3 uses the resutls to generate an answer
- It's worth pinting out the MCP servr works independently of Ollama.
- Python 3.12 or newer
- Astral uv
- Node.js and npm (for MCP Inspector)
Clone the repo:
git clone https://github.com/YOUR_USERNAME/MacroDataMCP.git
cd MacroDataMCPInstall the project dependencies:
uv syncLaunch the MCP Inspector:
uv run mcp dev main.pyOpen the local URL printed in your terminal.
The Inspector allows you to discover and test the server's tools without requiring an LLM.
Install Ollama and download Qwen3:
ollama pull qwen3:1.7bRun the demonstration:
uv run python mcp_client_test.pyThe Python client discovers the available MCP tools, passes their definitions to Qwen3, executes requested tool calls and returns the results to the model.
Search World Development Indicators by name.
Example:
{
"query": "inflation"
}Returns matching indicator codes, names and metadata.
Retrieve an economic time series for one country.
Example:
{
"country": "GBR",
"indicator": "NY.GDP.MKTP.KD.ZG",
"start_year": 2020,
"end_year": 2023
}Returns country information, indicator metadata, annual observations and source information.
Compare an economic indicator across multiple countries.
Example:
{
"countries": ["GBR", "FRA", "DEU"],
"indicator": "FP.CPI.TOTL.ZG",
"start_year": 2020,
"end_year": 2023
}Returns results for each successful country and reports individual country errors.
A partial flag indicates whether any requests failed.
Run the automated test suite:
uv run pytest -vTests use pytest and mocked dependencies to verify:
- Year-range validation
- Empty country-list validation
- HTTP error handling
- Missing economic observations
- Partial country failures
- Case-insensitive indicator searching
Tests run without requiring access to the World Bank API.
- Indicator search uses basic case-insensitive substring matching.
- The indicator catalogue is cached in memory without automatic expiration.
- Catalogue retrieval currently assumes all indicators fit on one API page.
- Country comparisons make sequential HTTP requests.
- Network failures may interrupt a comparison.
- Local LLMs can select incorrect tools or generate invalid arguments.
- Some World Bank observations are unavailable or revised over time.
- Remote deployment and authentication are not yet implemented.
Economic data is retrieved from the World Bank Indicators API.