Analyze GDP Data with Codex Using FRED
GDP is the single most referenced number in macroeconomics. If you’re building economic dashboards, investment tools, or anything that needs to contextualize growth, Codex can now pull GDP data and related series directly from the Federal Reserve and run analysis without you doing the data gathering.
Why This Matters
Working with GDP data usually means juggling multiple series: nominal GDP, real GDP, GDP per capita, GDP deflator. Each tells a different part of the story, and comparing them requires aligning different frequencies and units. Doing that manually is tedious — downloading CSVs from FRED, normalizing dates, handling missing values.
AgentPatch’s FRED Series Data tool returns clean, structured observations with metadata that includes units and frequency. Codex can pull multiple series, understand what each measures from the metadata, and run comparisons autonomously. Missing data points (which FRED marks with ”.”) are already filtered out, and values come as strings to avoid floating point precision issues.
Setup
Add AgentPatch to ~/.codex/config.toml:
[mcp_servers.agentpatch]
url = "https://agentpatch.ai/mcp"
bearer_token_env_var = "AGENTPATCH_API_KEY"
Then set your API key:
export AGENTPATCH_API_KEY=your_api_key
Replace your_api_key with your actual key from the AgentPatch dashboard. Codex discovers all AgentPatch tools automatically on next start.
Example
You’re building a macro dashboard and need to populate the GDP section with real data. You tell Codex:
“Pull quarterly real GDP (GDPC1) and the GDP deflator (GDPDEF) for the past 5 years. Calculate quarterly growth rates for both and identify any quarters where real GDP contracted.”
Codex fetches both series and runs the analysis:
Fetching FRED series GDPC1 (quarterly, 2021-Q1 to 2025-Q4)...
Fetching FRED series GDPDEF (quarterly, 2021-Q1 to 2025-Q4)...
Real GDP (GDPC1):
- Units: Billions of Chained 2017 Dollars
- 20 quarterly observations
- Range: $19,055.7B to $20,891.3B
GDP Deflator (GDPDEF):
- Units: Index 2017=100
- 20 quarterly observations
- Range: 114.6 to 127.8
Contraction quarters (negative real GDP growth):
- 2022-Q1: -1.6% (annualized)
- 2022-Q2: -0.6% (annualized)
Average quarterly real GDP growth (annualized):
- 2021: 5.9%
- 2022: 1.9%
- 2023: 2.5%
- 2024: 2.8%
- 2025: 2.3%
Writing seed data to fixtures/gdp.json and the growth rate calculations
to src/utils/gdp-analysis.ts. The dashboard component can import directly.
Codex pulled two related GDP series, calculated derived growth rates, flagged contraction periods, and produced both analysis and code artifacts. It understood from the metadata that GDPC1 is real GDP in chained dollars and GDPDEF is a price index, and treated them appropriately.
Wrapping Up
With AgentPatch connected, Codex can pull any combination of FRED series and analyze them autonomously. Use fred-search to discover series IDs you don’t have memorized — there are over 800,000 available. The same connection also gives Codex access to web search, email, image generation, and every other tool on the marketplace. Check it out at agentpatch.ai.