robinhood_get_earnings
Get earnings data for any stock using its ticker symbol. View revenue, EPS, and earnings dates to support investment research and portfolio analysis.
Instructions
Get earnings data for a stock.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Stock ticker symbol |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/robinhood_mcp/server.py:209-220 (registration)The @mcp.tool() decorator registers 'robinhood_get_earnings' as an MCP tool. The function calls get_earnings(symbol) after ensuring the user is logged in.
@mcp.tool() def robinhood_get_earnings(symbol: str) -> list: """Get earnings data for a stock. Args: symbol: Stock ticker symbol Returns list of earnings reports with EPS, report date, analyst estimates, and actual vs expected. """ _ensure_logged_in() return get_earnings(symbol) - src/robinhood_mcp/tools.py:320-331 (handler)Actual handler/implementation of get_earnings. It normalizes the symbol, calls rh.stocks.get_earnings via _safe_call, and returns the result as a list.
def get_earnings(symbol: str) -> list[dict[str, Any]]: """Get earnings data for a stock. Args: symbol: Stock ticker symbol. Returns: List of earnings reports with eps, report date, estimates, etc. """ symbol = _normalize_symbol(symbol) result = _safe_call(rh.stocks.get_earnings, symbol) return result if isinstance(result, list) else [] - src/robinhood_mcp/tools.py:49-56 (helper)_normalize_symbol helper: validates and uppercases the ticker symbol, called by get_earnings.
def _normalize_symbol(symbol: str) -> str: """Normalize and validate ticker symbols.""" if not symbol or not isinstance(symbol, str): raise RobinhoodError("Symbol must be a non-empty string") symbol = symbol.upper().strip() if not symbol: raise RobinhoodError("Symbol must be a non-empty string") return symbol - src/robinhood_mcp/tools.py:24-46 (helper)_safe_call helper: wraps robin_stocks API calls with error handling, used by get_earnings to call rh.stocks.get_earnings.
def _safe_call(func: Callable[..., Any], *args, **kwargs) -> Any: """Safely call a robin_stocks function with error handling. Args: func: The robin_stocks function to call. *args: Positional arguments. **kwargs: Keyword arguments. Returns: The function result. Raises: RobinhoodError: If the call fails. """ try: result = func(*args, **kwargs) if result is None: raise RobinhoodError("API returned None - you may need to login first") return result except RobinhoodError: raise except Exception as e: raise RobinhoodError(f"API call failed: {e}") from e