robinhood_search_symbols
Search for stock symbols by entering a company name or partial ticker. Get matching ticker symbols for portfolio research.
Instructions
Search for stock symbols by company name or ticker.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query (company name or partial ticker) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/robinhood_mcp/tools.py:371-398 (handler)Core implementation: searches Robinhood instruments by symbol (exact match) or company name (fuzzy search via find_instrument_data).
def search_symbols(query: str) -> list[dict[str, Any]]: """Search for stock symbols by company name or ticker. Args: query: Search query (company name or partial ticker). Returns: List of matching instruments with symbol, name, etc. """ if not query or not isinstance(query, str): raise RobinhoodError("Query must be a non-empty string") query = query.strip() # Try to get instruments by the query try: result = rh.stocks.get_instruments_by_symbols(query.upper()) if result and isinstance(result, list): return result except Exception: pass # If exact match fails, try search try: result = rh.stocks.find_instrument_data(query) return result if isinstance(result, list) else [] except Exception as e: raise RobinhoodError(f"Search failed: {e}") from e - src/robinhood_mcp/server.py:259-270 (registration)MCP tool registration: decorates robinhood_search_symbols as a FastMCP tool, delegates to tools.search_symbols().
@mcp.tool() def robinhood_search_symbols(query: str) -> list: """Search for stock symbols by company name or ticker. Args: query: Search query (company name or partial ticker) Returns list of matching instruments with symbol, name, and other details. """ _ensure_logged_in() return search_symbols(query) - src/robinhood_mcp/server.py:12-46 (helper)Import of search_symbols from the tools module into server.py.
from .tools import ( RobinhoodError, get_dividends, get_earnings, get_fundamentals, get_historicals, get_news, get_options_positions, get_portfolio, get_position, get_positions, get_quote, get_ratings, get_watchlist, search_symbols, ) # Load environment variables load_dotenv() # Initialize FastMCP server (older versions don't accept description kwarg). try: mcp = FastMCP( "robinhood-mcp", description="Read-only research tools for Robinhood portfolio data", ) except TypeError: mcp = FastMCP("robinhood-mcp") # Track login state _login_attempted = False _login_error: str | None = None _login_lock = threading.Lock() _cached_login_status: bool | None = None _cached_login_status_ts = 0.0 - src/robinhood_mcp/tools.py:24-46 (helper)Error-handling wrapper used by other tools but not directly by search_symbols (which handles its own errors inline).
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