examples/market-macro-agent/
A real-time financial data pipeline agent powered by Datris. MacroAgent acts as a pipeline orchestrator: it connects to the Datris MCP server, provisions four platform-owned taps (FRED, equities, crypto, SEC filings), triggers them to refresh data, and answers market questions grounded in actual numbers. The Datris platform does the fetching; the agent decides when and what to refresh. 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 the Datris MCP server via SSE, discovers tools via
tools/list, loads the server’s instructions and resources, pushesFRED_API_KEYfrom.envinto Datris as a tap secret (create_tap_secret), and provisions four taps (fred_tap,equities_tap,crypto_tap,sec_tap), each wired to its own pipeline. Idempotent: re-running against an existing install is a no-op. Taps are created with scheduling disabled so the agent’s own loop drives refreshes. - User asks a question — MacroAgent determines which data family is relevant
- Refresh — The agent calls
run_tap. The platform runs the tap’s Pythonfetch()in a Docker sandbox and submits records into the pipeline - Wait for ingestion — Ingestion is asynchronous; the agent polls
get_pipeline_statuswith the run’spublisherTokenuntil every row’s state isendorerror - Query — The agent queries the landed data via
query_postgresand answers grounded in actual numbers - Background refresh — Every
REFRESH_INTERVAL_MINUTESthe scheduler callsrun_tapfor every pipeline that has been exercised at least once - Tap health — Ask about failures and the agent calls
get_tap_logsto report the last runs and any errors
Data Sources
Quick Start
Demo Queries
"What's the current macro picture?"— runs the FRED + equities taps, then queries"Refresh all taps"— triggersrun_tapacross all four data families"Is crypto confirming the risk-on trade in equities?"— cross-pipeline analysis"Show me the last few tap runs"— exercisesget_tap_logslive
Environment Variables
Requirements
- Python 3.11+
- Datris Platform running via Docker
- Anthropic API key
