fred-macro-mcp

fred-macro-mcp

Enables LLM agents to query US macroeconomic time series from FRED, including GDP, CPI, unemployment, and interest rates, for contextual research.

Category
访问服务器

README

fred-macro-mcp

CI CodeQL License: MIT

A read-only Model Context Protocol (MCP) server that wraps the FRED (Federal Reserve Economic Data, St. Louis Fed) public API.

FRED is the canonical free source for US macroeconomic time series — GDP, CPI, unemployment, policy and market interest rates, and the Treasury yield curve. This server lets an LLM agent overlay macro context on equity / fixed-income research: "what is CPI doing", "where is the 10y-2y spread", "when is the next jobs print".

Read-only by design. Every tool performs HTTPS GET requests against the single fixed host https://api.stlouisfed.org. There is no write, mutation, or order-placement path of any kind.

Tools

Tool Purpose
get_series Observation values for one series over an optional date window.
search_series Keyword-search the FRED catalog to find the right series_id.
get_series_latest The single most-recent observation for a series.
get_release_calendar Upcoming FRED data releases in the next N days.
health_check Local health probe (key configured? rate limit?). Never calls FRED.
get_server_info Version, MCP SDK version, tool list. Never calls FRED.

get_series

  • When to use: pull a macro time series (e.g. CPI, GDP, 10y Treasury).
  • Input: series_id (e.g. CPIAUCSL), optional start / end (YYYY-MM-DD), optional limit.
  • Output: { series_id, start, end, units, observation_count, observations: [{date, value}, ...] }. Missing points ("." in FRED) surface as value: null.
  • Example: get_series(series_id="DGS10", start="2024-01-01").

search_series

  • When to use: you know the concept ("unemployment rate") but not the id.
  • Input: query (free text), optional limit.
  • Output: { query, result_count, results: [{id, title, frequency, units, observation_start, observation_end, popularity}, ...] }, most popular first.
  • Example: search_series(query="real gdp").

get_series_latest

  • When to use: "what is the current value of X" without the full history.
  • Input: series_id.
  • Output: { series_id, latest: {date, value} | null, units }.
  • Example: get_series_latest(series_id="UNRATE").

get_release_calendar

  • When to use: flag upcoming macro event risk (next CPI / GDP / jobs).
  • Input: days (1-180, default 14).
  • Output: { days, from_date, to_date, release_count, releases: [{release_id, release_name, date}, ...] }.
  • Example: get_release_calendar(days=30).

Common series ids

Concept series_id
Real GDP GDPC1
CPI (all urban) CPIAUCSL
Core PCE PCEPILFE
Unemployment rate UNRATE
Fed funds (effective) DFF
10-year Treasury DGS10
2-year Treasury DGS2
10y-2y spread T10Y2Y

Install

uv sync --extra dev

A FRED API key (free) is required. Copy .env.example to .env and set FRED_API_KEY.

Configure your MCP host

Add to your MCP host config (e.g. Cursor ~/.cursor/mcp.json):

{
  "mcpServers": {
    "fred-macro": {
      "command": "uv",
      "args": ["run", "fred-macro-mcp"],
      "cwd": "/opt/workspace/code/kevinkda/fred-macro-mcp",
      "env": { "FRED_API_KEY": "<your-fred-key>" }
    }
  }
}

FRED_API_KEY may also be set in .env instead of inline env.

Configuration

Env var Default Purpose
FRED_API_KEY (required) 32-char FRED key. Never logged.
FRED_RATE_LIMIT_PER_MIN 120 Client throttle (≤ FRED's 120/min ceiling).
FRED_CACHE_ENABLED false Opt-in read-through cache.
FRED_CACHE_BYPASS false Force fresh reads while still writing.
FRED_CACHE_BACKEND memory memory (zero-dep) or clickhouse (opt-in extra).
FRED_CLICKHOUSE_URL (unset) DSN used only when backend is clickhouse.
LOG_LEVEL WARNING Log verbosity.

The cache is off by default and uses an in-process memory LRU when enabled — zero external dependencies. ClickHouse is an opt-in extra (pip install fred-macro-mcp[clickhouse]) for durable history.

Security

  • API key is the only secret. It is read from the environment, passed to FRED only as a bound query parameter, and redacted from every log line and exception message (api_key=… and bare 32-char keys are masked).
  • SSRF-safe. The host is a hard-coded constant; callers supply an endpoint path + params only and can never redirect to another host. Redirects are not followed.
  • Injection-safe. series_id and dates are validated with anchored regexes and passed as bound query parameters — never string-concatenated into a URL.
  • Rate-limited. A sliding-60-second token bucket keeps requests within FRED's documented 120 req/min budget.

See docs/SECURITY.md and docs/THREAT_MODEL.md.

Development

uv run pytest --cov=src --cov-fail-under=100
uv run ruff check src tests && uv run ruff format --check src tests
uv run mypy --strict src

Tests use respx to mock FRED — no real FRED API calls are made in the test suite.

License

MIT — see LICENSE.

Data © Federal Reserve Bank of St. Louis (FRED). Subject to FRED's terms of use. This server is for interactive single-user research.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选