Skip to main content
Glama
leoncuhk

MCP Yahoo Finance

by leoncuhk

get_stock_price_date_range

Retrieve historical stock prices for a specific symbol within a defined date range using Yahoo Finance data.

Instructions

Get the stock prices for a given date range for a given stock symbol.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesStock symbol in Yahoo Finance format.
start_dateYesThe start date in YYYY-MM-DD format.
end_dateYesThe end date in YYYY-MM-DD format.

Implementation Reference

  • MCP tool handler for get_stock_price_date_range, decorated with @mcp_instance.tool() for registration. Delegates to YahooFinance instance method.
    @mcp_instance.tool() def get_stock_price_date_range(symbol: str, start_date: str, end_date: str) -> str: """Get the stock prices for a given date range for a given stock symbol. Args: symbol (str): Stock symbol in Yahoo Finance format. start_date (str): The start date in YYYY-MM-DD format. end_date (str): The end date in YYYY-MM-DD format. """ return yf_instance.get_stock_price_date_range(symbol, start_date, end_date)
  • Core implementation in YahooFinance class: fetches historical stock prices using yfinance.Ticker.history() and returns Close prices as JSON.
    def get_stock_price_date_range( self, symbol: str, start_date: str, end_date: str ) -> str: """Get the stock prices for a given date range for a given stock symbol. Args: symbol (str): Stock symbol in Yahoo Finance format. start_date (str): The start date in YYYY-MM-DD format. end_date (str): The end date in YYYY-MM-DD format. """ stock = Ticker(ticker=symbol, session=self.session) prices = stock.history(start=start_date, end=end_date) prices.index = prices.index.astype(str) return f"{prices['Close'].to_json(orient='index')}"

Latest Blog Posts

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/leoncuhk/mcp-yahoo-finance'

If you have feedback or need assistance with the MCP directory API, please join our Discord server