examples/market-macro-agent/
A real-time financial data pipeline agent powered by Datris. MacroAgent connects to the Datris MCP server, discovers available tools, fetches live market data from public APIs, creates pipelines, ingests data, and answers market questions grounded in actual numbers. Everything runs in the browser with a live activity feed.
100% Python — FastAPI backend, vanilla JS frontend, no Node.js required.
Architecture
How It Works
- On startup — Connects to Datris MCP server via SSE, discovers tools via
tools/list, reads the Pipeline Configuration Reference resource - User asks a question — MacroAgent determines which data sources are needed
- Data acquisition — Agent fetches live data from public APIs, caches it server-side, and uses MCP tools (
create_pipeline→upload_data) to ingest - Pipeline management — MacroAgent monitors jobs via
get_job_status, queries results viaquery_postgres— all through MCP tools discovered dynamically - Intelligent acquisition — If the user asks about data the agent doesn’t have, it asks for confirmation before fetching and ingesting new data
- Background refresh — Active pipelines are automatically refreshed on a configurable timer
Data Sources
| Source | Data | Auth |
|---|---|---|
| FRED | Macro series — yields, VIX, CPI, unemployment, credit spreads | Free API key |
| yfinance | Equity / ETF OHLCV (SPY, QQQ, GLD, TLT, XLE, IWM) | None |
| CoinGecko | Crypto prices, market cap, volume (BTC, ETH, SOL) | None (30 req/min) |
| SEC EDGAR | 10-K / 10-Q filings for RAG | None (10 req/sec) |
Quick Start
Demo Queries
"What's the current macro picture?"— creates pipelines, fetches live FRED + equity data"Refresh all pipelines"— re-fetches all active data sources"Is crypto confirming the risk-on trade in equities?"— cross-pipeline analysis"Which pipeline is most stale?"— exerciseslist_pipelinesand timestamp comparison
Environment Variables
| Variable | Default | Description |
|---|---|---|
ANTHROPIC_API_KEY | — | Required |
MODEL | claude-haiku-4-5-20251001 | Claude model |
PORT | 8001 | uvicorn port |
MCP_SERVER_URL | http://localhost:3000/sse | Datris MCP server SSE endpoint |
FRED_API_KEY | — | Get one free |
REFRESH_INTERVAL_MINUTES | 15 | Background refresh cycle |
Requirements
- Python 3.11+
- Datris Platform running via Docker
- Anthropic API key