robinhood_get_ratings
Retrieve analyst ratings summary for any stock ticker to assess market sentiment and make informed investment decisions.
Instructions
Get analyst ratings summary for a stock.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Stock ticker symbol |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/robinhood_mcp/server.py:223-234 (handler)The MCP tool handler exposed as 'robinhood_get_ratings'. Decorated with @mcp.tool(), it calls _ensure_logged_in() then delegates to get_ratings(symbol).
@mcp.tool() def robinhood_get_ratings(symbol: str) -> dict: """Get analyst ratings summary for a stock. Args: symbol: Stock ticker symbol Returns ratings summary with buy, hold, sell counts, and overall recommendation. """ _ensure_logged_in() return get_ratings(symbol) - src/robinhood_mcp/tools.py:334-348 (schema)The actual business-logic implementation of get_ratings(). Normalizes the symbol, calls robin_stocks' rh.stocks.get_ratings, validates the result is a dict, and returns it or raises RobinhoodError.
def get_ratings(symbol: str) -> dict[str, Any]: """Get analyst ratings summary for a stock. Args: symbol: Stock ticker symbol. Returns: Ratings summary with buy, hold, sell counts and summary. """ symbol = _normalize_symbol(symbol) result = _safe_call(rh.stocks.get_ratings, symbol) if isinstance(result, dict): return result raise RobinhoodError(f"No ratings found for symbol: {symbol}") - src/robinhood_mcp/server.py:24-27 (registration)Import registration — get_ratings is imported from .tools module so it can be used by the MCP handler in server.py.
get_ratings, get_watchlist, search_symbols, ) - src/robinhood_mcp/tools.py:24-46 (helper)_safe_call helper used by get_ratings to invoke the underlying robin_stocks API call with error handling.
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 - src/robinhood_mcp/tools.py:49-56 (helper)_normalize_symbol helper used by get_ratings to uppercase and validate the ticker symbol.
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