YFinance MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@YFinance MCP Server show me Apple's current stock price"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
YFinance MCP Server
A comprehensive Model Context Protocol (MCP) server that provides financial data through Yahoo Finance API integration. This server enables AI agents to access real-time stock market data, historical prices, financial statements, and market analysis.
Features
10 Comprehensive Financial Tools for complete market data access
Real-time Stock Information including prices, market cap, and key metrics
Historical Data Analysis with flexible time periods and intervals
Financial Statements (income statement, balance sheet, cash flow)
Earnings Data (annual and quarterly)
Dividend and Split History
News and Analyst Recommendations
Stock Search and Multi-quote Support
Robust Error Handling with structured JSON responses
FastMCP Framework with async support for high performance
Related MCP server: MCP YFinance Stock Server
Quick Start
Prerequisites
Python 3.11+
uv (Python package manager)
Installation
# Clone the repository
git clone https://github.com/barvhaim/yfinance-mcp-server.git
cd yfinance-mcp-server
# Install dependencies
uv syncRunning the Server
# Start the MCP server
uv run main.py
# The server will start and be ready to accept MCP client connectionsAvailable Tools
1. get_stock_info
Get comprehensive stock information including current price, market cap, and financial metrics.
Parameters:
symbol(str): Stock ticker symbol (e.g., 'AAPL', 'GOOGL')
Returns: Stock information including price, market cap, P/E ratio, dividend yield, 52-week range, volume, beta, and company details.
2. get_historical_data
Retrieve historical stock price data with flexible time periods and intervals.
Parameters:
symbol(str): Stock ticker symbolperiod(str): Time period (1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max)interval(str): Data interval (1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo)
Returns: Historical OHLCV data with dates and volume information.
3. get_dividends
Get dividend payment history for a stock.
Parameters:
symbol(str): Stock ticker symbol
Returns: List of dividend payments with dates and amounts.
4. get_splits
Retrieve stock split history.
Parameters:
symbol(str): Stock ticker symbol
Returns: List of stock splits with dates and split ratios.
5. get_financials
Get comprehensive financial statements.
Parameters:
symbol(str): Stock ticker symbolquarterly(bool): Get quarterly data if True, annual if False
Returns: Income statement, balance sheet, and cash flow statement data.
6. get_earnings
Retrieve earnings data for analysis.
Parameters:
symbol(str): Stock ticker symbol
Returns: Annual and quarterly earnings data.
7. get_news
Get recent news articles related to a stock.
Parameters:
symbol(str): Stock ticker symbolcount(int): Number of articles to return (default: 10)
Returns: List of news articles with titles, links, publishers, and timestamps.
8. get_recommendations
Get analyst recommendations and ratings.
Parameters:
symbol(str): Stock ticker symbol
Returns: List of analyst recommendations with firms, ratings, and actions.
9. search_stocks
Search for stocks by company name or ticker symbol.
Parameters:
query(str): Search query (company name or ticker)limit(int): Maximum results to return (default: 10)
Returns: List of matching stocks with symbols, names, and exchange information.
10. get_multiple_quotes
Get current quotes for multiple stocks simultaneously.
Parameters:
symbols(List[str]): List of stock ticker symbols
Returns: Dictionary of stock quotes with current prices, changes, and basic metrics.
Usage Examples
Basic Stock Information
# Get Apple stock information
result = await get_stock_info("AAPL")
print(f"Current Price: ${result['current_price']}")
print(f"Market Cap: ${result['market_cap']:,}")Historical Data Analysis
# Get 1-year daily data for Google
result = await get_historical_data("GOOGL", period="1y", interval="1d")
print(f"Retrieved {result['count']} data points")Multiple Stock Quotes
# Get quotes for tech stocks
result = await get_multiple_quotes(["AAPL", "GOOGL", "MSFT", "AMZN"])
for symbol, quote in result['quotes'].items():
print(f"{symbol}: ${quote['current_price']}")MCP Client Integration
Claude Desktop Integration
To connect this server with Claude Desktop:
Start the server in one terminal:
uv run main.pyConfigure Claude Desktop by editing your MCP settings file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonAdd the server configuration:
{ "yfinance": { "command": "uv", "args": [ "--directory", "/path/to/yfinance-mcp-server", "run", "main.py" ] } }Update the cwd path to your actual project directory
Restart Claude Desktop to load the new server
Verify connection by asking Claude: "What financial data tools do you have available?"
Alternative: Direct Connection
For other MCP clients:
Start the server:
uv run main.pyConfigure your MCP client to connect to the server endpoint
Tools will be automatically discovered by your AI agent
Use standard stock symbols (AAPL, GOOGL, MSFT, etc.) with the tools
Development
Code Formatting
# Format code with black
uv run black .
# Check formatting
uv run black --check .
# Show formatting differences
uv run black --diff .Adding New Tools
Create a new async function in
main.pyDecorate with
@mcp.tool()Add proper type hints and docstrings
Include error handling
Test the implementation
Environment Variables
Copy .env.sample to .env for any configuration needed:
cp .env.sample .envError Handling
All tools include comprehensive error handling:
Invalid symbols return structured error messages
Network issues are caught and reported
Data unavailability is handled gracefully
Rate limiting is respected automatically by yfinance
Performance Considerations
Async operations for optimal performance
Efficient data serialization with structured JSON
Minimal data processing to reduce latency
Built-in caching by yfinance for frequently accessed data
Dependencies
fastmcp - FastMCP framework for MCP server implementation
yfinance - Yahoo Finance API for financial data
python-dotenv - Environment variable management
black - Code formatting
pydantic - Data validation and serialization
License
This project is available under the MIT License.
Contributing
Fork the repository
Create a feature branch
Make your changes
Add tests if applicable
Format code with black
Submit a pull request
Support
For issues and questions:
Check the Issues section
Review the
CLAUDE.mdfile for development guidanceEnsure all dependencies are properly installed with
uv sync
Changelog
v0.1.0
Initial implementation with 10 financial data tools
FastMCP server framework integration
Comprehensive error handling
Full yfinance API coverage
MCP client integration support
Available Tools
10 toolsget_dividendsB
Get dividend history for a stock.
Args: symbol: Stock ticker symbol (e.g., 'AAPL', 'GOOGL')
Returns: Dictionary containing dividend history
Inputs: symbol (required). Returns: object
get_earningsA
Get earnings data for a stock. Note: Uses income statement data as 'earnings' property is deprecated.
Args: symbol: Stock ticker symbol (e.g., 'AAPL', 'GOOGL')
Returns: Dictionary containing earnings data extracted from financial statements
Inputs: symbol (required). Returns: object
get_financialsA
Get financial statements for a stock.
Args: symbol: Stock ticker symbol (e.g., 'AAPL', 'GOOGL') quarterly: If True, get quarterly data; if False, get annual data
Returns: Dictionary containing financial statements
Inputs: symbol (required), quarterly. Returns: object
get_historical_dataA
Get historical stock price data.
Args: symbol: Stock ticker symbol (e.g., 'AAPL', 'GOOGL') period: Time period (1d,5d,1mo,3mo,6mo,1y,2y,5y,10y,ytd,max) interval: Data interval (1m,2m,5m,15m,30m,60m,90m,1h,1d,5d,1wk,1mo,3mo)
Returns: Dictionary containing historical price data
Inputs: symbol (required), period, interval. Returns: object
get_multiple_quotesA
Get current quotes for multiple stocks at once.
Args: symbols: List of stock ticker symbols (e.g., ['AAPL', 'GOOGL', 'MSFT'])
Returns: Dictionary containing quotes for all requested symbols
Inputs: symbols (required). Returns: object
get_newsA
Get recent news for a stock.
Args: symbol: Stock ticker symbol (e.g., 'AAPL', 'GOOGL') count: Number of news articles to return (default: 10)
Returns: Dictionary containing news articles
Inputs: symbol (required), count. Returns: object
get_recommendationsA
Get analyst recommendations for a stock.
Args: symbol: Stock ticker symbol (e.g., 'AAPL', 'GOOGL')
Returns: Dictionary containing analyst recommendations
Inputs: symbol (required). Returns: object
get_splitsA
Get stock split history for a stock.
Args: symbol: Stock ticker symbol (e.g., 'AAPL', 'GOOGL')
Returns: Dictionary containing split history
Inputs: symbol (required). Returns: object
get_stock_infoA
Get basic stock information including current price, market cap, and key metrics.
Args: symbol: Stock ticker symbol (e.g., 'AAPL', 'GOOGL')
Returns: Dictionary containing stock information
Inputs: symbol (required). Returns: object
search_stocksA
Search for stocks by company name or ticker symbol.
This tool searches Yahoo Finance's database for stocks matching your query. Works best with specific company names or partial ticker symbols.
Examples of effective queries:
"Microsoft" (company name)
"AAPL" (ticker symbol)
"Tesla" (company name)
"JPM" (partial ticker)
Note: Complex multi-word queries may return fewer results. For best results, search for one company at a time.
Args: query: Search query - company name or ticker symbol (e.g., 'Microsoft', 'AAPL') limit: Maximum number of results to return (default: 10, max recommended: 25)
Returns: Dictionary containing search results with symbol, name, type, exchange, sector, industry, relevance score, and other metadata
Inputs: query (required), limit. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Most tools target distinct data types, but get_stock_info and get_multiple_quotes both provide current quote data, and get_earnings overlaps with get_financials by design. The descriptions help clarify the intended usage, making confusion unlikely in practice.
All tools follow a consistent snake_case verb_noun pattern, with get_ as the dominant prefix for data retrieval and search_stocks as a logical exception for the search action. This is a predictable and uniform naming convention.
10 tools is well within the ideal 3-15 range for a specialized data provider, and each tool covers a distinct aspect of stock market data without unnecessary duplication.
The server covers the core financial data needs: current quotes, historical prices, dividends, splits, financials, earnings, news, recommendations, search, and batch quotes. As a read-only stock data API, it has no significant gaps.
Maintenance
Related MCP Connectors
Yahoo Finance for AI agents: quotes, price history, options with Greeks, financials, news, movers.
Yahoo Finance stock quotes and multi-ticker comparison as agent tools.
Your agent needs company financials it can compute on — statements, ratios, earnings, estimates, filings and insider activity as structured data, not a PDF. **What you can ask for** • "Give me 8 quarters of income statement, balance sheet and cash flow for this ticker." • "What do analysts estimate for next quarter, and how did the last four surprise?" • "Find this exact line item across every filing." • "Who bought or sold as an insider in the last 90 days?" • "Screen for profitable companies under this valuation with growing revenue." **How to use it** Point any MCP client at https://mcp.aisa.one/marketpulse/mcp and sign in with OAuth — there is no key to create or paste. 21 tools: prices and snapshots, income statements, balance sheets, cash-flow statements, financial metrics and snapshots, earnings, analyst estimates, company facts, filings and filing items, line-item search, a screener, insider trades, macro interest rates, news, plus EDINET documents and filing digests for Japanese issuers. **Why this rather than the source** Statements as fields you can compute on, and a screener in the same place. **It is also a door to the rest** The same login reaches 26 sources and 580+ operations. Read the fundamentals here, then ask the same agent what social is saying about the ticker — without adding a second server. **What it costs** Finding and inspecting an operation is free. Running one is billed per call at API prices, with no seat and no monthly minimum, and every call takes max_price_usd so an agent cannot overspend by accident. **Where else it reaches** https://mcp.aisa.one/finance/mcp for equities, crypto and prediction markets in one place.
Your agent needs markets — prices and fundamentals for listed companies, the filings behind them, crypto, and what the prediction markets put the odds at. **What you can ask for** • "Pull this company's income statement, cash flow and balance sheet for the last 8 quarters." • "What did insiders buy or sell, and when?" • "Snapshot prices for these 50 tickers, then the OHLC history for the three that moved." • "What are the current odds on this event across Kalshi and Polymarket?" • "Screen for companies matching these financial criteria." **How to use it** Point any MCP client at https://mcp.aisa.one/finance/mcp and sign in with OAuth — there is no key to create or paste. 49 tools: prices and snapshots, income statements, balance sheets and cash flows, metrics and ratios, earnings and analyst estimates, filings and line-item search, insider trades, macro interest rates, news, a screener; CoinGecko spot prices, market tables, OHLC, per-venue tickers and trending; Kalshi and Polymarket markets and trades; plus EDINET filings for Japan. **Why this rather than the source** Equities, crypto and event markets behind one account, so a cross-asset question is one conversation. **It is also a door to the rest** The same login reaches 26 sources and 580+ operations. Read the number here, then ask the same agent what X is saying about the ticker today — without adding a second server. **What it costs** Finding and inspecting an operation is free. Running one is billed per call at API prices, with no seat and no monthly minimum, and every call takes max_price_usd so an agent cannot overspend by accident. **Where else it reaches** https://mcp.aisa.one/marketpulse/mcp · /crypto-market-data/mcp · /prediction-market-data/mcp · /stock-pulse/mcp for one slice each.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to access real-time financial data, historical stock prices, company information, financial statements, options data, market news, and analyst recommendations through Yahoo Finance. Built with FastMCP v2 for efficient HTTP streaming and comprehensive market analysis tools.4-
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to retrieve real-time stock data, manage watchlists, and perform comprehensive technical analysis using Yahoo Finance API. Provides 18+ tools for stock price tracking, trend analysis, volatility assessment, and financial indicators through MCP integration.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to access Yahoo Finance data including stock information, news, price history, options, and earnings via MCP tools.54MIT
- AlicenseAqualityDmaintenanceEnables querying stock data, financial information, news, and historical prices from Yahoo Finance through a set of MCP tools.5MIT