MCP Servers

A collection of Model Context Protocol servers, templates, tools and more.

E
Economic Forecasting MCP

AI-powered economic forecasting with MCP - achieving 98% token efficiency

Created 11/5/2025
Updated about 1 month ago
Repository documentation and setup instructions

Economic Forecasting Agent with MCP

An AI-powered economic forecasting system demonstrating efficient agent design using the Model Context Protocol (MCP) and code execution patterns.

Overview

This project showcases how to build production-ready AI agents for economic analysis by:

  • Using MCP servers to connect to economic data sources (FRED, IMF, BEA)
  • Implementing code execution patterns to reduce token consumption by ~98%
  • Building reusable forecasting "skills" that compound over time
  • Demonstrating secure handling of data in execution environments

Built by Lelo Nxumalo, Economist at IMF Statistics Department

Why This Matters

Traditional AI agents load all tool definitions upfront and pass all data through context, leading to:

  • High latency (processing 100K+ tokens before starting)
  • High costs (intermediate data flows through context repeatedly)
  • Context limits (large datasets can't be processed)

This implementation uses Anthropic's recommended patterns for code execution with MCP to solve these problems.

Key Features

  • Progressive Tool Discovery: Load only needed tools (2K tokens vs 150K tokens)
  • Context-Efficient Data Processing: Filter/transform data in execution environment
  • Reusable Skills: Build library of forecasting methodologies
  • Production Patterns: Proper error handling, logging, state management

Project Structure

economic-forecasting-mcp/
├── servers/              # MCP servers for data sources
│   ├── fred/            # Federal Reserve Economic Data
│   ├── imf/             # IMF World Economic Outlook
│   └── bea/             # Bureau of Economic Analysis
├── skills/              # Reusable forecasting workflows
│   ├── core-pce-forecast/
│   └── gdp-nowcast/
├── examples/            # Demo notebooks and scripts
├── tests/              # Unit tests
└── docs/               # Documentation

Quick Start

# Install dependencies
pip install -r requirements.txt

# Set up API keys
cp .env.example .env
# Edit .env with your FRED API key

# Run example forecast
python examples/run_core_pce_forecast.py

Example Usage

from agent import ForecastingAgent
from servers.fred import FREDServer

# Initialize agent with MCP server
agent = ForecastingAgent(servers=[FREDServer()])

# Run forecast (agent writes code to fetch data, estimate model, generate charts)
result = await agent.run_forecast(
    "Update Core PCE inflation forecast through 2026 Q4"
)

# Result contains: forecast values, confidence intervals, chart path
# All intermediate data stayed in execution environment

Technical Implementation

Based on Anthropic's Code execution with MCP patterns:

  1. MCP Servers as Code APIs: Each tool becomes a TypeScript/Python file on disk
  2. Progressive Disclosure: Agent navigates filesystem to load only needed tools
  3. Execution Environment: Data processing happens in sandboxed container
  4. Skills Persistence: Successful workflows saved as reusable functions

Applications

  • Macroeconomic Forecasting: Inflation, GDP growth, unemployment
  • Cross-Country Analysis: Run forecasts for multiple economies simultaneously
  • Policy Analysis: Scenario modeling with different assumptions
  • Research: Replicable, version-controlled analytical pipelines

Roadmap

  • [x] Phase 1: Basic infrastructure + FRED server + simple forecast
  • [ ] Phase 2: Multiple data sources + advanced forecasting skills
  • [ ] Phase 3: Web interface for interactive exploration
  • [ ] Phase 4: Multi-country analysis workflows

Contact

Lelo Nxumalo - lelonxumalo.blogspot.com

Built for demonstrating modern AI agent patterns for economic analysis.

Quick Setup
Installation guide for this server

Install Package (if required)

uvx economic-forecasting-mcp

Cursor configuration (mcp.json)

{ "mcpServers": { "lelonxumalo-economic-forecasting-mcp": { "command": "uvx", "args": [ "economic-forecasting-mcp" ] } } }