robinhood_get_positions
Retrieve all current stock positions from your Robinhood portfolio, including price, quantity, average buy price, equity, and percent change for each holding.
Instructions
Get all current stock positions with details.
Returns a dict mapping stock symbols to position details including price, quantity, average buy price, equity, and percent change.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/robinhood_mcp/server.py:110-118 (handler)MCP tool handler for 'robinhood_get_positions'. Decorated with @mcp.tool(), ensures the user is logged in, then delegates to get_positions() from tools module.
@mcp.tool() def robinhood_get_positions() -> dict: """Get all current stock positions with details. Returns a dict mapping stock symbols to position details including price, quantity, average buy price, equity, and percent change. """ _ensure_logged_in() return get_positions() - src/robinhood_mcp/tools.py:133-140 (schema)Schema/type definition: TUPLES of expected fields for position data (price, quantity, avg buy price, equity, percent_change, equity_change).
_POSITION_FIELDS = ( "price", "quantity", "average_buy_price", "equity", "percent_change", "equity_change", ) - src/robinhood_mcp/server.py:32-37 (registration)FastMCP server instantiation - the decorator @mcp.tool() on robinhood_get_positions registers it as an MCP tool.
# Initialize FastMCP server (older versions don't accept description kwarg). try: mcp = FastMCP( "robinhood-mcp", description="Read-only research tools for Robinhood portfolio data", ) - src/robinhood_mcp/tools.py:100-130 (helper)Core implementation get_positions() - fetches all stock positions via rh.account.build_holdings with caching (30s TTL) and thread-safe lock.
def get_positions() -> dict[str, dict[str, Any]]: """Get all current stock positions with details. Returns: Dict mapping symbol to position details including: - price, quantity, average_buy_price - equity, percent_change, equity_change """ global _positions_cache, _positions_cache_ts now = time.monotonic() cached = _get_positions_cached(now) if cached is not None: return cached with _positions_cache_lock: now = time.monotonic() if ( _positions_cache is not None and (now - _positions_cache_ts) < _POSITIONS_CACHE_TTL_SECONDS ): return deepcopy(_positions_cache) result = _safe_call(rh.account.build_holdings) if not isinstance(result, dict): raise RobinhoodError( f"Unexpected build_holdings response type: {type(result).__name__}" ) _positions_cache = deepcopy(result) _positions_cache_ts = time.monotonic() return result