get_dividends
Retrieve dividend information for a specific stock symbol to analyze income potential and track payout history.
Instructions
Get dividends for a given stock symbol.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Stock symbol in Yahoo Finance format. |
Implementation Reference
- src/mcp_yahoo_finance/server.py:250-257 (handler)The MCP tool handler for get_dividends. Registered via FastMCP @tool decorator. Executes by delegating to the YahooFinance class method.@mcp_instance.tool() def get_dividends(symbol: str) -> str: """Get dividends for a given stock symbol. Args: symbol (str): Stock symbol in Yahoo Finance format. """ return yf_instance.get_dividends(symbol)
- Core implementation of get_dividends in YahooFinance class using yfinance.Ticker to fetch and format dividends as JSON.def get_dividends(self, symbol: str) -> str: """Get dividends for a given stock symbol. Args: symbol (str): Stock symbol in Yahoo Finance format. """ stock = Ticker(ticker=symbol, session=self.session) dividends = stock.dividends if hasattr(dividends.index, "date"): dividends.index = dividends.index.date.astype(str) # type: ignore return f"{dividends.to_json(orient='index')}"