Yahoo Finance MCP Server
Enables AI assistants to access Yahoo Finance data including stock information, news, price history, options, and earnings via MCP tools.
README
Yahoo Finance MCP Server
📈 A Model Context Protocol (MCP) server that lets your AI interact with Yahoo Finance - get comprehensive stock market data, news, financials, and more.
✨ Features
- 📊 Stock Data - Get comprehensive ticker information including company details, financials, and trading metrics
- 📰 News Feed - Fetch recent news articles related to specific stock symbols
- 🔍 Search - Find stocks, ETFs, and other financial instruments with news results
- 🏆 Top Entities - Get top performing companies, ETFs, and mutual funds by sector
- 📈 Price History - Fetch historical price data with customizable periods and intervals
- ⚡ Options Chain - Get option chain data for stocks including calls and puts
- 💰 Earnings - Access earnings data including upcoming earnings dates
- 🌐 Proxy Support - Works with HTTP/HTTPS/SOCKS proxies
- 🚀 Fast & Async - Non-blocking operations using asyncio
- 🔧 Easy Integration - Standard MCP protocol for AI assistants
🚀 Quick Start
Prerequisites
- Python 3.11 or higher
- pip or uvx package manager
- (Optional) Proxy server for better reliability
Installation
Using uvx (Recommended)
# Install with namespace
uvx yahoo-finance-server
Using pip
pip install yahoo-finance-server
From source
git clone https://github.com/AgentX-ai/AgentX-mcp-servers.git
cd AgentX-mcp-servers/yahoo_finance_server
pip install -e .
Configuration
Proxy Setup (Recommended)
For better reliability and to avoid rate limiting, set up a proxy:
# HTTP/HTTPS proxy
export PROXY_URL="http://proxy.example.com:8080"
# SOCKS proxy with auth
export PROXY_URL="socks5://user:pass@127.0.0.1:1080/"
Running the Server
# Basic run (stdio transport)
yahoo-finance-server
# Run with proxy
PROXY_URL="http://127.0.0.1:7890" yahoo-finance-server
# Run with HTTP transport
yahoo-finance-server --transport http --host localhost --port 3000
# Run with HTTP transport and proxy
PROXY_URL="http://127.0.0.1:7890" yahoo-finance-server --transport http --host 0.0.0.0 --port 8080
Transport Options
Stdio Transport (Default)
- Best for development and AI assistant integration
- Communication via stdin/stdout pipes
- Usage:
yahoo-finance-serveroryahoo-finance-server --transport stdio
HTTP Transport
- StreamableHttp transport (replaces deprecated SSE)
- Allows web-based connections and remote access
- Usage:
yahoo-finance-server --transport http --host localhost --port 3000 - Inspector URL:
http://localhost:3000
🛠️ API Reference
Available Tools
1. get-ticker-info
Get comprehensive stock information including company details, financials, and trading metrics.
{
"name": "get-ticker-info",
"arguments": {
"symbol": "AAPL"
}
}
2. get-ticker-news
Get recent news articles for a stock symbol.
{
"name": "get-ticker-news",
"arguments": {
"symbol": "AAPL",
"count": 10
}
}
3. search
Search for stocks, ETFs, and other financial instruments with related news.
{
"name": "search",
"arguments": {
"query": "Apple Inc",
"count": 10
}
}
4. get-top-entities
Get top performing entities in a sector.
{
"name": "get-top-entities",
"arguments": {
"entity_type": "companies", // Options: "etfs", "mutual_funds", "companies", "growth_companies", "performing_companies"
"sector": "technology", // See supported sectors below
"count": 10
}
}
Supported sectors:
- basic-materials
- communication-services
- consumer-cyclical
- consumer-defensive
- energy
- financial-services
- healthcare
- industrials
- real-estate
- technology
- utilities
5. get-price-history
Get historical price data with customizable periods and intervals.
{
"name": "get-price-history",
"arguments": {
"symbol": "AAPL",
"period": "1y", // Options: 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max
"interval": "1d" // Options: 1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo
}
}
6. ticker-option-chain
Get option chain data for stocks.
{
"name": "ticker-option-chain",
"arguments": {
"symbol": "AAPL",
"option_type": "call", // Options: "call", "put", "both"
"date": "2024-01-19" // Optional: YYYY-MM-DD format
}
}
7. ticker-earning
Get earnings data including historical and upcoming earnings.
{
"name": "ticker-earning",
"arguments": {
"symbol": "AAPL",
"period": "annual", // Options: "annual", "quarterly"
"date": "2023-12-31" // Optional: YYYY-MM-DD format
}
}
🧪 Testing
Using MCP Inspector
With Stdio Transport (Default)
npx @modelcontextprotocol/inspector yahoo-finance-server
With HTTP Transport
# Terminal 1: Start server with HTTP transport
yahoo-finance-server --transport http --host localhost --port 3000
# Terminal 2: Connect inspector to HTTP server
npx @modelcontextprotocol/inspector http://localhost:3000
Manual Testing
python -c "
import asyncio
from yahoo_finance_server.helper import get_ticker_info
async def test():
info = await get_ticker_info('AAPL')
print(f'✅ Stock: {info[\"longName\"]}')
asyncio.run(test())
"
📋 Requirements
- Python 3.11+
- yfinance==0.2.62
- requests>=2.31.0
- pandas>=2.0.0
- mcp>=1.9.3
🤝 Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
📄 License
MIT License - see LICENSE file for details.
🔗 Links
- Homepage: GitHub Repository
- Issues: Report Issues
- MCP Documentation: Model Context Protocol
Made with ❤️ for the finance community
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。