MCP-FREDAPI
FRED(美联储经济数据)API 与模型上下文协议(MCP)集成
目录
介绍
MCP-FREDAPI 通过模型上下文协议 (MCP Protocol) 提供对圣路易斯联邦储备银行 (FRED) 经济数据的访问。此集成允许像 Claude 这样的 AI 助手在与 Cursor 或其他兼容 MCP 的环境配合使用时直接检索经济时间序列数据。
该软件包与官方 FRED API集成,特别关注为经济指标提供时间序列数据的series_observations 端点。
安装
安装方法有两种:
方法 1:使用 pip
安装所需的依赖项:
克隆此存储库:
方法二:使用 uv(推荐)
推荐使用此方法,因为它与 mcp.json 中显示的配置相匹配。
- 首先,如果您还没有安装 uv,请安装它:
- 克隆此存储库:
- 使用 uv 运行服务器(无需单独安装依赖项):
配置
FRED API 密钥
您需要一个 FRED API 密钥,您可以从FRED API获取。
在项目根目录中创建一个.env
文件:
Claude/Cursor 配置
要配置 Cursor 使用此 MCP 服务器,请将以下内容添加到您的~/.cursor/mcp.json
文件中:
将/path/to/mcp-fredapi
替换为你系统上仓库的实际路径。例如:
注意:在 Windows 上,您可以在路径中使用正斜杠/
或双反斜杠\\
。
可用工具
获取fred_series_observations
从 FRED 检索经济时间序列观测数据。
在 Cursor 中使用 Claude 时,您可以直接使用以下方式访问此工具:
参数
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_id
、sort_order
、units
、frequency
、aggregation_method, and
output_type。- ❌非工作参数:
realtime_start
、realtime_end
、limit
、offset
、observation_start
、observation_end
和vintage_dates
。为了获得最佳效果,请在查询中坚持使用有效参数。未来的更新可能会解决这些限制。
示例
获取美国GDP数据
在 Cursor 中使用 Claude 时,可以像这样请求 GDP 数据:
按降序获取 GDP 数据
获取年度GDP数据
获取通货膨胀率
获取百分比变化的消费者价格指数数据:
不同的输出格式
贡献
欢迎贡献。请按照以下步骤操作:
- 分叉存储库
- 创建功能分支(
git checkout -b feature/amazing-feature
) - 进行更改
- 提交您的更改(
git commit -m 'Add an amazing feature'
) - 推送到分支(
git push origin feature/amazing-feature
) - 打开拉取请求
执照
该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。
参考
- FRED API 文档 - 系列观察- 本项目使用的 FRED API 端点的官方文档。
- FRED API - 有关获取 API 密钥和一般 API 文档的信息。
- 模型上下文协议- 模型上下文协议的文档。
Related MCP Servers
- AsecurityFlicenseAqualityA Model Context Protocol server that provides tools to search and retrieve economic data series from the Federal Reserve Economic Data (FRED) API.Last updated -23TypeScript
- -securityAlicense-qualityMCP server that provides AI assistants access to stock market data including financial statements, stock prices, and market news through a Model Context Protocol interface.Last updated -253PythonMIT License
- -securityAlicense-qualityAn experimental server implementing the Model Context Protocol to allow AI assistants to query and analyze financial data stored in Beancount ledger files using the Beancount Query Language.Last updated -2PythonMIT License
- -securityAlicense-qualityA Model Context Protocol server that enables AI assistants like Claude to programmatically access financial data from Financial Modeling Prep API, including company profiles, financial statements, metrics, SEC filings, and market data.Last updated -5PythonMIT License
Appeared in Searches
- How to create pie and line charts with MCP
- Understanding and Using Analytics Tools
- A platform for analyzing crypto narratives based on macroeconomic events and cultural trends
- A tool for analyzing Indian stock data for investment decisions using LLMs and news insights
- Tools or software for generating charts and graphs