Alex2Yang97/yahoo-finance-mcp

This is a Model Context Protocol (MCP) server that provides comprehensive financial data from Yahoo Finance. It allows you to retrieve detailed information about stocks, including historical prices, company information, financial statements, options data, and market news.

Yahoo Finance MCP Server

一个轻量级的 Model Context Protocol (MCP) 服务器,封装了公开的 Yahoo Finance API,为基于大语言模型的智能体(例如 Claude)提供丰富的金融数据。该服务器暴露了一系列类型化的工具,供大语言模型调用以获取:

类别 工具(简要描述)
股票信息 get_historical_stock_prices – OHLCV 系列;get_stock_info – 当前价格、指标、公司详情;get_yahoo_finance_news – 最新新闻;get_stock_actions – 股息与拆股
财务报表 get_financial_statement – 收益表、资产负债表、现金流量表(年度/季度);get_holder_info – 主要股东、机构投资者、共同基金、内部人士持股信息
期权数据 get_option_expiration_dates – 可用到期日;get_option_chain – 指定到期日的看涨/看跌期权
分析师信息 get_recommendations – 分析师评级、上调/下调

为何对 AI 至关重要

该服务器专为从 Claude for Desktop(或任何 MCP 兼容模型)调用而设计,使模型能够结合最新的市场数据、新闻和持股信息来增强推理能力。这使得纯语言模型转变为 金融研究助手,而无需模型自行爬取网页。

现实场景提示(来自 README)

  • “显示 NOW 股票过去 6 个月、每日间隔的历史股价。”get_historical_stock_prices
  • “获取 Intuit 的季度资产负债表。”get_financial_statement
  • “过去 3 个月 Intuit 的分析师推荐情况是什么?”get_recommendations
  • “获取到期日为 2026-01-30 的 INTU 看涨期权链。”get_option_chain

这些示例展示了大语言模型如何提出自然语言问题,而 MCP 服务器将其转化为具体的 API 调用。

快速入门

  1. 无需安装运行 – README 推荐使用 uvx
    uvx --from git+https://github.com/Alex2Yang97/yahoo-finance-mcp yahoo-finance-mcp
    
  2. 本地开发 – 克隆仓库,使用 uv sync 安装 pyproject.toml 中列出的依赖(Python ≥ 3.14.6,mcpyfinancepandaspydantic 等),然后通过 uv run server.py 启动服务器。
  3. 接入 Claude – 编辑 claude_desktop_config.json,添加指向上述命令的 yfinance MCP 条目,然后重启 Claude。

许可证

MIT – 可自由使用、修改和分发。


所有信息均直接取自仓库的 README。

相关

  • 项目
  • 项目
  • 项目
  • 项目