mcpField
M
Mcp Yfinance

Mcp Yfinance

本地服务
github.com/nicholasf金融数据083 周前更新

关于 Mcp Yfinance

Mcp Yfinance 是将 yFinance ticker 历史记录调用封装为 MCP 工具的演示项目,面向希望获取个股历史价格的 MCP 主机用户。它会把结果以 Pandas DataFrame 返回,README 提到复杂聚合可能受令牌限制。

主要功能

  1. 01封装 yFinance 历史记录调用
  2. 02返回 Pandas DataFrame
  3. 03可作为 MCP 主机扩展注册

适用场景

  1. 01获取单个证券的每日价格
  2. 02在 MCP 主机中调用历史记录工具

MCP 相关

该项目将 yFinance 历史记录调用作为工具提供给 MCP 主机;输出为 Pandas DataFrame,主机需要能够处理该格式。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

暂未收录安装方式

我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。

代码仓库

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

一个围绕经典 yFinance 构建的简单封装,以 MCP 工具的形式运行。

注意:此工具会将 Pandas Dataframe 返回给 MCP 主机,因此需要主机能够理解该数据格式。它使用 Goose 作为 MCP 主机,并使用 Claude Sonnet 3.5 作为集成的大模型。

目前我用它获取过单个金融工具的每日股价。当我要求大模型执行一些更高级的聚合操作时,很快就遇到了 Anthropic 的令牌数限制。

此工具旨在用作演示、起点或概念验证。

安装

在 MCP 主机中将其注册为扩展。

在 goose 上:


☁  mcp-yfinance [main] ⚡  goose configure    

This will update your existing config file
  if you prefer, you can edit it directly at /home/nicholasf/.config/goose/config.yaml

┌   goose-configure 
│
◇  What would you like to configure?
│  Add Extension 
│
◇  What type of extension would you like to add?
│  Command-line Extension 
│
◇  What would you like to call this extension?
│  yf
│
◇  What command should be run?
│  uv run server.py
│
◇  Please set the timeout for this tool (in secs):
│  5
│
◇  Would you like to add environment variables?
│  No 
│
└  Added yf extension

然后调用它:

☁  mcp-yfinance [main] ⚡  goose session -n yf
starting session | provider: anthropic model: claude-3-5-sonnet-latest
    logging to /home/nicholasf/.local/share/goose/sessions/yf.jsonl
    working directory: /home/nicholasf/code/github/nicholasf/mcp-yfinance

Goose is running! Enter your instructions, or try asking what goose can do.

( O)> yf__history AAPL
I'll try getting Apple's stock history now.
─── history | yf ──────────────────────────
symbol: AAPL



Great! The command is now working correctly. The data shows Apple's stock performance over the last month (from February 19, 2025 to March 18, 2025). Here are some key observations:

1. The stock has shown a general downward trend over this period
2. Starting price (Feb 19): Around $244.66
3. Latest price (March 18): Around $214.16
4. Highest point: Around $250.00 (Feb 25)
5. Notable decline: A sharp drop occurred around March 11, falling from ~$235 to ~$223

The data includes Open, High, Low, Close prices, Volume, Dividends, and Stock Splits (though no dividends or splits occurred during this period).

Would you like to:
1. See the data for a different time period?
2. Look at a different stock symbol?
3. Get more detailed analysis of specific aspects of this data?

Just let me know what information would be most helpful!


运行测试

pytest -v

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。