yfinance-mcp
yfinance-mcp
为你的 AI 提供实时市场数据。 一个 Model Context Protocol 服务器,为 Claude(或任何 MCP 客户端)提供实时报价、OHLCV 历史数据、完整期权链、新闻以及多标的对比。免费,无需 API 密钥。
为什么
LLM 回答市场问题时依赖的是训练数据的猜测。只需接入这个服务器一次,它们就不再猜测了:
"苹果现在股价多少?" → 实时报价,而不是过时的幻觉
"拉取下个月到期的 AAPL 期权" → 带 IV 和未平仓量的真实行权价
"今年 NVDA 对比 AMD 对比 INTC?" → 基于数据计算的实际收益率、波动率、回撤
"PLTR 最近有什么新闻?" → 带链接的标题,可供引用
Related MCP server: yfinance
工具
工具 | 功能 | 示例提示 |
| 最新价格、日内区间、成交量、市值、52 周区间、涨跌幅 | "TSLA 今天表现如何?" |
| OHLCV K 线(任意周期 × 间隔)+ 汇总统计 | "SPY 2024 年每日收盘价" |
| 看涨与看跌期权:行权价、最新价、买/卖价、IV、OI、成交量、实值 | "AAPL 下个月期权链" |
| 带链接的最新头条 | "PLTR 有什么新闻?" |
| 收益率、年化波动率、最大回撤并排对比;指出表现最佳者 | "MSFT 对比 GOOGL,3 个月" |
响应为 JSON,截断为适合 LLM 的大小(期权每侧上限 60 行),并附带汇总统计,让模型在查看原始 K 线之前先基于聚合数据进行推理。
安装
git clone https://github.com/saksham10arora-dotcom/yfinance-mcp
cd yfinance-mcp
python3 -m venv .venv && .venv/bin/pip install fastmcp yfinanceClaude Desktop / 任何 MCP 客户端
添加到 claude_desktop_config.json(文件 → 设置 → 开发者 → 编辑配置):
{
"mcpServers": {
"yfinance": {
"command": "/absolute/path/to/yfinance-mcp/.venv/bin/python",
"args": ["/absolute/path/to/yfinance-mcp/server.py"]
}
}
}重启 Claude Desktop。工具会出现在 🔨 图标下。询问任意股票代码即可。
无需 MCP 客户端即可验证
./.venv/bin/python -c "import server; print(server.get_quote('AAPL'))"CI 在每次推送时都会运行与 GitHub 相同的 stdio 握手测试,因此 main 分支始终保证协议正确。
常见问题
数据是实时的吗? Yahoo Finance 数据:美股接近实时,部分国际市场有延迟。适合研究和聊天,不适合下单执行。
需要付费吗? 不需要。无需 API 密钥、无需限流账户、无需任何配置。
为什么不直接把 yfinance 代码粘贴到聊天里? 当然可以。这个服务器省去了复制粘贴的循环,让模型根据问题自行决定调用哪个工具,包括多步骤问题("对比这五只股票,然后拉取波动率最大的那只看涨期权链")。
Windows 支持吗?
支持。将配置指向 .venv\Scripts\python.exe,并在 JSON 中使用双反斜杠。
故障排查
重启后工具图标消失:配置中的路径必须是绝对路径;相对路径会静默失败。
no data for <ticker>:股票已退市或代码拼写错误;请在浏览器中到 Yahoo Finance 确认。大量使用后被限流:等待几分钟再试;Yahoo 会限制突发请求。
替代方案对比
yfinance-mcp | 付费市场 MCP | |
API 密钥 | 无需 | 需要 |
费用 | 免费 | $10-100+/月 |
带 IV 的期权链 | 支持 | 视情况而定 |
实时深度/L2 数据 | 不支持 | 有时支持 |
安装时间 | 2 分钟 | 账户 + 计费 |
许可证
MIT。不构成投资建议;读取你投资组合的 AI 不是受托人。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides Yahoo Finance data including stock info, historical prices, dividends, financials, earnings, news, and more through a set of MCP tools, deployable on Azure Functions.
- AlicenseAqualityCmaintenanceA Model Context Protocol (MCP) server that provides comprehensive access to Yahoo Finance data through 18 specialized tools for pricing, financials, options, holders, and news.181MIT
- AlicenseNot gradedqualityCmaintenanceA comprehensive MCP server that provides seamless access to Yahoo Finance stock market data, enabling retrieval of real-time quotes, historical data, charts, financial summaries, and market searches.38ISC
- AlicenseNot gradedqualityDmaintenanceEnables querying stock data, financial information, news, and historical prices from Yahoo Finance through a set of MCP tools.MIT
Related MCP Connectors
Alpaca MCP — real-time US stock market data via the Alpaca Market Data API
Hosted MCP for stocks, options, Greeks, brokers, order previews, alerts, and workflows.
Tradier MCP — stock & options market data via the Tradier Brokerage API
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/saksham10arora-dotcom/yfinance-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server