Skip to main content
Glama

MCP-FREDAPI

FRED(美联储经济数据)API 与模型上下文协议(MCP)集成

目录

Related MCP server: Financial Modeling Prep MCP Server

介绍

MCP-FREDAPI 通过模型上下文协议 (MCP Protocol) 提供对圣路易斯联邦储备银行 (FRED) 经济数据的访问。此集成允许像 Claude 这样的 AI 助手在与 Cursor 或其他兼容 MCP 的环境配合使用时直接检索经济时间序列数据。

该软件包与官方 FRED API集成,特别关注为经济指标提供时间序列数据的series_observations 端点

安装

安装方法有两种:

方法 1:使用 pip

安装所需的依赖项:

pip install "mcp[cli]" httpx python-dotenv

克隆此存储库:

git clone https://github.com/Jaldekoa/mcp-fredapi.git cd mcp-fredapi

方法二:使用 uv(推荐)

推荐使用此方法,因为它与 mcp.json 中显示的配置相匹配。

  1. 首先,如果您还没有安装 uv,请安装它:

pip install uv
  1. 克隆此存储库:

git clone https://github.com/Jaldekoa/mcp-fredapi.git cd mcp-fredapi
  1. 使用 uv 运行服务器(无需单独安装依赖项):

uv run --with mcp --with httpx mcp run server.py

配置

FRED API 密钥

您需要一个 FRED API 密钥,您可以从FRED API获取。

在项目根目录中创建一个.env文件:

FRED_API_KEY=your_api_key_here

Claude/Cursor 配置

要配置 Cursor 使用此 MCP 服务器,请将以下内容添加到您的~/.cursor/mcp.json文件中:

{ "mcpServers": { "mcp-fredapi": { "command": "uv", "args": ["--directory", "/path/to/mcp-fredapi", "run", "--with", "mcp", "--with", "httpx", "mcp", "run", "server.py"] } } }

/path/to/mcp-fredapi替换为你系统上仓库的实际路径。例如:

{ "mcpServers": { "mcp-fredapi": { "command": "uv", "args": ["--directory", "/path/to/mcp-fredapi", "run", "--with", "mcp", "--with", "httpx", "mcp", "run", "server.py"] } } }

注意:在 Windows 上,您可以在路径中使用正斜杠/或双反斜杠\\

可用工具

获取fred_series_observations

从 FRED 检索经济时间序列观测数据。

在 Cursor 中使用 Claude 时,您可以直接使用以下方式访问此工具:

@mcp-fredapi:get_fred_series_observations

参数

get_fred_series_observations工具接受以下参数。有关每个参数的完整技术细节,请参阅官方 FRED API 文档

范围

类型

描述

允许值

默认值

地位

系列 ID

字符串

经济系列ID

-

(必需的)

✅ 有效

排序顺序

字符串

对观察结果进行排序

‘升序’,‘降序’

‘升序’

✅ 有效

单位

字符串

数据价值转化

'lin'、'chg'、'ch1'、'pch'、'pc1'、'pca'、'cch'、'cca'、'log'

✅ 有效

频率

字符串

观察频率

'd'、'w'、'bw'、'm'、'q'、'sa'、'a'、'wef'、'weth'、'wew'、'wetu'、'wem'、'wesu'、'wesa'、'bwew'、'bwem'

没有任何

✅ 有效

聚合方法

字符串

频率聚合方法

“平均值”、“总和”、“eop”

‘平均’

✅ 有效

输出类型

整数

观测值的输出类型

1、2、3、4

1

✅ 有效

实时启动

字符串

实时周期的开始 (YYYY-MM-DD)

-

没有任何

❌ 不工作

realtime_end

字符串

实时周期结束时间 (YYYY-MM-DD)

-

没有任何

❌ 不工作

限制

整数/字符串

返回的最大观测数

介于 1 到 100000 之间

10

❌ 不工作

抵消

整数/字符串

从头开始跳过的观察次数

-

0

❌ 不工作

观察开始

字符串

观察开始日期(YYYY-MM-DD)

-

没有任何

❌ 不工作

观察结束

字符串

观察结束日期(YYYY-MM-DD)

-

没有任何

❌ 不工作

年份日期

字符串

以逗号分隔的年份列表

-

没有任何

❌ 不工作

关于参数兼容性的注意事项

由于当前 MCP 实施的限制,只有某些参数可以正常工作:

  • 工作参数series_idsort_orderunitsfrequency 、aggregation_method , and output_type。

  • 非工作参数realtime_startrealtime_endlimitoffsetobservation_startobservation_endvintage_dates

为了获得最佳效果,请在查询中坚持使用有效参数。未来的更新可能会解决这些限制。

示例

获取美国GDP数据

在 Cursor 中使用 Claude 时,可以像这样请求 GDP 数据:

Can you get the latest GDP data from FRED? @mcp-fredapi:get_fred_series_observations { "series_id": "GDP" }

按降序获取 GDP 数据

Can you get the GDP data in descending order (newest first)? @mcp-fredapi:get_fred_series_observations { "series_id": "GDP", "sort_order": "desc" }

获取年度GDP数据

Can you get annual GDP data? @mcp-fredapi:get_fred_series_observations { "series_id": "GDP", "frequency": "a" }

获取通货膨胀率

获取百分比变化的消费者价格指数数据:

What's the recent inflation rate in the US? @mcp-fredapi:get_fred_series_observations { "series_id": "CPIAUCSL", "units": "pch", "frequency": "m" }

不同的输出格式

Show me GDP data in a different format. @mcp-fredapi:get_fred_series_observations { "series_id": "GDP", "output_type": 2 }

贡献

欢迎贡献。请按照以下步骤操作:

  1. 分叉存储库

  2. 创建功能分支( git checkout -b feature/amazing-feature

  3. 进行更改

  4. 提交您的更改( git commit -m 'Add an amazing feature'

  5. 推送到分支( git push origin feature/amazing-feature

  6. 打开拉取请求

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。

参考

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Jaldekoa/mcp-fredapi'

If you have feedback or need assistance with the MCP directory API, please join our Discord server