Skip to main content
Glama
leoncuhk

MCP Yahoo Finance

by leoncuhk

get_current_stock_price

Retrieve the current stock price by providing the stock symbol in Yahoo Finance format. Ideal for accessing real-time financial data for analysis or decision-making.

Instructions

Get the current stock price based on stock symbol.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesStock symbol in Yahoo Finance format.

Implementation Reference

  • MCP tool registration and handler function for 'get_current_stock_price'. This is the entry point decorated with @mcp_instance.tool() that delegates to the YahooFinance instance method.
    @mcp_instance.tool() def get_current_stock_price(symbol: str) -> str: """Get the current stock price based on stock symbol. Args: symbol (str): Stock symbol in Yahoo Finance format. """ return yf_instance.get_current_stock_price(symbol)
  • Core implementation in YahooFinance class that fetches the current stock price using yfinance Ticker.info and formats the response.
    def get_current_stock_price(self, symbol: str) -> str: """Get the current stock price based on stock symbol. Args: symbol (str): Stock symbol in Yahoo Finance format. """ stock = Ticker(ticker=symbol, session=self.session).info current_price = stock.get( "regularMarketPrice", stock.get("currentPrice", "N/A") ) return ( f"{current_price:.4f}" if current_price else f"Couldn't fetch {symbol} current price" )

Other Tools

Related Tools

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