get_dividends
Retrieve dividend data for a specific stock symbol using the MCP Yahoo Finance server. Input the stock symbol to access payout details for financial analysis or investment decisions.
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 @mcp_instance.tool() decorator. It calls the underlying YahooFinance.get_dividends 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)
- Helper method in YahooFinance class that fetches dividends data using yfinance.Ticker and formats it 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')}"