Skip to main content
Glama
leoncuhk

MCP Yahoo Finance

by leoncuhk

get_current_stock_price

Retrieve real-time stock price data for any publicly traded company using its stock symbol. This tool provides current market prices to support investment decisions and financial analysis.

Instructions

Get the current stock price based on stock symbol.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesStock symbol in Yahoo Finance format.

Implementation Reference

  • The primary MCP tool handler for 'get_current_stock_price', registered via @mcp_instance.tool() decorator. It delegates execution to the YahooFinance instance's 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)
  • Supporting helper method in the YahooFinance class that performs the actual API call to yfinance to retrieve the current stock price.
    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" )

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